I am defining a decision variable in Gurobi as follows:
x = model.addVar(vtype=GRB.INTEGER, lb=0, ub=24)
However, instead of putting a lower and upper bound, I want the domain of the variable to be limited to only [0, 4, 8, 12, 16, 20, 24]
. Since I know these are the only possible values my variable can take.
Can I limit the domain to the above specific set, rather than a general lower and upper bound.
Not sure if we can directly define integer variables over a specific discrete set of values. However, one can add binary variables, and a couple of constraints to restrict the values that an integer variable can take: