Topic
• No replies
1883 Posts

Pinned topic modelling question? how to write a closed form of a constraint

‏2013-01-25T09:32:56Z |
n=4
range city= (1..n);
range car=(1..2);
dvar int xcitycitycar in 0..1; // if car one traverse arc i to j it takes 1
dvar int+ ucitycitycar; // amount of product carrying car one

u[1][2][1]!=0 => x[1][2][1]=1 ||
x[1][3][1]+x[3][2][1]=2||
x[1][4][1]+x[4][2][1]=2||
x[1][3][1]+x[3][4][1]+x[4][2][1] =3||
x[1][4][1]+x[4][3][1]+x[3][2][1] =3;

u[1][2][2]!=0 => x[1][2][2]=1 ||
x[1][3][2]+x[3][2][2]=2||
x[1][4][2]+x[4][2][2]=2||
x[1][3][2]+x[3][4][2]+x[4][2][2] =3||
x[1][4][2]+x[4][3][2]+x[3][2][2] =3;

u[1][3][1]!=0 => x[1][3][1]=1 ||
x[1][2][1]+x[2][3][1]=2||
x[1][4][1]+x[4][3][1]=2||
x[1][2][1]+x[2][4][1]+x[4][2][1] =3||
x[1][4][1]+x[4][2][1]+x[2][3][1] =3;

u[1][3][2]!=0 => x[1][3][2]=1 ||
x[1][2][2]+x[2][3][2]=2||
x[1][4][2]+x[4][3][2]=2||
x[1][2][2]+x[2][4][2]+x[4][2][2] =3||
x[1][4][2]+x[4][2][2]+x[2][3][2] =3;

.
.
.

u[2][3][1]!=0 => x[2][3][1]=1 ||
x[2][4][1]+x[4][3][1]=2||
x[2][1][1]+x[1][3][1]=2|| // this is illegal because city 1 is depot.
x[2][1][1]+x[1][4][1]+x[4][3][1] =3|| // this is illegal because city 1 is depot.
x[2][4][1]+x[4][1][1]+x[1][3][1] =3; // this is illegal because city 1 is depot.

u[2][3][2]!=0 => x[2][3][2]=1 ||
x[2][4][2]+x[4][3][2]=2||
x[2][1][2]+x[1][3][2]=2|| // this is illegal because city 1 is depot.
x[2][1][2]+x[1][4][2]+x[4][3][2] =3|| // this is illegal because city 1 is depot.
x[2][4][2]+x[4][1][2]+x[1][3][2] =3; // this is illegal because city 1 is depot.

.
.
.

u[4][3][1]!=0 => x[4][3][1]=1 ||
x[4][2][1]+x[2][3][1]=2||
x[4][1][1]+x[1][3][1]=2|| // this is illegal because city 1 is depot.
x[4][2][1]+x[2][1][1]+x[1][3][1] =3|| // this is illegal because city 1 is depot.
x[4][1][1]+x[1][2][1]+x[2][3][1] =3; // this is illegal because city 1 is depot.

u[2][3][2]!=0 => x[2][3][2]=1 ||
x[2][4][2]+x[4][3][2]=2||
x[2][1][2]+x[1][3][2]=2|| // this is illegal because city 1 is depot.
x[2][1][2]+x[1][4][2]+x[4][3][2] =3|| // this is illegal because city 1 is depot.
x[2][4][2]+x[4][1][2]+x[1][3][2] =3; // this is illegal because city 1 is depot.

these are the constraint which i want to write in opl. for 4 city it is simple but even for 6 or 7 it is a lot :) so is there any one who can suggest me how to write in closed form. i mean =(using forall and sum).

PS: there is a order in constraints. for example " x[1][4][2]+x[4][2][2]+x[2][3][2]" means car two starts it tour from city 1 and goes to city 4 then goes to city 2 and finally city 3. these constraint make sure that : if there is a product which is transferred from city 1 to city 2 (u[1][2][2]!=0 =>) then one of the possible tours can only exist.