0

Please help me write constraint in Cplex. I'm solving a staff scheduling problem.

I have following sets:

{string} I=...; // set of all physicians

{string} E=...; // set of experience levels

{string} K=...; //type of shifts

{string} A=...;//work type

int D=...;

range Day=1..D; //scheduling horizon is from day 1 to day 30

Data:

I={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T"};

E={"Senior","Rookie"};

K={"o","t"};

A={"Day","Evening","Night","Night1","Night2"};

Decision Variable:

dvar int x[I][E][Day][K][A] in 0..1; //1, if physician i with experience level e is assigned to day d with shift type k with work type a

Constraint: evening+night constraint

My main problem is, since I only need to focus on "Evening" and "Day" in set A, I don't know how to express it in Cplex.

forall(i in I, e in E, d in D, k in K, Evening in A, Day in A)
       {
       x [i, e, (d-1), k, Evening]+ x[i, e, d, k, Day]<=1;  
       }

Above is my trying but fail.

Thank you for the help!

1 Answers1

0

.mod

{string} I=...; // set of all physicians

{string} E=...; // set of experience levels

{string} K=...; //type of shifts

{string} A=...;//work type

int D=...;

range Day=1..D; //scheduling horizon is from day 1 to day 30

dvar int x[I][E][Day][K][A] in 0..1; //1, if physician i with experience level e is assigned to day d with shift type k with work type a



subject to
{
forall(i in I, e in E, d in Day, k in K, Evening in A:(d-1) in Day)
       {
       x [i, e, (d-1), k,"Evening"]+ x[i, e, d, k, "Day"]<=1;  
       }

     } 

.dat

I={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T"};

E={"Senior","Rookie"};

K={"o","t"};

A={"Day","Evening","Night","Night1","Night2"};

D=7;

work fine

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Thank you very much, the error is now gone. (But I face new problem regarding total model design and will create a new post). Really appreciate ! – Joanna Shih Nov 29 '19 at 14:42