The solution deteriorates if the domain of decisions is improperly set when using Ipopt

This is related to Ipopt’s automatic scaling that it applies.

If you solve the original model, you’ll see that Ipopt claims success, but reports

Overall NLP error.......:   3.3680175321150538e-09    3.3680175321150535e-01

So Ipopt solved the scaled problem to optimality, but the unscaled error is very high! I don’t know if this is classified as a bug. It happens in LP solvers as well.

For this problem, you could turn off scaling:

julia> using JuMP, Ipopt

julia> function main(; nlp_scaling_method = nothing)
           model = Model(Ipopt.Optimizer)
           if nlp_scaling_method !== nothing
               set_attribute(model, "nlp_scaling_method", nlp_scaling_method)
           end
           @variable(model, x >= 0)
           @objective(model, Min, x * log(x))
           optimize!(model)
           assert_is_solved_and_feasible(model)
           return value(x)
       end
main (generic function with 1 method)

julia> main()

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit https://github.com/coin-or/Ipopt
******************************************************************************

This is Ipopt version 3.14.17, running with linear solver MUMPS 5.7.3.

Number of nonzeros in equality constraint Jacobian...:        0
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:        1

Total number of variables............................:        1
                     variables with only lower bounds:        1
                variables with lower and upper bounds:        0
                     variables with only upper bounds:        0
Total number of equality constraints.................:        0
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -4.6051666e-02 0.00e+00 1.00e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -2.4280022e-01 0.00e+00 1.00e-02  -1.0 1.00e-01    -  9.90e-01 1.00e+00f  1
   2 -2.5997605e-01 0.00e+00 1.52e-06  -3.8 1.50e-02    -  1.00e+00 1.00e+00f  1
   3 -2.6269769e-01 0.00e+00 1.06e-08  -8.6 2.55e-03    -  9.93e-01 1.00e+00f  1
   4 -3.5116570e-01 0.00e+00 3.37e-09 -12.9 1.35e-01    -  1.00e+00 1.00e+00f  1

Number of Iterations....: 4

                                   (scaled)                 (unscaled)
Objective...............:  -3.5116570400222862e-09   -3.5116570400222863e-01
Dual infeasibility......:   3.3680175321150538e-09    3.3680175321150535e-01
Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
Variable bound violation:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   2.5724384364771816e-13    2.5724384364771815e-05
Overall NLP error.......:   3.3680175321150538e-09    3.3680175321150535e-01


Number of objective function evaluations             = 5
Number of objective gradient evaluations             = 5
Number of equality constraint evaluations            = 0
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 0
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 4
Total seconds in IPOPT                               = 2.535

EXIT: Optimal Solution Found.
0.26271017938293323

julia> main(; nlp_scaling_method = "none")
This is Ipopt version 3.14.17, running with linear solver MUMPS 5.7.3.

Number of nonzeros in equality constraint Jacobian...:        0
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:        1

Total number of variables............................:        1
                     variables with only lower bounds:        1
                variables with lower and upper bounds:        0
                     variables with only upper bounds:        0
Total number of equality constraints.................:        0
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -4.6051666e-02 0.00e+00 4.61e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -1.9902165e-01 0.00e+00 4.75e+00  -1.0 6.80e-02    -  1.00e+00 1.00e+00f  1
   2 -2.6593036e-01 0.00e+00 1.07e+00  -1.0 5.27e-02    -  7.77e-01 1.00e+00f  1
   3 -3.6776246e-01 0.00e+00 7.35e-01  -1.0 2.28e-01    -  1.00e+00 1.00e+00f  1
   4 -3.6779739e-01 0.00e+00 1.09e-03  -1.7 1.70e-02    -  1.00e+00 1.00e+00f  1
   5 -3.6787937e-01 0.00e+00 2.05e-04  -3.8 7.56e-03    -  1.00e+00 1.00e+00f  1
   6 -3.6787944e-01 0.00e+00 2.01e-07  -5.7 2.33e-04    -  1.00e+00 1.00e+00f  1
   7 -3.6787944e-01 0.00e+00 1.43e-11  -8.6 1.96e-06    -  1.00e+00 1.00e+00f  1

Number of Iterations....: 7

                                   (scaled)                 (unscaled)
Objective...............:  -3.6787944117144233e-01   -3.6787944117144233e-01
Dual infeasibility......:   1.4279221332907585e-11    1.4279221332907585e-11
Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
Variable bound violation:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   2.5167856134015930e-09    2.5167856134015930e-09
Overall NLP error.......:   2.5167856134015930e-09    2.5167856134015930e-09


Number of objective function evaluations             = 8
Number of objective gradient evaluations             = 8
Number of equality constraint evaluations            = 0
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 0
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 7
Total seconds in IPOPT                               = 0.002

EXIT: Optimal Solution Found.
0.36787944368297487
3 Likes