SCIP.jl icon indicating copy to clipboard operation
SCIP.jl copied to clipboard

VectorOfVariable with indicator does not detect binary variable

Open matbesancon opened this issue 4 years ago • 4 comments

From https://github.com/jump-dev/JuMP.jl/issues/2167

When copying the indicator constraint, the binary is sometimes not already set (comes from copy_to not being ordered).

MWE from JuMP:

using JuMP
import SCIP
using LinearAlgebra: ⋅

m = Model(with_optimizer(SCIP.Optimizer))
nl = 10

@variable(m, v[1:nl])
@variable(m, s[j=1:nl])
@variable(m, z[j=1:nl], Bin)

@assert all(JuMP.is_binary, z)

@constraint(m,
    indicator_ones[j=1:nl],
    [z[j], v[j]] in MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE}(MOI.LessThan(0.0))
)
optimize!(m)

Tricky to reproduce without it because it is tied to each copying implementation

matbesancon avatar Mar 31 '21 08:03 matbesancon

SCIP should set z[j] to binary when adding an indicator constraint, and then potentially error on optimize! if the user has not explicitly set z to be binary.

odow avatar Mar 31 '21 23:03 odow

not sure I follow, if we set z[j] to binary, how do you check that the user has done it themselves? Does the optimizer have to keep another copy? Or do you set binary with the SCIP lower-level API directly in the first phase?

matbesancon avatar Apr 01 '21 07:04 matbesancon

Yes, I think we would have to have to keep a copy of the explicit user-defined variable type/constraint.

This is already done partially, see MOI_wrapper.jl, but I don't remember the exact use case for that.

A similar case is that of second-order cone constraints. In SCIP, it's asserted that y is non-negative for a constraint of the form sqrt(sum x_i^2) <= y. Here, there's also the choice of "fixing" the bound for the user, or error to tell the user to do it themselves.

Maybe the friendliest way is to "fix" the bounds and variable types to meet SCIP expectations, but send warnings. This requires additional storage of variable information.

rschwarz avatar Apr 01 '21 07:04 rschwarz

I can't seem to reproduce the incident anymore, neither with JuMP nor MOI directly. It is very likely still there but makes it tricky to test

matbesancon avatar Oct 06 '21 14:10 matbesancon