diff --git a/Project.toml b/Project.toml index 5973ff0..6d3ad6e 100644 --- a/Project.toml +++ b/Project.toml @@ -8,7 +8,7 @@ NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6" SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843" [compat] -Ipopt = "0.9, 1" +Ipopt = "1" NLPModels = "0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21" SolverCore = "0.3" julia = "^1.6" diff --git a/src/NLPModelsIpopt.jl b/src/NLPModelsIpopt.jl index 79c7e77..d79b096 100644 --- a/src/NLPModelsIpopt.jl +++ b/src/NLPModelsIpopt.jl @@ -27,6 +27,29 @@ const ipopt_statuses = Dict( -199 => :exception, # Internal error ) +const ipopt_internal_statuses = Dict( + 0 => :Solve_Succeeded, + 1 => :Solved_To_Acceptable_Level, + 2 => :Infeasible_Problem_Detected, + 3 => :Search_Direction_Becomes_Too_Small, + 4 => :Diverging_Iterates, + 5 => :User_Requested_Stop, + 6 => :Feasible_Point_Found, + -1 => :Maximum_Iterations_Exceeded, + -2 => :Restoration_Failed, + -3 => :Error_In_Step_Computation, + -4 => :Maximum_CpuTime_Exceeded, + -5 => :Maximum_WallTime_Exceeded, + -10 => :Not_Enough_Degrees_Of_Freedom, + -11 => :Invalid_Problem_Definition, + -12 => :Invalid_Option, + -13 => :Invalid_Number_Detected, + -100 => :Unrecoverable_Exception, + -101 => :NonIpopt_Exception_Thrown, + -102 => :Insufficient_Memory, + -199 => :Internal_Error, +) + """ IpoptSolver(nlp; kwargs...,) @@ -132,7 +155,7 @@ For advanced usage, first define a `IpoptSolver` to preallocate the memory used * `zL`: a vector of size `nlp.meta.nvar` to specify initial multipliers for the lower bound constraints * `zU`: a vector of size `nlp.meta.nvar` to specify initial multipliers for the upper bound constraints -All other keyword arguments will be passed to IpOpt as an option. +All other keyword arguments will be passed to Ipopt as an option. See [https://coin-or.github.io/Ipopt/OPTIONS.html](https://coin-or.github.io/Ipopt/OPTIONS.html) for the list of options accepted. # Output @@ -247,7 +270,7 @@ function SolverCore.solve!( if has_bounds(nlp) set_bounds_multipliers!(stats, problem.mult_x_L, problem.mult_x_U) end - set_solver_specific!(stats, :internal_msg, Ipopt._STATUS_CODES[status]) + set_solver_specific!(stats, :internal_msg, ipopt_internal_statuses[status]) set_solver_specific!(stats, :real_time, real_time) try diff --git a/test/runtests.jl b/test/runtests.jl index 211e8f7..943bf7b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -58,7 +58,7 @@ end nlp = ADNLPModel(x -> (x[1] - 1)^2 + 100 * (x[2] - x[1]^2)^2, [-1.2; 1.0]) stats = ipopt(nlp, tol = 1e-12, callback = callback, print_level = 0) @test stats.status == :user - @test first(stats.solver_specific[:internal_msg]) == :User_Requested_Stop + @test stats.solver_specific[:internal_msg] == :User_Requested_Stop @test stats.iter == 1 @test stats.elapsed_time > 0 @test stats.primal_feas ≈ 0.0