Skip to content

Commit

Permalink
Implement support for MOI.FeasibilitySense (#122)
Browse files Browse the repository at this point in the history
Closes #114
  • Loading branch information
mlubin authored Jun 24, 2018
1 parent bb9ffbb commit 91a893c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/MOIWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ function eval_objective(m::IpoptOptimizer, x)
elseif m.objective !== nothing
return eval_function(m.objective, x)
else
error("No objective function set!")
# No objective function set. This could happen with FeasibilitySense.
return 0.0
end
end

Expand Down Expand Up @@ -444,8 +445,6 @@ function eval_objective_gradient(m::IpoptOptimizer, grad, x)
MOI.eval_objective_gradient(m.nlp_data.evaluator, grad, x)
elseif m.objective !== nothing
fill_gradient!(grad, x, m.objective)
else
error("No objective function set!")
end
return
end
Expand Down Expand Up @@ -617,8 +616,10 @@ function MOI.optimize!(m::IpoptOptimizer)
objective_scale = 1.0
elseif m.sense == MOI.MaxSense
objective_scale = -1.0
else
error("FeasibilitySense not yet supported")
else # FeasibilitySense
# TODO: This could produce confusing solver output if a nonzero
# objective is set.
objective_scale = 0.0
end

eval_f_cb(x) = objective_scale*eval_objective(m, x)
Expand Down
1 change: 0 additions & 1 deletion test/MOIWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const config = MOIT.TestConfig(atol=1e-4, rtol=1e-4)
"linear12", # Same as above.
"linear8b", # Behavior in unbounded case doesn't match test.
"linear8c", # Same as above.
"linear13", # FeasibilitySense not supported yet.
"linear7", # VectorAffineFunction not supported.
]
linear_optimizer = MOI.Bridges.SplitInterval{Float64}(MOIU.CachingOptimizer(IpoptModelData{Float64}(), optimizer))
Expand Down

0 comments on commit 91a893c

Please sign in to comment.