Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Apr 9, 2024

Conversation

odow
Copy link
Member

@odow odow commented Apr 9, 2024

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

MOI.modify(
model,
bridge.vector_constraint,
MOI.VectorConstantChange([-bridge.set_constant]),
)

calls
function MOI.modify(
b::AbstractBridgeOptimizer,
ci::MOI.ConstraintIndex,
change::MOI.AbstractFunctionModification,
)
if is_bridged(b, change)
modify_bridged_change(b, ci, change)

which calls
function modify_bridged_change(
b::AbstractBridgeOptimizer,
ci_or_obj,
change::Union{MOI.ScalarConstantChange,MOI.VectorConstantChange},
)
bridged_func = _bridged_function(b, ci_or_obj)
unbridged_func = _unbridged_function(b, ci_or_obj)
bridged_const =
MOI.constant(bridged_func) + change.new_constant -
MOI.constant(unbridged_func)
bridged_change = _constant_change(bridged_const)
_modify_bridged_function(b, ci_or_obj, bridged_change)

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
Copy link
Member Author

odow commented Apr 9, 2024

@odow
Copy link
Member Author

odow commented Apr 9, 2024

All ticks green

@odow odow merged commit 362544d into master Apr 9, 2024
14 checks passed
@odow odow deleted the od/2452-reprise branch April 9, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants