Originally posted by: NguyenHuuTRi
Hi,
I am trying to code the syntax for multi-citeria objective as below. However, it said that my syntax is incorrect. Could you please help check for me the syntax as I have used the syntax from truckfleet model.
Thanks.
range type = 1..2;
range course = 1..4;
range room = 1..2;
range lecture = 1..2;
range timeslot = 1..12;
range group=1..3;
int lecturetimea[lecture][timeslot] = ...;
int courselecturea[course][lecture]=...;
int courserooma[course][room]=...;
int caparooma[type]= ...;
//int capa_cg[group]=...;
int coursegroupa[course][group]=...;
tuple lecture_time {
int lecture;
int time;
};
setof (lecture_time) LectureTimes =
{<l,t> | l in lecture,t in timeslot : lecturetimea[l][t]==1};
tuple course_room {
int course;
int room;
};
setof (course_room) CourseRooms =
{<c,r> | c in course,r in room : courserooma[c][r]==1};
tuple course_lecture {
int course;
int lecture;
};
setof (course_lecture) CourseLectures =
{<c,l> | c in course, l in lecture : courselecturea[c][l]==1};
tuple course_type{
int idcourse;
int idtype;
};
setof (course_type) coursetypesa = ...;
tuple course_group {
int idcourse;
int idgroup;
};
setof (course_group) CourseGroups = {<c,g> | c in course, g in group: coursegroupa[c][g]==1};
tuple lecture_course_time {
int lecture;
int course;
int type;
int time;
int room;
}
setof (lecture_course_time) LectureCourseTimes =
{<l,c,ty,t,r> | <c,l> in CourseLectures, <l,t> in LectureTimes , <c,ty> in coursetypesa, <c,r> in CourseRooms};
dvar boolean x[LectureCourseTimes];
dvar int y[group][timeslot];
dvar boolean z[group][timeslot];
dexpr int e1=sum (w in LectureCourseTimes) x[w];
dexpr int e2=sum(t in timeslot:t<7, g in group) y[g][t];
Maximize staticLex(e1,e2);
subject to
{
//forall (g in group){
//sum(t in timeslot)cs[g][t]==capa_cg[g];
//}
forall (<l,t> in LectureTimes) {
assignLecture : sum(<l,c,ty,t,r> in LectureCourseTimes) x[<l,c,ty,t,r>] <=1;
};
forall (c in course) {
asignCourse: sum(<l,c,ty,t,r> in LectureCourseTimes) x[<l,c,ty,t,r>] <= 1 ;
};
forall (r in room, t in timeslot){
assignRoom: sum(<l,c,ty,t,r> in LectureCourseTimes)x[<l,c,ty,t,r>]<=1;
};
forall (t in timeslot, ty in type) {
asignCapaRoomType: sum(<l,c,ty,t,r> in LectureCourseTimes) x[<l,c,ty,t,r>]<= caparooma[ty];
};
forall(t in timeslot, g in group){
sum(<l,c,ty,t,r> in LectureCourseTimes)x[<l,c,ty,t,r>]*coursegroupa[c][g]==z[g][t];
};
forall(t in timeslot, g in group){
sum(<l,c,ty,t,r> in LectureCourseTimes)x[<l,c,ty,t,r>]*coursegroupa[c][g]<=1;
};
/*
forall ( t in timeslot:t<7, g in group){
z[g][t]- z[g][(t+6)] == y[g][t];
};
*/
//forall (t in timeslot:t<7, g in group){
//z[g][t]- z[g][(t+6)] != 0;
//};
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;
#DecisionOptimization#OPLusingCPLEXOptimizer