Search code examples
ampl

Ampl finds optimal solution in 0 iteration, but the variables are wrongly set to 0


I'm trying to solve this non-linear problem:

var c;
var n;

minimize error:
(
    (6770924 - (n * c * exp(-c * 1)))^2 + 
    (3617627 - (n * c * exp(-c * 2)))^2 + 
    (2344172 - (n * c * exp(-c * 3)))^2
) / 3;

When I execute this code, I have the success message with 0 iteration:

MINOS 5.51: optimal solution found.
0 iterations, objective 214759264300000
Non lin evals: obj = 3 grad = 2.

But the variables 'n' and 'c' are set to '0'. And using this answer I get a bad value from the function, since nothing is subtracted from the constant values.

If I take out the 'n' variable from the function I have a normal answer, with 'c' minimizing my function. What is wrong with the model I described?

Thanks in advance.


Solution

  • As already mentioned in this post, MINOS is sensitive to the starting point. For example, using 1 as a starting value for n gives a better objective value:

    ampl: let n := 1;
    ampl: solve;
    MINOS 5.51: optimal solution found.
    10 iterations, objective 24439722900
    Nonlin evals: obj = 34, grad = 33.