Hi,
Could you please tell me how I can model the following in CP optimizer?
W is the array of variables.
n is a constant value
for each 1<=p<=n1
if W[p]=0 then [all wj]s must be equal to 0 for (p+1<=j<=n)
I know that I can easily present the constraint as follows:
for (p = 1; p < n; i++)
{
for (j = p; p <= n; j++)
model.add(IloIfThen(env, W[p] == 0, W[j] == 0));
}
but to have a stronger propagation I wanna present the "Then" conditional section using consecutive logical and expressions as follows:
model.add(IloIfThen(env, W[p] == 0, (Wp+1 == 0)&&(Wp+2 == 0)&&(Wp+3 == 0)&& .... (W[n] == 0)));
Topic
This topic has been locked.
2 replies
Latest Post
 20130405T07:59:05Z by ol
ACCEPTED ANSWER
Pinned topic Consecutive logical and constraints
20130403T22:23:17Z

Answered question
This question has been answered.
Unanswered question
This question has not been answered yet.
Updated on 20130405T07:59:05Z at 20130405T07:59:05Z by ol

ACCEPTED ANSWER
Re: Consecutive logical and constraints
20130404T20:27:56Z in response to SystemAdminNo body has any idea how to present the following constraint?
model.add(IloIfThen(env, W[p] == 0, (Wp+1 == 0)&&(Wp+2 == 0)&&(Wp+3 == 0)&& .... (W[n] == 0))); 
ACCEPTED ANSWER
Re: Consecutive logical and constraints
20130405T07:59:05Z in response to SystemAdminHello,
you cannot have a stronger propagation, both formulations give the best possible propagation.
Nevertheless you can use only O(n) instead of O(n*n) constraints, for example:
for (p = 1; p < n1; i++) model.add(IloIfThen(env, W[p] == 0, W[p+1] == 0)); }
Regards,
Olivier