Reputation: 9
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!
Upvotes: 0
Views: 161
Reputation: 5950
I can see two options to model the requests:
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.
Upvotes: 1