Skip to content

Commit

Permalink
[Bridges] Throw in Constraint.SlackBridge if scalar constant is nonze…
Browse files Browse the repository at this point in the history
…ro (#2382)
  • Loading branch information
blegat authored Jan 2, 2024
1 parent 8662e97 commit bf2a8b9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
1 change: 1 addition & 0 deletions src/Bridges/Constraint/bridges/slack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ function bridge_constraint(
f::MOI.AbstractScalarFunction,
s::S,
) where {T,F,S}
MOI.throw_if_scalar_and_constant_not_zero(f, typeof(s))
slack, slack_in_set = MOI.add_constrained_variable(model, s)
new_f = MOI.Utilities.operate(-, T, f, slack)
equality = MOI.add_constraint(model, new_f, MOI.EqualTo(zero(T)))
Expand Down
5 changes: 0 additions & 5 deletions test/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,6 @@ function test_MOI_runtests_StandardSDPAModel()
# sets of the same type are added.
"test_model_LowerBoundAlreadySet",
"test_model_UpperBoundAlreadySet",
# MOI.ScalarFunctionConstantNotZero is thrown, not of the original
# constraint, but of the bridged constraint. This seems okay. The
# fix would require that a bridge optimizer has a try-catch for this
# error.
"test_model_ScalarFunctionConstantNotZero",
],
)
return
Expand Down

0 comments on commit bf2a8b9

Please sign in to comment.