Hi Tobias
I have been able to find a solution to my problem, but I would appreciate to understand why my initial attempt at using your prescribed "conditional constraint" (if a=0 then b=1) does not work.
I've tried to use your suggestion to solve the following problem:
I have a sequence of binary variables (y_i), and I want their sum to be either of two values (v_1, v_2).
Using your suggestion I declared an integer variable a_1 and with a constraint a_1=sum(y_i)-v_1,
and a_2 with the constraint a_2=sum(y_i)-v_2.
From your "conditional constraint" I get b_1=1 when a_1=0, and b_2=1 when a_2=0.
I then use an or contraint b=or(b_1,b_2)
Finally I add a constraint that b==1
When implemented in my problem I started getting IIS problems.
I tested this in a simplified scenario:
integer var:x, lb=0, ub=4
b1=conditional_constraint(x==4)
b2=conditional_constraint(x==0)
b=or(b1,b2)
b==1
trying obj=x, maximize
I get x=4, b=1, b1=1, b2=0 as expected
trying obj=x, minimize
strangely enough i get the same result (x=4.....) and not x=0
when changing the first constraint to b1=conditional_constraint(x==2) I get x=2 (either for maximization or minimization).
What is wrong with this approach?
I ended up using the syntax addConstr(a=[v_1,v_2]) for the (not so well documented) range constraint which works as expected.
However this approach only works for numeric values, how would I implement a similar solution when I want to constraint the variable a to a set of combined numeric and variable values?
Thanks
Hanan
בתאריך יום שני, 13 ביוני 2016 בשעה 16:43:55 UTC+3, מאת Tobias Achterberg: