Originally posted by: NguyenHuuTRi
Hi,
I do not know why anytime I use the below constraint my model can not return the result.
forall (t in timeslot: t<7, g in group){
(z[g][t]!= z[g][t+6]) => y[g][t]== 2;
(z[g][t] == z[g][t+6])&&(z[g][t]==0) => y[g][t] == 1;
(z[g][t] == z[g][t+6])&&(z[g][t]==1) => y[g][t] == 0;
};
I am getting stucked with my model. Could you please help me resolve this issue.
Thanks.,
range type = 1..14;
range course = 1..518;
range room = 1..150;
range lecture = 1..353;
range timeslot = 1..12;
range group=1..252;
int lecturetime[lecture][timeslot] = ...;
int courselecture[course][lecture]=...;
int caparoom[type]= ...;
int coursegroup[course][group]=...;
tuple lecture_time {
int lecture;
int time;
};
setof (lecture_time) LectureTimes =
{<l,t> | l in lecture,t in timeslot : lecturetime[l][t]==1};
tuple course_lecture {
int course;
int lecture;
};
setof (course_lecture) CourseLectures =
{<c,l> | c in course, l in lecture : courselecture[c][l]==1};
tuple course_type{
int idcourse;
int idtype;
};
setof (course_type) coursetypes = ...;
tuple course_group {
int idcourse;
int idgroup;
};
setof (course_group) CourseGroups = {<c,g> | c in course, g in group: coursegroup[c][g]==1};
tuple lecture_course_time {
int lecture;
int course;
int type;
int time;
}
setof (lecture_course_time) LectureCourseTimes =
{<l,c,ty,t> | <c,l> in CourseLectures, <l,t> in LectureTimes , <c,ty> in coursetypes};
dvar boolean x[LectureCourseTimes];
dvar boolean z[group][timeslot];
dvar boolean y[group][timeslot];
//dexpr int o1=sum (w in LectureCourseTimes) x[w];
//dexpr int o2=sum(t in timeslot:t<7, g in group) y[g][t];
//maximize staticLex(o1,o2);
maximize sum (w in LectureCourseTimes) x[w];
//minimize sum(t in timeslot:t<7, g in group) y[g][t];
subject to
{
forall (<l,t> in LectureTimes) {
assignLecture : sum(<l,c,ty,t> in LectureCourseTimes) x[<l,c,ty,t>] <=1;
};
forall (c in course) {
asignCourse: sum(<l,c,ty,t> in LectureCourseTimes) x[<l,c,ty,t>]<= 1 ;
};
forall (t in timeslot, ty in type) {
asignCapaRoomType: sum(<l,c,ty,t> in LectureCourseTimes) x[<l,c,ty,t>]<= caparoom[ty];
};
forall(t in timeslot, g in group){
sum(<l,c,ty,t> in LectureCourseTimes)x[<l,c,ty,t>]*coursegroup[c][g]==z[g][t];
};
/*
forall (t in timeslot: t<7, g in group){
(z[g][t]!= z[g][t+6]) => y[g][t]== 2;
(z[g][t] == z[g][t+6])&&(z[g][t]==0) => y[g][t] == 1;
(z[g][t] == z[g][t+6])&&(z[g][t]==1) => y[g][t] == 0;
};
*/
forall(t in timeslot, g in group){
sum(<l,c,ty,t> in LectureCourseTimes)x[<l,c,ty,t>]*coursegroup[c][g]<=1;
};
};
#DecisionOptimization#OPLusingCPLEXOptimizer