Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Bridges/Constraint/bridges/SplitIntervalBridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ function MOI.modify(
if bridge.upper !== nothing
MOI.modify(model, bridge.upper, change)
end
if bridge.lower === bridge.upper === nothing
bridge.func = MOI.Utilities.modify_function(bridge.func, change)
end
return
end

Expand All @@ -369,6 +372,9 @@ function MOI.set(
if bridge.upper !== nothing
MOI.set(model, MOI.ConstraintFunction(), bridge.upper, func)
end
if bridge.lower === bridge.upper === nothing
bridge.func = func
end
return
end

Expand Down
12 changes: 12 additions & 0 deletions test/Bridges/Constraint/test_SplitIntervalBridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,18 @@ function test_modify_set()
return
end

function test_split_interval_free_modify()
inner = MOI.Utilities.Model{Float64}()
model = MOI.Bridges.Constraint.SplitInterval{Float64}(inner)
x, y = MOI.add_variable(model), MOI.add_variable(model)
ci = MOI.add_constraint(model, 1.0 * x, MOI.Interval(-Inf, Inf))
MOI.modify(model, ci, MOI.ScalarCoefficientChange(y, 2.0))
@test ≈(MOI.get(model, MOI.ConstraintFunction(), ci), 1.0 * x + 2.0 * y)
MOI.set(model, MOI.ConstraintFunction(), ci, 3.0 * x + 4.0 * y)
@test ≈(MOI.get(model, MOI.ConstraintFunction(), ci), 3.0 * x + 4.0 * y)
return
end

end # module

TestConstraintSplitInterval.runtests()
Loading