oxfordcontrol / Clarabel.jl

Clarabel.jl: Interior-point solver for convex conic optimisation problems in Julia.
Apache License 2.0
174 stars 16 forks source link

Model becomes infeasible after setting constraint RHS to identical value #160

Closed mtanneau closed 8 months ago

mtanneau commented 8 months ago

cc @odow because I don't know whether the underlying issue is in JuMP or in Clarabel. This was initially reported by @klamike.

In certain circumstances (which I have not been able to fully isolate beyond the example below), setting the RHS of some constraints, then re-optimizing, yields an infeasible model. I have not been able to make a smaller example than the code below, which calls set_normalized_rhs to reset the right-hand-side of all equality constraints to the same value as in the initial model (thus presumably not changing anything)

using PowerModelsAnnex, PGLib, JuMP, Clarabel, HiGHS
const PMA = PowerModelsAnnex
const PM = PMA.PowerModels

data = PM.make_basic_network(pglib("14_ieee"))
model = PMA.build_dc_opf(data)
set_silent(model)
set_optimizer(model, Clarabel.Optimizer)  # Changing this to `HiGHS.Optimizer` removes any issue
optimize!(model)  # commenting this line will remove the INFEASIBLE issue below
@show termination_status(model)

# The code below resets the RHS of all equality constraints to the same value as before.
# --> this should not change anything to the model
cons = all_constraints(model, AffExpr, MOI.EqualTo{Float64})
b = normalized_rhs.(cons)
set_normalized_rhs.(cons, b)

# set_optimizer(model, Clarabel.Optimizer)  # re-setting the optimizer also gets rid of the infeasibility
# Re-optimize the model --> this should return `OPTIMAL` with the same objective value
optimize!(model)
@show termination_status(model)  # ⚠⚠⚠ this is INFEASIBLE unless either
                                 # 1) we don't optimize in the first run, or
                                 # 2) we call `set_optimizer(model, Clarabel.Optimizer)` before the second `optimize!`
As far as I can tell, the following sequences yield the following results: sequence termination status (1) termination status (2)
build/ optimize! / set_normalized_rhs / optimize! OPTIMAL INFEASIBLE
build/ (do not optimize) / set_normalized_rhs / optimize! OPTIMIZE_NOT_CALLED OPTIMAL
build/ optimize! / set_optimizer / set_normalized_rhs / optimize! OPTIMAL OPTIMAL

Also note that the issue goes away when using HiGHS instead of Clarabel.


Further comments, hopefully helpful when debugging:

odow commented 8 months ago

This is a bug in MOI getting the right-hand side with variable bridges: https://github.com/jump-dev/MathOptInterface.jl/issues/2452

I have a minimal reproducer, so this issue can be closed.

goulart-paul commented 8 months ago

Thanks @odow. I will close here for now, but please reopen (or make a new issue) if this turns out to be something on our end.

mtanneau commented 8 months ago

Thanks!

odow commented 7 months ago

This will be fixed in the upcoming MOI v1.27.2.

It took a while to find the proper fix. The bug was non-trivial!