I am building a bidding VRP model using constraint programming with DOCPLEX. In this model, I have the following constraint:
IF {presentOf(xtime[k]) == 0}, THEN {sum(b in B)z[k][b] == 0 – forall k in KN}
and
IF {sum(b in B)z[k][b] == 0} – forall k in KN, THEN {presentOf(xtime[k]) == 0}
This is my code
for k in KN:
model.add(model.if_then(sum(z[k -NberExistConstract- 1][b-1] for b in B) == 0, model.presence_of(xtime[k-NberExistConstract-1])==0))
model.add(model.if_then(model.presence_of(xtime[k-NberExistConstract-1])==0, sum(z[k -NberExistConstract- 1][b-1] for b in B) == 0))
I have tried using if_then as shown in the link, but it is not effective; the results are incorrect. For example wrong solution:
xtime_19: absent
but: z_19_1 = 1; z_19_2 = 0; z_19_3 = 0 and sum(z_19_1; z_19_2; z_19_3) = 1.
It should be:
xtime_19: absent
but: z_19_1 = 0; z_19_2 = 0; z_19_3 = 0 and sum(z_19_1; z_19_2; z_19_3) = 0.
This is full code: https://drive.google.com/drive/folders/1-Fnk0QkBV5_PF1EsPNA6VZSz4XDd37Ir?usp=drive_link
Please help me, thanks
I have try this example
1/ https://github.com/AlexFleischerParis/zoodocplex/blob/master/zooifthen.py
2/ https://github.com/AlexFleischerParis/zoodocplex/blob/master/zooifthen2.py
3/ https://github.com/AlexFleischerParis/zoodocplex/blob/master/zooifthenwithstaticcondition.py
But it does not works and still give the wrong solution