Hello, I am new to Commons Math (3.2 on MacOS 10.5.8) and am struggling to maximize a simple function. I think I need to use the optimization classes, but the user guide ( http://commons.apache.org/proper/commons-math/userguide/optimization.html) seems to refer mainly to functions that are deprecated according to the API. Mucking around through the API, I think I have found some other functions that are not deprecated, but it's really not clear to me how to use them.
What I have done so far is: import org.apache.commons.math3.analysis.*; import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.*; import org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction; import org.apache.commons.math3.optim.nonlinear.scalar.GoalType; then somewhere I define a mutlivariate function: class TestFcMulti implements MultivariateFunction { public double value(double[] par) { return - par[0] * par[0]; } } but then the following code does not work: public Test_MC() { TestFcMulti tf = new TestFcMulti(); ObjectiveFunction obFc = new ObjectiveFunction(tf); SimplexOptimizer so = new SimplexOptimizer(0.01, 0.01); so.optimize(obFc, GoalType.MAXIMIZE); // Doesn't work so.optimize(); // Doesn't work } Is there a simple example somewhere, or can someone explain what to do? Thanks, Philippe