Skip to content

Commit 063b5d2

Browse files
committed
Update NLPModelsIpopt.jl for Ipopt.jl v1.9
1 parent 01495d5 commit 063b5d2

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
88
SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843"
99

1010
[compat]
11-
Ipopt = "0.9, 1"
11+
Ipopt = "1.9"
1212
NLPModels = "0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21"
1313
SolverCore = "0.3"
1414
julia = "^1.6"

src/NLPModelsIpopt.jl

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ const ipopt_statuses = Dict(
2727
-199 => :exception, # Internal error
2828
)
2929

30+
const ipopt_internal_statuses = Dict(
31+
0 => :Solve_Succeeded,
32+
1 => :Solved_To_Acceptable_Level,
33+
2 => :Infeasible_Problem_Detected,
34+
3 => :Search_Direction_Becomes_Too_Small,
35+
4 => :Diverging_Iterates,
36+
5 => :User_Requested_Stop,
37+
6 => :Feasible_Point_Found,
38+
-1 => :Maximum_Iterations_Exceeded,
39+
-2 => :Restoration_Failed,
40+
-3 => :Error_In_Step_Computation,
41+
-4 => :Maximum_CpuTime_Exceeded,
42+
-5 => :Maximum_WallTime_Exceeded,
43+
-10 => :Not_Enough_Degrees_Of_Freedom,
44+
-11 => :Invalid_Problem_Definition,
45+
-12 => :Invalid_Option,
46+
-13 => :Invalid_Number_Detected,
47+
-100 => :Unrecoverable_Exception,
48+
-101 => :NonIpopt_Exception_Thrown,
49+
-102 => :Insufficient_Memory,
50+
-199 => :Internal_Error,
51+
)
52+
3053
"""
3154
IpoptSolver(nlp; kwargs...,)
3255
@@ -132,7 +155,7 @@ For advanced usage, first define a `IpoptSolver` to preallocate the memory used
132155
* `zL`: a vector of size `nlp.meta.nvar` to specify initial multipliers for the lower bound constraints
133156
* `zU`: a vector of size `nlp.meta.nvar` to specify initial multipliers for the upper bound constraints
134157
135-
All other keyword arguments will be passed to IpOpt as an option.
158+
All other keyword arguments will be passed to Ipopt as an option.
136159
See [https://coin-or.github.io/Ipopt/OPTIONS.html](https://coin-or.github.io/Ipopt/OPTIONS.html) for the list of options accepted.
137160
138161
# Output
@@ -247,7 +270,7 @@ function SolverCore.solve!(
247270
if has_bounds(nlp)
248271
set_bounds_multipliers!(stats, problem.mult_x_L, problem.mult_x_U)
249272
end
250-
set_solver_specific!(stats, :internal_msg, Ipopt._STATUS_CODES[status])
273+
set_solver_specific!(stats, :internal_msg, ipopt_internal_statuses[status])
251274
set_solver_specific!(stats, :real_time, real_time)
252275

253276
try

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ end
5858
nlp = ADNLPModel(x -> (x[1] - 1)^2 + 100 * (x[2] - x[1]^2)^2, [-1.2; 1.0])
5959
stats = ipopt(nlp, tol = 1e-12, callback = callback, print_level = 0)
6060
@test stats.status == :user
61-
@test first(stats.solver_specific[:internal_msg]) == :User_Requested_Stop
61+
@test stats.solver_specific[:internal_msg] == :User_Requested_Stop
6262
@test stats.iter == 1
6363
@test stats.elapsed_time > 0
6464
@test stats.primal_feas 0.0

0 commit comments

Comments
 (0)