Originally posted by: NguyenHuuTRi
Hello,
I am a beginner of CPLEX optimizer. Actually, I have to revise my model and switch it to CP in stead of MIP. Below is my model. I appreciate it if you could help me how to revise my model in CP way.
Thanks.
using CP;
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 course_type{
int idcourse;
int idtype;
};
setof (course_type) coursetypes = ...;
dvar boolean assCourseTimes[course][timeslot];
dvar boolean assGroupTimes[group][timeslot];
dvar int compactGroup[group][1..6];
maximize sum (c in course, t in timeslot) assCourseTimes[c][t];
minimize sum(g in group, t in 1..6)compactGroup[g][t];
subject to {
forall (t in timeslot,c in course ) {
assign_CourseinTimeslot: assCourseTimes[c][t] <= sum(l in lecture) (lecturetime[l][t]*courselecture[c][l]);
}
forall (c in course){
OneCourseinTime: sum(t in timeslot)assCourseTimes[c][t] <= 1;
}
forall (t in timeslot, ty in type){
capa_room: sum(<c,ty> in coursetypes) assCourseTimes[c][t] <= caparoom[ty];
}
forall (t in timeslot, g in group){
assign_GroupTimes: sum(c in course) assCourseTimes[c][t]*coursegroup[c][g] == assGroupTimes[g][t];
}
forall (t in timeslot: t<7, g in group){
abs(assGroupTimes[g][t] - assGroupTimes[g][t+6])* 2 <=
compactGroup[g][t];
forall (t in timeslot: t>6, g in group){
abs(assGroupTimes[g][t] - 1) <= compactGroup[g][t-6];
};
#DecisionOptimization#OPLusingCPOptimizer