Yoom
Yoom

Reputation: 27

3-dimension Parameter in Cplex

I've got a model that I need to calculate the capacity of rooms (i) divided by the number of students in a student group (m). I use this value in my object function. I'm not sure how to code this parameter though. Do I use "execute"? Also, the parameter H_jkl is used to show the instructor l's mood during the time period (j k) (H = 1 "happy", = 2 "okay", = 3 "sonst"). There are five days, and each day has four time slots. That means there are twenty time periods in a week. So, I think H_jkl is a range of [timeperiod] and [1..d] (set of instructors). But this can't show the index (j k). I think I need to use this "int timeperiod [1..b, 1..c] = [j: [k: (k + (j-1)*4)] | j in 1..b, k in 1..c]" to connect timeperiod and (j k), but I think it is wrong. The object function is: minimize c_im * H_jkl * x_ijklmn

//Parameter
int a = ...; // Set of rooms // Index i                
int b = ...; // Set of days  // Index j              
int c = ...; // set of timeslots  // Index k
int d = ...; // set of instructors // Index l         
int e = ...; // set of student groups // Index m  
int f = ...; // set of courses // Index n

int capacity [1..a] = ...; // Capacity of rooms
int number [1..e] = ...; // number of students in student group
/* c [i][m] = capacity [i] / number [m]

range timeperiod = 1..20;
int H [timeperiod][1..d] = ...; // Instructors Preference

/*
int timeperiod [1..b, 1..c] = [j: [k: (k + (j-1)*4)] | j in 1..b, k in 1..c];
*/


dvar boolean x [1..a][1..b][1..c][1..d][1..e][1..f];


Could you please help me out with this. Thanks for advance!

Upvotes: 0

Views: 49

Answers (1)

user24898807
user24898807

Reputation: 1

Regarding the computation of c[i][m], it’s not necessary to use an "execute". You can write directly: float cc[i in 1..a][m in 1..e] = capacity[i]/number[m]; Note: you cannot use c because you already used c as an integer (int c = ... ;)

Regarding the time period, I think the easiest way is to use your definitions: range timeperiod = 1..b*c; int H[timeperiod][1..d] = ...;

You need to update the declaration of your decision variables x: dvar boolean x [1..a][1..b*c][1..d][1..e][1..f];

Finally, your objective can be written as follows: minimize sum(i in 1..a, m in 1..e, tp in 1..b*c, l in 1..d, n in 1..f) cc[i][m]*H[tp][l]*x[i][tp][l][m][n];

Regards,

Upvotes: 0

Related Questions