[jira] [Commented] (MATH-949) LevenbergMarquardtOptimizer reports 0 iterations

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-949) LevenbergMarquardtOptimizer reports 0 iterations

Baljit Singh (Jira)

    [ https://issues.apache.org/jira/browse/MATH-949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13604282#comment-13604282 ]

Gilles commented on MATH-949:
-----------------------------

Actually, the number of iterations is used in the "optim.linear" package while the number of evaluations is used in the "optim.nonlinear" package. The counters were both moved to a unique base class in order to reduce the amount of code duplication.

It seems indeed that now we should indeed update the iterations counter in every optimizer implementation.

We could also take both limits (evaluations and iterations) into account but I'm not sure that would be useful. I think that it would be confusing; some time ago, we agreed that the number of evaluations is a better measure of an optimization algorithm (at least when the evaluation is more costly than the optimization's bookkeeping).

               

> LevenbergMarquardtOptimizer reports 0 iterations
> ------------------------------------------------
>
>                 Key: MATH-949
>                 URL: https://issues.apache.org/jira/browse/MATH-949
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.2
>            Reporter: Evan Ward
>
> The method LevenbergMarquardtOptimizer.getIterations() does not report the correct number of iterations; It always returns 0. A quick look at the code shows that only SimplexOptimizer calls BaseOptimizer.incrementEvaluationsCount()
> I've put a test case below. Notice how the evaluations count is correctly incremented, but the iterations count is not.
> {noformat}
>     @Test
>     public void testGetIterations() {
>         // setup
>         LevenbergMarquardtOptimizer otim = new LevenbergMarquardtOptimizer();
>         // action
>         otim.optimize(new MaxEval(100), new Target(new double[] { 1 }),
>                 new Weight(new double[] { 1 }), new InitialGuess(
>                         new double[] { 3 }), new ModelFunction(
>                         new MultivariateVectorFunction() {
>                             @Override
>                             public double[] value(double[] point)
>                                     throws IllegalArgumentException {
>                                 return new double[] { FastMath.pow(point[0], 4) };
>                             }
>                         }), new ModelFunctionJacobian(
>                         new MultivariateMatrixFunction() {
>                             @Override
>                             public double[][] value(double[] point)
>                                     throws IllegalArgumentException {
>                                 return new double[][] { { 0.25 * FastMath.pow(
>                                         point[0], 3) } };
>                             }
>                         }));
>         // verify
>         assertThat(otim.getEvaluations(), greaterThan(1));
>         assertThat(otim.getIterations(), greaterThan(1));
>     }
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira