Cplex:无法获取决策变量的值



我正在 Cplex 中解决医院工作人员调度问题,我是 Cplex 的新手。

但是 Cplex 无法配置决策变量的答案。

我想也许这与我的模型设计问题有关。

这是一个很长的模型。

如果我能得到帮助,非常感谢。

++模型

--集:

{string} E=...;//一组经验水平(高级、新秀(

{string} I=...;//所有医生的集合

{string} Is=...;//一组具有经验水平 S 的医生

{string} Ir=...;一组具有R级经验的医生

{string} K=...;//shift type of shifts (o & t(

{string} A1=...;//set of shift o work (day, night, night(

{string} A2=...;//班次 t 工作集(白天、晚上、晚上 1、晚上 2(

--参数

int D=...;

范围 日=1..D;//计划区间

范围int Co[Is]=...;//具有高级经验水平的医生的招聘成本

int Ct[Ir]=...;//具有新手经验水平的医生 i 的招聘成本

int Pku=...;//医生执行轮班的最长天数

oint Pkd=...;//医生执行轮班的最小天数

int Pkuh=...;医生执行轮班 T 的最长天数

int pkdh=...;医生执行轮班 T 的最短天数

int s=...;//最大连续工作日

int dosd=...;//shift o "高级"医生的日常工作需求

int dose=...;//shift o 晚间工作对"高级"医师的需求

int dosn=...;//shift o "高级"医生的夜间工作需求

int dord=...;//shift o "菜鸟"医生的日常工作需求

int dore=...;//shift o 晚间工作对"菜鸟"医生的需求

int dorn=...;//shift o "菜鸟"医生的夜间工作需求

int dtsd=...;//shift t "高级"医师的日常工作需求

int dtse=...;//shift t 晚间工作对"高级"医师的需求

int dtsn1=...;//shift t night1 "高级"医师的工作需求

int dtsn2=...;//shift t night2 "高级"医师的工作需求

int dtrd=...;//shift t "菜鸟"医生的日常工作需求

int dtre=...;//shift t 晚间工作对"菜鸟"医生的需求

int dtrn1=...;//shift t night1 "菜鸟"医生的工作需求

int dtrn2=...;//shift t night2 "菜鸟"医生的工作需求

--二进制十进制变量

dvar int x1[I][Day][A1] in 0..1;//1, 如果 senior+ shift o+ 工作之一

dvar int x2[I][Day][A2] in 0..1;//1, if senior+ shift t+ 工作之一

dvar int y1[I][Day][A1] in 0..1;//1, if rookie+ shift o+ 其中一项工作

dvar int y2[I][Day][A2] in 0..1;//1, if+ shift 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"};

Is={"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={"白天","晚上","晚上1","晚上2"};

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,650];Pku=10;

pkd=5;

Pkuh=8;

pkdh=4;

s=5;

您的模型可能不可行。如果您标记约束,则 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 

最新更新