jump-dev / MathOptInterface.jl

A data structure for mathematical optimization problems
http://jump.dev/MathOptInterface.jl/
Other
392 stars 87 forks source link

[Bridges] error on set(_, ::ConstraintSet with variable and constraint bridges #2472

Closed odow closed 6 months ago

odow commented 6 months ago

Revisiting #2464 for another take at #2452.

This time it definitely fixes the original MWE:

(clarabel) pkg> st
Status `/private/tmp/clarabel/Project.toml`
  [61c947e1] Clarabel v0.7.1
  [4076af6c] JuMP v1.21.0
  [b8f27783] MathOptInterface v1.27.1 `~/.julia/dev/MathOptInterface`

julia> model = Model(Clarabel.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Clarabel

julia> set_silent(model)

julia> @variable(model, x >= 1)
x

julia> @constraint(model, c, 2x == 3)
c : 2 x = 3

julia> optimize!(model)

julia> y = value(x)
1.4999999999999996

julia> b = normalized_rhs(c)
3.0

julia> set_normalized_rhs(c, b)

julia> optimize!(model)

julia> value(x)
1.4999999999999996

https://github.com/jump-dev/MathOptInterface.jl/blob/009004c527d4bdcddc9db8f552c3048bb2e5e8fd/src/Bridges/Constraint/bridges/vectorize.jl#L221-L225 calls https://github.com/jump-dev/MathOptInterface.jl/blob/009004c527d4bdcddc9db8f552c3048bb2e5e8fd/src/Bridges/bridge_optimizer.jl#L2044-L2050 which calls https://github.com/jump-dev/MathOptInterface.jl/blob/009004c527d4bdcddc9db8f552c3048bb2e5e8fd/src/Bridges/bridge_optimizer.jl#L1992-L2003 but the issue is that we can't tell whether we're modifying from the user's perspective, or whether we're modifying the inner constraint.

I'm guessing we need some call_in_context, but I got confused, so I decided it's simpler just to punt for now and fix the correctness issue.

odow commented 6 months ago

https://github.com/jump-dev/MathOptInterface.jl/actions/runs/8610208951

odow commented 6 months ago

All ticks green