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] Re: Pass ConvergenceChecker to BOBYQAOptimizer
Date Wed, 28 Aug 2013 22:15:15 GMT
On Wed, 28 Aug 2013 04:53:26 -0700 (PDT), Thomas wrote:
> Hi!
>
> I have tried to use the CMAESOptimizer but unfortunately the program 
> (given
> below) is aborted with the following exception:
>
> Exception in thread "main" java.lang.NullPointerException
> 	at
> 
> org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizer.checkParameters(CMAESOptimizer.java:554)
> 	at
> 
> org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizer.parseOptimizationData(CMAESOptimizer.java:542)
> 	at
> 
> org.apache.commons.math3.optim.BaseOptimizer.optimize(BaseOptimizer.java:137)
> 	at
> 
> org.apache.commons.math3.optim.BaseMultivariateOptimizer.optimize(BaseMultivariateOptimizer.java:66)
> 	at
> 
> org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer.optimize(MultivariateOptimizer.java:64)
> 	at
> 
> org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizer.optimize(CMAESOptimizer.java:363)
> 	at CMA_ES.main(CMA_ES.java:122)
>
>
>
> The optimizer I used as follows:
>
>
> public static void main(String[] args){
>
>   MultivariateFunction f = new MultivariateFunction() {
>   @Override
>   public double value(double[] arg0) {
>     double res = 0;
>       for(int i = 0; i < arg0.length; i++){
>         res = res + Math.pow(arg0[i], 2);
>       }
>       return res;
>     }
>   };
>
>   int dim = 50;
>
>   JDKRandomGenerator rand = new JDKRandomGenerator();
>   rand.setSeed(1503);
>
>   double[] sigma = new double[dim];
>   for(int i = 0; i < dim; i++){
>     sigma[i] = 5;
>   }
>
>
>   SimpleValueChecker checker = new SimpleValueChecker(1E-3, 1E-6);
>   CMAESOptimizer opt = new CMAESOptimizer(Integer.MAX_VALUE,
> Double.NEGATIVE_INFINITY, true, 1, 1, rand, false, checker);
>   PointValuePair p = opt.optimize(new ObjectiveFunction(f),
> GoalType.MINIMIZE, new CMAESOptimizer.Sigma(sigma), new
> CMAESOptimizer.PopulationSize(25));
>
>
> According to the API I have to specify the objective function and the 
> goal
> of optimization. Moreover, if using the CMAES I have also to specify 
> Sigma
> and PopulationSize. Obviously, I specified these parameters in my 
> code,
> hence I wonder a bit why the exception is thrown. Does anyone has
> suggestions? Thanks a lot.

The error is a missing "starting point".
See apidocs of the parent class(es).

HTH,
Gilles


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message