Skip to content

Commit

Permalink
Merge b482b29 into 870f037
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Aug 16, 2018
2 parents 870f037 + b482b29 commit 804bc75
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/MOIWrapper.jl
Expand Up @@ -674,6 +674,14 @@ function MOI.optimize!(m::IpoptOptimizer)
length(hessian_sparsity),
eval_f_cb, eval_g_cb, eval_grad_f_cb, eval_jac_g_cb,
eval_h_cb)

# Ipopt crashes by default if NaN/Inf values are returned from the
# evaluation callbacks. This option tells Ipopt to explicitly check for them
# and return Invalid_Number_Detected instead. This setting may result in a
# minor performance loss and can be overwritten by specifying
# check_derivatives_for_naninf="no".
addOption(m.inner, "check_derivatives_for_naninf", "yes")

if !has_hessian
addOption(m.inner, "hessian_approximation", "limited-memory")
end
Expand Down Expand Up @@ -731,6 +739,8 @@ function MOI.get(m::IpoptOptimizer, ::MOI.TerminationStatus)
return MOI.InvalidModel
elseif status == :Invalid_Problem_Definition
return MOI.InvalidModel
elseif status == :Invalid_Number_Detected
return MOI.InvalidModel
elseif status == :Unrecoverable_Exception
return MOI.OtherError
elseif status == :NonIpopt_Exception_Thrown
Expand Down
13 changes: 10 additions & 3 deletions src/MPBWrapper.jl
Expand Up @@ -94,10 +94,17 @@ function MPB.loadproblem!(m::IpoptMathProgModel, numVar::Integer, numConstr::Int


m.inner = createProblem(numVar, float(x_l), float(x_u), numConstr,
float(g_lb), float(g_ub), length(Ijac), length(Ihess),
eval_f_cb, eval_g_cb, eval_grad_f_cb, eval_jac_g_cb,
eval_h_cb)
float(g_lb), float(g_ub), length(Ijac), length(Ihess),
eval_f_cb, eval_g_cb, eval_grad_f_cb, eval_jac_g_cb,
eval_h_cb)
m.inner.sense = sense

# Ipopt crashes by default if NaN/Inf values are returned from the
# evaluation callbacks. This option tells Ipopt to explicitly check for them
# and return Invalid_Number_Detected instead. This setting may result in a
# minor performance loss and can be overwritten by specifying
# check_derivatives_for_naninf="no".
addOption(m.inner, "check_derivatives_for_naninf", "yes")
if !has_hessian
addOption(m.inner, "hessian_approximation", "limited-memory")
end
Expand Down

0 comments on commit 804bc75

Please sign in to comment.