is there a way using "logical or  " between each constraint which are constructed by forall stament. for example:
x[1]=1 
x[2]=1 
x[3]=1 
x[4]=1 
how can i write these logical constraints by using forall?
forall(i in 1..4)x[i]==1 doesn't works...
Topic
This topic has been locked.
3 replies
Latest Post
 20130127T11:02:23Z by SystemAdmin
ACCEPTED ANSWER
Pinned topic using "logical or  " between each constraint
20130111T15:19:51Z

Answered question
This question has been answered.
Unanswered question
This question has not been answered yet.
Updated on 20130127T11:02:23Z at 20130127T11:02:23Z by SystemAdmin

ACCEPTED ANSWER
Re: using "logical or  " between each constraint
20130114T09:56:29Z in response to SystemAdminYou could use the sum operator to do specify that the sum of variables x in 1..4 that have value 1 should be at least one:
sum(i in 1..4) (x[i] == 1) >= 1
Since (x[i] == 1) is a boolean variable in 0..1 (0 meaning false, and 1 meaning true), this sum has an equivalent semantic to the disjunction of your example.
Regards,
StefanoUpdated on 20140326T05:51:18Z at 20140326T05:51:18Z by ironman
ACCEPTED ANSWER
Re: using "logical or  " between each constraint
20130116T13:31:02Z in response to SystemAdminIf you are in a CP context, it is valid to write
using CP; ... or(i in 1..4) x[i]==1
And using CPLEX as the engine, the formulation of the previous post is valid. Note that if your variables are boolean, you have a native linear simplification :
sum(i in 1..4) x[i] >=1
DavidUpdated on 20140326T05:51:13Z at 20140326T05:51:13Z by ironman
ACCEPTED ANSWER
Re: using "logical or  " between each constraint
20130127T11:02:23Z in response to davidoffif i change the constraints like:
x[1][3][1]+x[3][2][1]=2
x[1][4][1]+x[4][2][1]=2
x[1][3][2]+x[3][2][2]=2
x[1][4][2]+x[4][2][2]=2
.
.
.
how can i make these logical constraints in closed form?

