On Fri, 24 May 2013 09:52:23 -0400, Mister Mak wrote:
The multivariate function in my example was indeed flawed. Here is a
better example with Thomas' solution:
MultivariateFunction g =
new MultivariateFunction() {
public double value(double[] x) {
return Math.exp(-Math.abs(x[0] - 5.4)) *
Math.exp(-Math.abs(x[1] - 2.2)) + 1.1;
}
};
SimplexOptimizer optimizerMult = new SimplexOptimizer(1e-3,
1e-6);
PointValuePair solutionMult = optimizerMult.optimize(new
MaxEval(200), new ObjectiveFunction(g), GoalType.MAXIMIZE, new
InitialGuess(new double[]{0, 0}), new MultiDirectionalSimplex(2));
System.out.println("Min is: " + solutionMult.getValue() +
"\tobtained at:" + Arrays.toString(solutionMult.getKey()));
The above code works. However, introducing constraints like below,
doesn't.
PointValuePair solutionMult = optimizerMult.optimize(new
MaxEval(200), new
ObjectiveFunction(g), GoalType.MAXIMIZE, new InitialGuess(new
double[]{0,
0}), new MultiDirectionalSimplex(2), new SimpleBounds(new
double[]{-10,
-15}, new double[]{12, 22}));
So which optimizer does accept bounds?
"SimpleBounds" are used by "CMAESOptimizer".
For the other optimizers, bound handling can be mimicked by using the
MultivariateFunctionMappingAdapter
or
MultivariateFunctionPenaltyAdapter
defined in package "o.a.c.m.optim.nonlinear.scalar".
HTH,
Gilles
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org