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<=n-1
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)));
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
2 replies Latest Post - 2013-04-05T07:59:05Z by ol
Pinned topic Consecutive logical and constraints
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-04-05T07:59:05Z at 2013-04-05T07:59:05Z by ol
SystemAdmin 110000D4XK554 Posts
ol 270002SRX756 PostsACCEPTED ANSWER
Re: Consecutive logical and constraints2013-04-05T07: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 < n-1; i++) model.add(IloIfThen(env, W[p] == 0, W[p+1] == 0)); }