Constraint Problem

Problems with modeling
Post Reply
Emine
User
User
Posts: 5
Joined: 6 years ago

Constraint Problem

Post by Emine »

Hello guys,
I need your help.

My project is on booklet optimization for exams, it is a timetabling problem.

Here my sets, variables, equ. and obj. :

SETS

o sessions /1*4/

k booklets /1*31/

i courses / course1 * coursen/

s students/student1*studentm/;

VARIABLES
x(i,k) if course i assing to booklet k
z(i,o) if course i assing to session o
y(k,o) if booklet k assing to session o
q(k) if booklet k created
a obj;

BINARY VARIABLES
x(i,k)
z(i,o)
y(k,o)
q(k);

PARAMETER NCs(s) -it is a parameter that gives number of courses for every student
TABLE P(s,i) student- course matrix(0-1 matrix)

EQUATIONS
obj obj. function
cons2 a booklet has to include max. 6 courses
cons21 a booklet has to include min. 4 courses
cons3 a course must be assigned to only one session
cons4 a booklet must be assigned to only one session
cons5 all courses must be assigned and they can be assigned to more than one booklets as long as being one session
cons6 a student must be assigned max 5 lessons in one session
cons9 correlation cons. with y(ko) and q(k)
cons91 correlation cons. with y(ko) and q(k)
cons12 correlation cons. with x(ik) and q(k)
cons13 correlation cons. with x(ik) and q(k)
cons15 equality that counts the courses of students for every student and session ;

obj.. a =e= sum(k,q(k));
cons2(k).. sum(i, x(i,k)) =l=6;
cons21(k).. sum(i, x(i,k)) =g=4;
cons3(i).. sum(o, z(i,o)) =e= 1;
cons4(k).. sum(o, y(k,o)) =e= 1;
cons5(i).. sum(k, x(i,k)) =g= 1;
cons6(s,o)..sum(i, P(s,i)*z(i,o))=l= 5;
cons15(s)..NCs(s) =e= sum ((i,o),P(s,i)* z(i,o)) ;
cons9(k)..sum(o, y(k,o)) =l= M* q(k);
cons91(k)..sum(o, y(k,o)) =g= q(k);
cons12(k)..sum((i), x(i,k)) =g= q(k) ;
cons13(k)..sum((i), x(i,k)) =l= M* q(k);

MODEL oturum /all/;
SOLVE oturum using mip minimizing a;


I choosed CPLEX as solver, i reached optimal solution for 31 booklets but my problem is the session of z(i,o) and y(k,o) is not the same.
For example, math is assigned to booklet 1, x11=1 (i1=math and k1=booklet1).
But booklet1's session is 2, while math's session is 3.
I want that when x11 is equal to 1 (i1=math and k1=booklet1), z11 is equal to y11 or z12 is equal to y12 or z13 is equal to y13 or z14 is equal to y14.

I tried lot of things, but didn't work, i will be really appriciated, if you help.
Thank you!

Emine.
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: Constraint Problem

Post by cladelpino »

I didn't understand well... but,
I want that when x11 is equal to 1 (i1=math and k1=booklet1), z11 is equal to y11 or z12 is equal to y12 or z13 is equal to y13 or z14 is equal to y14.
What about something like ? Uses an auxiliary variable w(i,k,o)

z(i,o)-y(k,o) =l= ( 1- w(i,k,o) ) for all o
z(i,o)-y(k,o) =g= - (1- w(i,k,o) ) for all o

And :

sum(o,w(i,k,o))=e=x(i,k)

or

sum(o,w(i,k,o))=g=x(i,k)

(Depending on the reverse implications you want... i e is what you stated as "or" really an "OR" or a "XOR")

Perhaps its useful to get you going.

Good luck
Claudio
Emine
User
User
Posts: 5
Joined: 6 years ago

Re: Constraint Problem

Post by Emine »

Thank you very much for the reply Claudio,
Your suggestion worked, i didn't use auxiliary variable like w(i,k,o),
i just changed it like below:

z(i,o)-y(k,o))=l= 1-(x(i,k)) for all i,o,k
z(i,o)-y(k,o)=g= -(1-(x(i,k))) for all i,o,k

Have a nice day,

Emine
Post Reply