Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 021EFD224 for ; Thu, 23 May 2013 14:13:15 +0000 (UTC) Received: (qmail 64036 invoked by uid 500); 23 May 2013 14:13:13 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 63954 invoked by uid 500); 23 May 2013 14:13:13 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 63929 invoked by uid 99); 23 May 2013 14:13:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 May 2013 14:13:12 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [193.74.71.26] (HELO hel.is.scarlet.be) (193.74.71.26) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 May 2013 14:13:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1369318365; bh=lg8IMYG/X/AOqkYN0UZUovx9skCALeVrdjsIJk2sasI=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To: Subject:In-Reply-To:References:Message-ID; b=3vQEJdUZgGeLP5HZWegbMgsYQX8BSiAxfbceW3zACZmFIXOQjWr+FF2Gyk+FcvMgJ gmIlQzUNr05ydJBCfuZN+O33/8iaMkyB4/SOx5QP0+BWzY8N+UaKiXK06egcR/Aow5 u7wyB/5YE9UXSS6AnmYB/nInbaOAnoPZ3lqowNFE= Received: from webmail.scarlet.be (meigs.is.scarlet.be [193.74.71.216]) by hel.is.scarlet.be (8.14.5/8.14.5) with ESMTP id r4NECiNf004023 for ; Thu, 23 May 2013 16:12:45 +0200 X-Scarlet: d=1369318365 c=193.74.71.216 Received: from ip-83-134-165-164.dsl.scarlet.be ([83.134.165.164]) via ip-83-134-165-164.dsl.scarlet.be ([83.134.165.164]) by webmail.scarlet.be with HTTP (HTTP/1.1 POST); Thu, 23 May 2013 16:12:44 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 23 May 2013 16:12:44 +0200 From: Gilles To: Subject: Re: [math] Struggling with opimization In-Reply-To: References: Message-ID: X-Sender: gilles@harfang.homelinux.org User-Agent: Scarlet Webmail X-DCC-scarlet.be-Metrics: hel; whitelist X-Virus-Scanned: clamav-milter 0.97.1-exp at hel X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org On Thu, 23 May 2013 09:40:44 -0400, Mister Mak wrote: > Hello, > > I am new to Commons Math (3.2 on MacOS 10.5.8) and am struggling to > maximize a simple function. I think I need to use the optimization > classes, but the user guide [...] The user guide needs updating. > > http://commons.apache.org/proper/commons-math/userguide/optimization.html) > seems to refer mainly to functions that are deprecated according to > the > API. Mucking around through the API, I think I have found some other > functions that are not deprecated, but it's really not clear to me > how to > use them. > > What I have done so far is: > > import org.apache.commons.math3.analysis.*; > import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.*; > import > org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction; > import org.apache.commons.math3.optim.nonlinear.scalar.GoalType; > > then somewhere I define a mutlivariate function: > > class TestFcMulti implements MultivariateFunction { > public double value(double[] par) { > return - par[0] * par[0]; > } > } > > but then the following code does not work: > > public Test_MC() { > > TestFcMulti tf = new TestFcMulti(); > ObjectiveFunction obFc = new ObjectiveFunction(tf); > SimplexOptimizer so = new SimplexOptimizer(0.01, 0.01); > > so.optimize(obFc, GoalType.MAXIMIZE); // Doesn't work > so.optimize(); // Doesn't work > } > > > Is there a simple example somewhere, or can someone explain what to > do? What is the error? Regards, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org