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.



--
View this message in context: 
http://apache-commons.680414.n4.nabble.com/math-Struggling-with-opimization-tp4650246p4653405.html
Sent from the Commons - User mailing list archive at Nabble.com.

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

Reply via email to