Originally posted by: harshniu
Here is my code for the scheduling of n jobs on m machines. I am describing the problem just below the code.
//data
{int}total=...;
int m=...;
int n=...;
range job=0..n;
range mac=1..m;
//int h=m*n*(n+1);
int t;
tuple timeType{
int precedingjob;
int succeedingjob ;
int machine;
int time;}
timeType times
total=...;
//variables
dvar int+ c
job;
dvar int+ cmax;
dvar boolean x
jobjobmac;
//objective
minimize cmax;
//constraints
subject to {
forall(j in job)
onejobprecedesanother:
sum(i in 0..n, k in mac :i!=j)x[i][j][k] == 1;
forall(h in job, k in mac)
balanceconstraint:
sum(i in 0..n:i!=h)x[i][h][k] - sum(j in 0..n:j!=h )x[h][j][k] == 0;
forall(i in 0..n,j in 1..n,k in 1..m :t ==((((n+1)*j)+i-n)*(k-1)))
//p=((7*j)+i-6)*(k - 1);
jobcompletiontime: + **c[j]>=c[i]+sum(k in 1..m) x[i][j][k]*(times[t].time) + 10000*(sum(k in 1..m)x[i][j][k]-1);+
forall(k in mac)
firstjob :
sum(j in 0..n) x[0][j][k]==1;
timeatstart:
c[0]==0;
forall(j in job)
cmaxconstraint:
cmax>= c[j];}
As you can see I am using a tuple and I have linked my data file to and excel file to input the data. I have italicised the constraint which is giving the problem. The element(times[t].time)takes the first value from the excel sheet and does not follow the expression t ==((((n+1)*j)+i-n)*(k-1))). Thereby, multiplying the same vale say 116 * 5 for 5 job problem.
Please help me out or suggest a way to handle 3 dimensional arrays.
Thanks
#DecisionOptimization#OPLusingCPLEXOptimizer