Originally posted by: **Kylie gp**

Hello everyone. I am a new for using IBM ilog cplex and I have a lot of wondering about that.

**My objective output from cplex is to know that who worker works in which workstation with which machine in which period and day.**

That shows I have 5 indexes these are i = workers, j = workstaions, m = machines, k = periods and l = days.

**I wonder that can I use 2 boolean decision variables which are X[i][j][k][l] and Y[m][j][k][l] or using a boolean decision variable with 5 indexes which is W[i][j][m][k][l] for solving this problems ?? ****I defined X will be 1 if worker (i) works in workstaion (j) in period (k) in day (l) and Y will be 1 if machine (m) works in workstaion (j) in period (k) in day (l).**

I have a .mod model is (I am not sure it's correct but It can run the output)

int Nbmachines =...;

int Nbworkers =...;

int Nbworkstations =...;

int Nbperiods =...;

int Nbdays =...;

int hazard =...;

range machines = 1..Nbmachines;

range workers = 1..Nbworkers;

range workstations = 1..Nbworkstations;

range periods = 1..Nbperiods;

range days = 1..Nbdays;

float h [workstations] =...;

float N [workstations] =...; Worker required per workstations

float B [workers][workstations] =...;

float A [machines][workstations] =...;

float M [workstations] =...; //Machine required

float P [machines] =...; // Power of machines

float PM [workstations] =...; //Power required

//3 dimentions variable read from excel t[j][k][l]

int t1[1..Nbworkstations*Nbperiods*Nbdays] =...;

int tArray[j in 1..Nbworkstations, k in 1..Nbperiods,l in 1..Nbdays] = t1[l+Nbdays*(k-1)+Nbperiods*Nbdays*(j-1)];

execute {

writeln(tArray);

};

//Decision Variables

dvar boolean X[workers][workstations][periods][days];

dvar boolean Y[machines][workstations][periods][days];

dvar boolean y[workers];

dvar boolean z[machines];

//Objective function

dexpr float Objective = sum(i in workers) y[i];

minimize Objective;

//Contraints

subject to {

//[OK] 1. limited hazard of the day for worker

forall(i in workers)

sum(j in workstations,k in periods,l in days) h[j]*X[i][j][k][l] <= hazard

//[OK] 2. Every workstations need to assign workers as worker required per workstations.

forall(j in workstations, k in periods, l in days)

sum(i in workers) X[i][j][k][l]== N[j]*t1[l+Nbdays*(k-1)+Nbperiods*Nbdays*(j-1)];

//[OK] 3. A workstation needs One worker per one period and one day.

forall(i in workers, k in periods, l in days)

sum(j in workstations) X[i][j][k][l] <= 1;

//[OK] 4. Workers [i] are chosen from who be able to work in workstation j.

forall(i in workers,j in workstations, k in periods, l in days)

X[i][j][k][l] <= B[i][j];

//[OK] 5. Workers [i] are chosen from all we have 30 workers.

forall(i in workers,j in workstations, k in periods, l in days)

X[i][j][k][l] <= y[i];

//**[HELP] **6. machines [m] are chosen from all we have 56 machiens.

forall(m in machines, j in workstations, k in periods, l in days)

Y[m][j][k][l] <= z[m];

**I've got problem with 6. because the output does not show machines are chosen as I define 1 if they are chosen and 0 if other. I attached output of z[m] below.

//[OK] 7. A workstation needs one machines per one period and one day.

forall(m in machines, k in periods, l in days)

sum(j in workstations) Y[m][j][k][l] <= 1;

//[OK] 8. Every workstations need to assign machines as machines required per workstations.

forall(j in workstations, k in periods, l in days)

sum(m in machines) Y[m][j][k][l]== M[j] * t1[l+Nbdays*(k-1)+Nbperiods*Nbdays*(j-1)];

//[OK] 9. Every workstations need to assign machines that power of machines as power required per workstations.

forall(m in machines, k in periods, l in days)

sum(j in workstations) Y[m][j][k][l] * PR[j] <= P[m];

//[OK] 10. Machines [m] are chosen from which be able to work in workstation j.

forall(m in machines, k in periods, l in days,j in workstations)

Y[m][j][k][l] <= A[m][j];

}

And my .dat file, It connected data with Excel.

Questions

1. I want to know how to read output easily, maybe write the outputs to .txt file but I don't know how to use "lloOplOutplutFile" in cplex (Ofile) Could you all please give me some advice?

2. I want to define that "workstation j=1 have to work along with workstation j=2 in same machine.", "workstation j=3 have to work along with workstation j=4 in same machine.", ... untill "workstation j=11 have to work along with workstation j=12 in same machine." How can I write ontraint in program??

Thank you so much everyone.

Kylie gp

#DecisionOptimization#OPLusingCPLEXOptimizer