Le 17/04/2013 10:08, Eric HENON a écrit :
> Hello,
>
> I'm trying to do a non linear
> regression using the LevenbergMarquardtOptimizer.
>
> I have copied the proposed Demo code at:
> http://commons.apache.org/proper/commons-math/userguide/optimization.html
>
> and I get the following error at the java
> compilation time:
>
> "The method optimize(OptimizationData..) in the type
> AbstractLeastSquaresOptimizer is not
> applicable for the arguments (int, QuadraticProblem, double[], double[],
> double[])"
>
> It seems that the optimize method employed in the Demo code is not
> the appropriate one.
You are right. This code correspond to the former API in the
optimization package, which is still available but deprecated now. The
new API is in the optim package and it is the one you use, which expect
OptimizationData parameters.
You can try to wrap the arguments in the various implementations of the
OptimizationData interface according to their meaning.
So you should end up with something like;
lm.optimize(new MaxEval(maxEval),
new ModelFunction(function),
new ModelFunctionJacobian(jacobian),
new Target(target),
new Weight(weight),
new InitialGuess(initial));
hope this helps.
Luc
>
> I tried to change the imports, but that does not work.
>
> Any help will be appreciated.
> Thanks.
> Eric
>
> ****
> ...
> LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
> ...
> PointVectorValuePair optimum = optimizer.optimize(100, problem,
> problem.calculateTarget(), weights, initialSolution);
> ****
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]