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?
Thanks,
Philippe