我正在解决Cplex中的医院员工日程安排问题,并且对Cplex还是陌生的。
但是Cplex无法配置决策变量的答案。
我认为可能与我的模型设计问题有关。
这是一个长模型。
非常感谢能得到帮助。
++模型
-设置:
{string} E = ...; //一组经验级别(高级,菜鸟)
{string} I = ...; //所有医生的集合
{string} Is = ...; //经验为S级的医师
{string} Ir = ...; //经验等级为R的医师组
{string} K = ...; //班次类型(o&t)
{string} A1 = ...; //设置班次(白天,晚上,晚上)
{string} A2 = ...; //一组轮班工作(白天,晚上,晚上1,晚上2)
-参数
int D = ...;
范围日= 1..D; //计划范围范围
int Co [Is] = ...; //具有资深经验的医师i的聘用费用
int Ct [Ir] = ...; //具有新手经验水平的医师i的聘用成本
int Pku = ...; //最大。医师进行轮班工作的天数
int Pkd = ...; //分钟医师进行轮班工作的天数
int Pkuh = ...; //最大值医师进行轮班的天数
int Pkdh = ...; //分钟。医师进行轮班的天数
int s = ...; //最大。连续工作日
int dosd = ...; //转变对“高级”医师的日常工作需求
int剂量= ...; //转变对“高级”医师的夜间工作需求
int dosn = ...; //轮换“高级”医师的夜间工作需求
int dord = ...; //轮换“菜鸟”医师的日常工作需求
int dore = ...; //转移对“菜鸟”医师的夜间工作需求
int dorn = ...; //对“菜鸟”医师的夜间工作需求
int dtsd = ...; //转变对“高级”医师的日常工作需求
int dtse = ...; //转变对“高级”医师的夜间工作需求
int dtsn1 = ...; // shift t night1对“高级”医师的工作需求
int dtsn2 = ...; //转变“ tnight2”对“高级”医师的工作需求
int dtrd = ...; //转移“菜鸟”医师的日常工作需求
int dtre = ...; //转移“菜鸟”医师的夜间工作需求
int dtrn1 = ...; //转变t night1对“菜鸟”医师的工作需求
int dtrn2 = ...; //改变“新秀”医师的工作需求
-二进制决策变量
dvar int x1 [I] [Day] [A1] in 0..1; // 1,如果老年人+将o +移至其中一项工作
dvar int x2 [I] [Day] [A2] in 0..1; // 1,如果前辈+转移t +其中一项工作
dvar int y1 [I] [Day] [A1] in 0..1; // 1,如果菜鸟+将o +移至其中一项
dvar int y2 [I] [Day] [A2] in 0..1; // 1,如果菜鸟+将t +移至其中一项
-决策变量的表达
dexpr float cost =sum(i in Is, d in Day, a in A1)Co[i]*x1[i][d][a]
+ sum(i in Is, d in Day, a in A2)Co[i]*x2[i][d][a]
+ sum(i in Ir, d in Day, a in A1)Ct[i]*y1[i][d][a]
+ sum(i in Ir, d in Day, a in A2)Ct[i]*y2[i][d][a] ;
-目标函数
最小化成本;
-约束
subject to
{
forall(d in Day, Day in A1)
{
sum(i in Is) x1[i, d ,"Day"] == dosd; //Daily demand:Senior+shift o+day work
}
forall(d in Day, Evening in A1)
{
sum(i in Is ) x1[i, d, "Evening"] == dose; //Daily demand:Senior+shift o+evening work
}
forall(d in Day, Night in A1)
{
sum(i in Is ) x1[i, d, "Night"] == dosn; //Daily demand:Senior+shift o+night work
}
forall(d in Day, Day in A2)
{
sum(i in Is) x2[i, d, "Day"] == dtsd; //Daily demand:Senior+ shift t +day work
}
forall(d in Day, Evening in A2)
{
sum(i in Is) x2[i, d, "Evening"] == dtse; //Daily demand:Senior+shift t+evening work
}
forall(d in Day, Night1 in A2)
{
sum(i in Is) x2[i, d, "Night1"] == dtsn1; //Daily demand:Senior+shift t+night1 work
}
forall(d in Day, Night2 in A2)
{
sum(i in Is) x2[i, d, "Night2"] == dtsn2; //Daily demand:Senior+shift t+night2 work
}
forall(d in Day, Day in A1)
{
sum(i in Ir) y1[i, d, "Day"] == dord; //Daily demand:Rookie+shift o+day work
}
forall(d in Day, Evening in A1)
{
sum(i in Ir) y1[i, d, "Evening"] == dore; //Daily demand:Rookie+shift o+evening work
}
forall(d in Day, Night in A1)
{
sum(i in Ir) y1[i, d, "Night"] == dorn; //Daily demand:Rookie+shift o+night work
}
forall(d in Day, Day in A2)
{
sum(i in Ir) y2[i, d, "Day"] == dtrd; //Daily demand:Rookie+shift t+day work
}
forall(d in Day, Evening in A2)
{
sum(i in Ir) y2[i, d, "Evening"] == dtre; //Daily demand:Rookie+shift t+evening work
}
forall(d in Day, Night1 in A2)
{
sum(i in Ir) y2[i, d, "Night1"] == dtrn1; //Daily demand:Rookier+shift t+night1 work
}
forall(d in Day, Night2 in A2)
{
sum(i in Ir) y2[i, d, "Night2"] == dtrn2; //Daily demand:Rookie+shift t+night2 work
}
forall(i in Is, d in Day:d<D, Evening in A1)
{
x1[i, d, "Evening"]+ x1[i,(d+1), "Day"]<=1; //(Senior)For shift type o,if previous day is evening
work, can't have day work the following day'
}
forall(i in Is, d in Day:d<D, Evening in A2)
{
x2[i, d, "Evening"]+ x2[i,(d+1), "Day"]<=1; //(Senior)For shift type t,if previous day is evening
work, can't have day work the following day'
}
forall(i in Ir, d in Day:d<D, Evening in A1)
{
y1[i, d, "Evening"]+ y1[i,(d+1), "Day"]<=1; //(Rookie)For shift type o,if previous day is evening
work, can't have day work the following day'
}
forall(i in Ir, d in Day:d<D, Evening in A2)
{
y2[i, d, "Evening"]+ y2[i,(d+1), "Day"]<=1; //(Rookie)For shift type t,if previous day is evening
work, can't have day work the following day'
}
forall(i in Is, d in Day:d<D, Night in A1)
{
x1[i, d,"Night"]+ x1[i,(d+1),"Day"]<=1; //(Senior)For shift type o,if previous day is night work,
can't have day work the following day'
}
forall(i in Is, d in Day:d<D, Night1 in A2)
{
x2[i, d,"Night1"]+ x2[i,(d+1),"Day"]<=1; //(Senior)For shift type t,if previous day is night1 work,
can't have day work the following day'
}
forall(i in Is, d in Day:d<D, Night2 in A2)
{
x2[i, d,"Night2"]+ x2[i,(d+1),"Day"]<=1; //(Senior)For shift type t,if previous day is night2 work,
can't have day work the following day'
}
forall(i in Ir, d in Day:d<D, Night in A1)
{
y1[i, d,"Night"]+ y1[i,(d+1),"Day"]<=1; //(Rookie)For shift type o,if previous day is night work,
can't have day work the following day'
}
forall(i in Ir, d in Day:d<D, Night1 in A2)
{
y2[i, d,"Night1"]+ y2[i,(d+1),"Day"]<=1; //(Rookie)For shift type t,if previous day is night1 work,
can't have day work the following day'
}
forall(i in Ir, d in Day:d<D, Night2 in A2)
{
y2[i, d,"Night2"]+ y2[i,(d+1),"Day"]<=1; //(Rookie)For shift type t,if previous day is night2 work,
can't have day work the following day'
}
forall (i in Is, d in Day)
{
sum(a in A1)x1[i,d,a] + sum(a in A2)x2[i,d,a] <=1; //(Senior)each day can only have one work with
one shift
}
forall (i in Ir, d in Day)
{
sum(a in A1)y1[i,d,a] + sum(a in A2)y2[i,d,a] <=1; //(Rookie)each day can only have one work with
one shift
}
forall(i in Is, a in A1)
{
sum(d in Day)x1[i,d,a] <=Pku; //(Senior) can’t have shift type o that more than upper bound. (in
days)
}
forall(i in Ir, a in A1)
{
sum(d in Day)y1[i,d,a] <=Pku; //(Rookie) can’t have shift type o that more than upper bound. (in
days)
}
forall(i in Is, a in A1)
{
sum(d in Day)x1[i,d,a]>=Pkd; //(Senior) can’t have shift type o that less than lower bound. (in
days)
}
forall(i in Ir, a in A1)
{
sum(d in Day)y1[i,d,a]>=Pkd; //(Rookie) can’t have shift type o that less than lower bound. (in
days)
}
forall(i in Is, a in A2)
{
sum(d in Day)x2[i,d,a]<=Pkuh; //(Senior) can’t have shift type t that more than upper bound. (in
days)
}
forall(i in Ir, a in A2)
{
sum(d in Day)y2[i,d,a]<=Pkuh; //(Rookie) can’t have shift type t that more than upper bound. (in
days)
}
forall(i in Is, a in A2)
{
sum(d in Day)x2[i,d,a]>=Pkdh; //(Senior) can’t have shift type t that less than lower bound. (in
days)
}
forall(i in Ir, a in A2)
{
sum(d in Day)y2[i,d,a]>=Pkdh; //(Rookie) can’t have shift type t that less than lower bound. (in
days)
}
forall(i in Is)
{
sum(d in Day:d<=(D-s), a in A1)x1[i,d,a]+sum(d in Day:d<=(D-s), a in A2)x2[i,d,a]<=s; //(Senior)
can’t have consecutive working days (regardless of shift type) that more than upper bound. (in days)
}
forall(i in Ir)
{
sum(d in Day:d<=(D-s), a in A1)y1[i,d,a]+sum(d in Day:d<=(D-s), a in A2)y2[i,d,a]<=s; //(Rookie)
can’t have consecutive working days (regardless of shift type) that more than upper bound. (in days)
}
++数据
E = {“高级”,“菜鸟”};
I = {“ A”,“ B”,“ C”,“ D”,“ E”,“ F”,“ G”,“ H”,“ I”,“ J”,“ K”, “ L”,“ M”,“ N”,“ O”,“ P”,“ Q”,“ R”,“ S”,“ T”,“ W”,“ X”,“ Y”,“ Z” “};
是= {“ A”,“ B”,“ C”,“ D”,“ E”,“ F”,“ G”,“ H”};
Ir = {“ I”,“ J”,“ K”,“ L”,“ M”,“ N”,“ O”,“ P”,“ Q”,“ R”,“ S”, “ T”,“ W”,“ X”,“ Y”,“ Z”};
K = {“ o”,“ t”};
A1 = {“白天”,“晚上”,“夜晚”};
A2 = {“白天”,“晚上”,“ Night1”,“ Night2”};
D = 7;
Co = [1200,1150,1100,1050,1000,950,900,850];
Ct = [800,750,750,750,700,700,700,700,700,700,650,650,650,650,650,650,650];
Pku = 10;
Pkd = 5;
Pkuh = 8;
Pkdh = 4;
s = 5;
答案 0 :(得分:1)
您的模型可能不可行。如果标记了约束,那么CPLEX将为您提供一些放松和冲突,这将帮助您理解原因。我的建议是标记所有约束。
例如,您可以更改
forall(d in Day, Day in A1)
{
sum(i in Is) x1[i, d ,"Day"] == dosd; //Daily demand:Senior+shift o+day work
}
进入
forall(d in Day, Day in A1)
ct1:sum(i in Is) x1[i, d ,"Day"] == dosd; //Daily demand:Senior+shift o+day work