I want to use the sum of two binary decision variables (when their sum equals to one) as the condition of Model.AddGenConstrIndicator https://www.gurobi.com/documentation/current/refman/py_model_agc_indicator.html, however, it seems to be impossible, e.g. for the minimal code below which reflects the relevant part of my real problem trying the following:
import gurobipy as gp
model = gp.Model()
x = model.addVar(vtype=gp.GRB.BINARY, name="x")
y = model.addVar(vtype=gp.GRB.BINARY, name="y")
z = model.addVar(vtype=gp.GRB.CONTINUOUS, name="z")
model.update()
constr = model.addConstr((x + y == 1) >> (z <= 20))
model.setObjective(z, gp.GRB.MAXIMIZE)
# Solve the model
model.optimize()
Will result in the following error:
constr = model.addConstr((x + y == 1) >> (z <= 20))
File "src/gurobipy/model.pxi", line 3632, in gurobipy.Model.addConstr
gurobipy.GurobiError: Indicator constraints can only be triggered by a single binary variable at a given value
Is there a workaround for this?