List of usage examples for org.apache.commons.math3.optimization.direct CMAESOptimizer CMAESOptimizer
@Deprecated public CMAESOptimizer(int lambda, double[] inputSigma, int maxIterations, double stopFitness, boolean isActiveCMA, int diagonalOnly, int checkFeasableCount, RandomGenerator random, boolean generateStatistics)
From source file:edu.stevens.cpe.reservior.readout.CMAES.java
public double[] train(int numberWeightsToTrain) { this.epoch = 0; //Number of weights to evolve final double[] start = new double[numberWeightsToTrain]; Arrays.fill(start, startValue); final double[] lower = new double[numberWeightsToTrain]; Arrays.fill(lower, lowerBound); final double[] upper = new double[numberWeightsToTrain]; Arrays.fill(upper, upperBound); //Set to 1/3 the initial search volume final double[] sigma = new double[numberWeightsToTrain]; Arrays.fill(sigma, insigma);/*from w ww. jav a 2 s. c o m*/ int lambda = 4 + (int) (3. * Math.log(numberWeightsToTrain)); int maxEvals = CMAESOptimizer.DEFAULT_MAXITERATIONS; double stopValue = .01; boolean isActive = true; //Chooses the covariance matrix update method. int diagonalOnly = 0; int checkFeasable = 0; final CMAESOptimizer optimizer = new CMAESOptimizer(lambda, sigma, CMAESOptimizer.DEFAULT_MAXITERATIONS, stopValue, isActive, diagonalOnly, checkFeasable, new MersenneTwister(), false); final PointValuePair result = optimizer.optimize(maxEvals, fitnessFuntion, GoalType.MINIMIZE, start, lower, upper); logger.info(Arrays.toString(result.getPoint())); logger.info("Best weights: " + Arrays.toString(bestWeights)); updateReadoutWeights(result.getPoint()); logger.info("done training."); return bestWeights; }
From source file:edu.stevens.cpe.reservior.demo.EvolvedReservoir.java
/** * Optimize the convolution filter/* w w w .jav a2 s .c o m*/ */ public void optimize(int size) { this.epoch = 0; //Number of weights to evolve final double[] start = new double[] { 3, 0, 1, 20, .1 }; final double[] lower = new double[] { 1, 0, 0, 15, .08 }; final double[] upper = new double[] { 5, 5, 3, 120, .3 }; //Set to 1/3 the initial search volume final double[] sigma = new double[size]; Arrays.fill(sigma, insigma); int lambda = 4 + (int) (3. * Math.log(size)); int maxEvals = 100000;//CMAESOptimizer.DEFAULT_MAXITERATIONS; double stopValue = .01; boolean isActive = true; //Chooses the covariance matrix update method. int diagonalOnly = 0; int checkFeasable = 0; final CMAESOptimizer optimizer = new CMAESOptimizer(lambda, sigma, 100000, //CMAESOptimizer.DEFAULT_MAXITERATIONS, stopValue, isActive, diagonalOnly, checkFeasable, new MersenneTwister(), false); final PointValuePair result = optimizer.optimize(maxEvals, fitnessFuntion, GoalType.MINIMIZE, start, lower, upper); logger.info(Arrays.toString(result.getPoint())); }