Skip to content

Commit

Permalink
[Bridges] Throw in Constraint.SlackBridge if scalar constant is nonzero
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 30, 2023
1 parent 8662e97 commit 2b7d5be
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))

Check warning on line 225 in src/Bridges/Constraint/bridges/slack.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/Constraint/bridges/slack.jl#L225

Added line #L225 was not covered by tests
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 2b7d5be

Please sign in to comment.