cvanaret / Uno

A next-gen Lagrange-Newton solver for nonconvex optimization. It unifies barrier and SQP methods in a modern and generic way, and implements different globalization flavors (line search/trust region and merit function/filter method/funnel method). Competitive against filterSQP, IPOPT, SNOPT, MINOS and CONOPT.
MIT License
276 stars 20 forks source link

"The problem has inequality constraints. Create an instance of EqualityConstrainedModel" error when solving with ipopt preset in Debug mode #5

Closed traversaro closed 1 year ago

traversaro commented 1 year ago

I am trying to solve the example .nl files provided in https://github.com/cvanaret/Uno/tree/main/examples with uno_ampl with the ipopt preset, and they are both failing with:

uno_ampl: /home/traversaro/unows/Uno/uno/ingredients/subproblem/interior_point_methods/PrimalDualInteriorPointSubproblem.cpp:46: virtual void PrimalDualInteriorPointSubproblem::generate_initial_iterate(const NonlinearProblem&, Iterate&): Assertion `problem.has_inequality_constraints() && "The problem has inequality constraints. Create an instance of EqualityConstrainedModel"' failed.

However, if I try to comment out the assert in https://github.com/cvanaret/Uno/blob/e4a8fa7a21e9357c916d298b4f5cbb31a0f8d314/uno/ingredients/subproblem/interior_point_methods/PrimalDualInteriorPointSubproblem.cpp#L46, then the problems both get solved, and the solution is quite similar to the one found by ipopt, see for example for polak5.nl:

# Uno
(/home/traversaro/unows/env) traversaro@IITICUBLAP257:~/unows/Uno/build$ ./uno_ampl -preset ipopt -print_solution yes ../examples/polak5.nl
<...>
Uno (LS feasibility_restoration waechter_filter_method primal_dual_interior_point)
Wed Jun 21 16:31:43 2023
────────────────────────────────────────
Status:                                 Converged with feasible KKT point
Objective value:                        50
┌ Optimality stationarity residual:     8.458521e-09
│ Feasibility stationarity residual:    1
│ Constraint violation:                 8.4585e-09
│ Optimality complementarity residual:  1e-09
└ Feasibility complementarity residual: 8.454271e-06
┌ Infeasibility measure:                1.610706e-08
│ Optimality measure:                   50
└ Auxiliary measure:                    4.01609e-08
Primal solution:                        1.036611e-09 0.005779715 50
Constraint multipliers:                 -0.5 -0.5
Lower bound multipliers:                0 0 0
Upper bound multipliers:                0 0 0
Objective multiplier:                   1
CPU time:                               0.144922s
Iterations:                             32
Objective evaluations:                  33
Constraints evaluations:                34
Objective gradient evaluations:         34
Jacobian evaluations:                   34
Hessian evaluations:                    32
Number of subproblems solved:           32
memory_allocation_amount = 0

# Ipopt

(/home/traversaro/unows/env) traversaro@IITICUBLAP257:~/unows/Uno/build$ ipopt ../examples/polak5.nl

<...>
                                   (scaled)                 (unscaled)
Objective...............:   4.9999999991818186e+01    4.9999999991818186e+01
Dual infeasibility......:   8.4449709447653731e-09    8.4449709447653731e-09
Constraint violation....:   6.6267923873419930e-09    6.6267923873419930e-09
Variable bound violation:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   9.0909090909090941e-10    9.0909090909090941e-10
Overall NLP error.......:   8.4449709447653731e-09    8.4449709447653731e-09

Number of objective function evaluations             = 33
Number of objective gradient evaluations             = 33
Number of equality constraint evaluations            = 0
Number of inequality constraint evaluations          = 33
Number of equality constraint Jacobian evaluations   = 0
Number of inequality constraint Jacobian evaluations = 33
Number of Lagrangian Hessian evaluations             = 32
Total seconds in IPOPT                               = 0.025

EXIT: Optimal Solution Found.

Ipopt 3.14.12: Optimal Solution Found
cvanaret commented 1 year ago

Hi Silvio/@traversaro , Thanks for reporting the error. Of course, it should be not problem.has_inequality_constraints(). This was actually fixed in a subsequent commit (93cb0a2f0bbe7cf10e721254de487826ee1c5d28), so you just have to git pull. Best,

Charlie

traversaro commented 1 year ago

Thanks for the fast feedback @cvanaret !

This was actually fixed in a subsequent commit (93cb0a2), so you just have to git pull.

I am currently using the last commit (https://github.com/cvanaret/Uno/commit/e4a8fa7a21e9357c916d298b4f5cbb31a0f8d314), and I still see the problem.

I am not familiar with the codebase, but the commit you reference changed an assert in the PrimalDualInteriorPointSubproblem::solve method, while the assert I was referencing to is in the PrimalDualInteriorPointSubproblem::generate_initial_iterate method, and seems to be still there in the main branch: https://github.com/cvanaret/Uno/blob/main/uno/ingredients/subproblem/interior_point_methods/PrimalDualInteriorPointSubproblem.cpp#L46 .

cvanaret commented 1 year ago

Oh, thanks for catching that one. I overlooked the function name in your first message. It's now fixed in commit a1f89f7d77714126993fbd283bcfe312855f11d2.

traversaro commented 1 year ago

Thanks!