commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <gil...@harfang.homelinux.org>
Subject Re: [math] Struggling with opimization
Date Thu, 23 May 2013 14:12:44 GMT
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


Mime
View raw message