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](https://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.modeler.py.html?highlight=logical#docplex.cp.modeler.if_then),
But it is not works; the results are still incorrect. For example wrong solution:
xtime_19: absent
but: z_19_1 = 1; z_19_2 = 0; z_19_3 = 0 => 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 => sum(z_19_1; z_19_2; z_19_3) = 0
I have try this example:
But it does not works and still give the wrong solution
Please help me, thanks
------------------------------
Son Nguyen Hoang
------------------------------