0

I'm solving a hospital staff scheduling problem in Cplex. I'm new to cplex so really appreciate if I can

get any help!

Problem description: There is a set of doctors, working each day for "Day",

"Evening" and "Night" period.There are also typical scheduling constraints

like "no day period working after night working". My current critical problem

is: each doctor can request 3 days working period in my planning horizon (7

days). If the request is not met (eg. the doctor requested to have "Day"

working period on 1st day but was assign as "evening" period at that day),

the penalty cost will be triggered.

Goal is to minimize total cost.

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

{string} A=...; //set of working period (Day, evening, night)


int D=...; //planning horizon

range Day=1..D;

int Co[I]=...; //hiring cost for each doctor 

int p[I]=...; //penalty cost for each doctor

-Decision variable

dva int x[I][Day][A] in 0..1; //equals 1, if doctor i is working on Day d


dvar int z[I][Day][A] in 0..1; // equals 1, if the request of doctor i on Day d is not met.

-Expression of Decision Variables

dexpr int totalcost=sum(i in I, d in Day, a in A)*x[I][Day][A]
                   +sum(i in I, d in Day, a in A) p[I]*z[I][Day][A];

-Objective function

minimize totalcost;

**Problem: For doctor request, I think I should use method 1 suggested from

Daniel and add in doctor index, since each doctor can issue 3 requests. So

that means e.g. 1st to 3rd request refer to the same doctor?

     tuple doctorrequest {

     string doctor:

     int date;

     string period;

} 

doctorrequest Req[I]=...; //example of doctor request

--Data

I={"A","B","C"}; //set of doctors

A={"Day","Evening","Night"}; //set of working period

D=7; //planning horizon

p=[50,45,45];//penalty cost for each doctor

    Reqa=[<"A",1,"Day">,<"A",5,"Night">,<"A",7,"Evening>,

<"B",2,"Evening">,<"B",3,"Night">,<"B",5,"Night">,<"C",4,"Evening">,

<"C",5,"Evening">,<"C",6,"Night">];//requst from doctors 

**Problem: Constraint for penalty cost-->I'd like to write a constraint,

when doctor's request is not satisfied, the doctor's penalty cost will be

added into objective function. Have initial idea only.

if (x[i,d,a] in Req){

x [i,d,a]==0;}

else {

z[i,d,a]==1;

}

Appreciate for any help!

  • Hi, you could have a look at example nurses in CPLEX_Studio129\opl\examples\opl\nurses – Alex Fleischer Dec 09 '19 at 08:09
  • Thank you very much Alex. I've referred to the nurse example in Cplex. Got some ideas but still need some adjustment to fit into my model. Really appreciate! – Joanna Shih Dec 09 '19 at 23:27

1 Answers1

1

I can see two options to model the requests:

  1. Using tuples. In that case you should also add the doctor as field to the tuple. That way you can find back which request is for which doctor.
  2. If each doctor can have only one single request then you can just have parameters data and period that are indexed by doctors and give the preferred shift for each doctor.

If you go with the tuple-approach then you may want to check the documentation and tutorials for how tuples are initialized. Your initializer is wrong (and that probably is why CPLEX gives an error). The initialization of the tuple array should look something like this:

Reqa=[<1,"Day">,<2,"">,<3,"Evening"",<4,"Night">]

Finally, in your model I cannot see a decision variable that tells when a doctor actually works. Without such a variable you will not be able to tell whether a doctor's request was met or not.

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22
  • Hello Daniel, thank you very much for the reply. I've supplemented my model and problems. Really appreciate if you have time and willing to help further :) – Joanna Shih Dec 10 '19 at 20:57
  • The constraint to force `z` to 1 in case a doctor does not work on the requested date could look something like this: `forall (r in Reqa) z[r.doctor][r.date][r.period] >= 1 - x[r.doctor][r.date][r.period];`. – Daniel Junglas Dec 11 '19 at 15:10