Skip to content

Commit bf2a8b9

Browse files
authored
[Bridges] Throw in Constraint.SlackBridge if scalar constant is nonzero (#2382)
1 parent 8662e97 commit bf2a8b9

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

src/Bridges/Constraint/bridges/slack.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ function bridge_constraint(
222222
f::MOI.AbstractScalarFunction,
223223
s::S,
224224
) where {T,F,S}
225+
MOI.throw_if_scalar_and_constant_not_zero(f, typeof(s))
225226
slack, slack_in_set = MOI.add_constrained_variable(model, s)
226227
new_f = MOI.Utilities.operate(-, T, f, slack)
227228
equality = MOI.add_constraint(model, new_f, MOI.EqualTo(zero(T)))

test/Bridges/lazy_bridge_optimizer.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,6 @@ function test_MOI_runtests_StandardSDPAModel()
323323
# sets of the same type are added.
324324
"test_model_LowerBoundAlreadySet",
325325
"test_model_UpperBoundAlreadySet",
326-
# MOI.ScalarFunctionConstantNotZero is thrown, not of the original
327-
# constraint, but of the bridged constraint. This seems okay. The
328-
# fix would require that a bridge optimizer has a try-catch for this
329-
# error.
330-
"test_model_ScalarFunctionConstantNotZero",
331326
],
332327
)
333328
return

0 commit comments

Comments
 (0)