In working the integration of SCIP (1.17.1) with CPMpy (CPMpy/cpmpy#412), I found that in the docs, it says indicator constraints have to be <=, but it seems >= does also work.
from pyscipopt import Model
m = Model()
m.hideOutput()
x = m.addVar(vtype="I", lb=0, ub=10, name="x")
b = m.addVar(vtype="B", name="b")
# This works despite docs saying only "<=" is accepted
m.addConsIndicator(x >= 5, binvar=b)
m.addCons(b == 1)
m.setObjective(x, sense="minimize")
m.optimize()
print(f"Status: {m.getStatus()}")
print(f"x = {m.getVal(x)}")
print(f"b = {m.getVal(b)}")
assert m.getStatus() == "optimal"
assert m.getVal(x) == 5
# Output:
# Status: optimal
# x = 5.0
# b = 1.0
# All assertions passed
Cheers,
Hendrik 'Henk' Bierlee
In working the integration of SCIP (1.17.1) with CPMpy (CPMpy/cpmpy#412), I found that in the docs, it says indicator constraints have to be
<=, but it seems>=does also work.Cheers,
Hendrik 'Henk' Bierlee