use of org.apache.commons.math3.optim.nonlinear.scalar.noderiv.MultiDirectionalSimplex in project narchy by automenta.
the class Optimize method solve.
public void solve(int dim, ObjectiveFunction func, double[] mid, double[] min, double[] max, double[] inc, int maxIterations) {
if (dim == 1) {
// use a solver capable of 1 dim
new SimplexOptimizer(1e-10, 1e-30).optimize(new MaxEval(maxIterations), func, GoalType.MAXIMIZE, new InitialGuess(mid), // new NelderMeadSimplex(inc)
new MultiDirectionalSimplex(inc));
} else {
int popSize = // 4 + 3 ln(n)
(int) Math.ceil(4 + 3 * Math.log(tweaks.size()));
double[] sigma = MathArrays.scale(1f, inc);
MyCMAESOptimizer m = new MyCMAESOptimizer(maxIterations, Double.NaN, true, 0, 1, new MersenneTwister(System.nanoTime()), true, null, popSize, sigma);
m.optimize(func, GoalType.MAXIMIZE, new MaxEval(maxIterations), new SimpleBounds(min, max), new InitialGuess(mid));
m.print(System.out);
// final int numIterpolationPoints = 3 * dim; //2 * dim + 1 + 1;
// new BOBYQAOptimizer(numIterpolationPoints,
// dim * 2.0,
// 1.0E-4D /* ? */).optimize(
// MaxEval.unlimited(), //new MaxEval(maxIterations),
// new MaxIter(maxIterations),
// func,
// GoalType.MAXIMIZE,
// new SimpleBounds(min, max),
// new InitialGuess(mid));
}
}
Aggregations