-
Notifications
You must be signed in to change notification settings - Fork 92
Description
See discussion in #1992, and these tests:
MathOptInterface.jl/test/Bridges/bridge_optimizer.jl
Lines 898 to 933 in d9c998a
function test_Issue1992_supports_ConstraintDualStart_VariableIndex() | |
# supports should be false | |
model = MOI.Bridges.full_bridge_optimizer(_Issue1992(false), Float64) | |
x, _ = MOI.add_constrained_variables(model, MOI.Nonpositives(1)) | |
c = MOI.add_constraint(model, MOI.VectorOfVariables(x), MOI.Nonnegatives(1)) | |
@test !MOI.supports(model, MOI.ConstraintDualStart(), typeof(c)) | |
# supports should be true | |
model = MOI.Bridges.full_bridge_optimizer(_Issue1992(true), Float64) | |
x, _ = MOI.add_constrained_variables(model, MOI.Nonpositives(1)) | |
c = MOI.add_constraint(model, MOI.VectorOfVariables(x), MOI.Nonnegatives(1)) | |
# !!! warning | |
# This test is broken with a false negative. See the discussion in | |
# PR#1992. | |
@test_broken MOI.supports(model, MOI.ConstraintDualStart(), typeof(c)) | |
return | |
end | |
function test_bridge_supports_issue_1992() | |
inner = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()) | |
model = MOI.Bridges.Variable.NonposToNonneg{Float64}(inner) | |
x = MOI.add_variable(model) | |
c = MOI.add_constraint( | |
model, | |
MOI.VectorOfVariables([x]), | |
MOI.Nonpositives(1), | |
) | |
# !!! warning | |
# This test is broken with a false negative. (Getting and setting the | |
# attribute works, even though supports is false) See the discussion in | |
# PR#1992. | |
@test_broken MOI.supports(model, MOI.ConstraintDualStart(), typeof(c)) | |
@test MOI.get(model, MOI.ConstraintDualStart(), c) === nothing | |
MOI.set(model, MOI.ConstraintDualStart(), c, [1.0]) | |
@test MOI.get(model, MOI.ConstraintDualStart(), c) == [1.0] | |
return | |
end |
The issue is that the bridge/model may support an attribute for a variable-in-set constraint if it was added via add_constrained_variable(s)
but not via add_constraint
(or vice versa). However, we have no way of telling which way the constraint was added based on the type alone.
We can either default to &&
, in which case we may return a false negative (the model supports the attribute but supports
returns false
) or ||
, in which case we may return a false positive (the model supports the attribute for one of the ways, but we added it the other way). It's not obvious which is better, but our tests are passing with the current implementation, so we should wait for a solver to complain before reconsidering.