问题描述
OPL模型在代码框中。
我的问题涉及到icu病床的调度,我有一个MIQP(混合整数二次程序)公式。
目的是要消除重症监护病床的正负偏差,
以便平衡使用一张床。
例如,我们要避免在手术周期的前3天全部占用病床,而在接下来的2天中全部清空病床。
问题是Opl不会返回任何解决方案,而是告诉我
-obj没有值
-dneg没有值
-dpos无值
我不明白如何解决这个问题。
using CP;
int nspeciality=...; //Set of clinical specialties
int nor=...; //Set of surgery rooms
int ndays=...; //Set of days in surgery cycle
int npazients=...; // Set of patient types (non-ICU or ICU,I={0,1})
int nsurgerylengthtypes=...; // Set of surgery length types (short or long)
int ndaysinICUcycle =...; //Set of days in ICU cycle
int nweekend=...; //Set of days without surgery (i.e. Saturday,Sunday)
range speciality=0..nspeciality;
range OR=1..nor;
range days=0..ndays;
range pazients=0..npazients;
range surgerylengthtypes=0..nsurgerylengthtypes;
range daysinICUcycle=0..ndaysinICUcycle;
range weekend=0..nweekend;
;
int s[speciality][surgerylengthtypes]=...; //Surgery duration by specialty c and length type l
int w[OR]=...; // opening hours for each room r
int p[c in speciality][i in pazients][l in surgerylengthtypes]=2*rand(10); //Number of scheduled
surgeries in one surgery cycle by specialty c,patient type i,and length type l
int N=10000;
float randU[c in speciality][l in surgerylengthtypes][k in daysinICUcycle]=rand(N)/N; //Probability that a scheduled patient stays at least k days in the ICU after having surgery by specialty c and length type l
float b=8.99; //bed utilization target level
int v[speciality][OR]=...;
int j[OR][days]=...;
int m[c in speciality][r in OR][t in days]= v[c][r]*j[r][t]; //1 if specialty c is assigned to room r on day t; 0 otherwise
dvar int dneg[days]; //Negative deviation from bed utilization target level for day t
dvar int dpos[days]; //Positive deviation from bed utilization target level for day t
dvar int x[speciality][OR][days][pazients][surgerylengthtypes]; //Number of assigned surgeries by specialty c,room r,day t,length type l
int h[speciality]=...; //Maximum number of MSS blocks in one surgery cycle by specialty c
int g[speciality]=...; //Maximum number of daily MSS blocks by specialty c
float y=0.25; //Weight for positive and negative deviation from the bed utilization target level
dexpr float obj= sum(t in days) ((y*(dneg[t])^2) + (1-y)*(dpos[t])^2);
minimize obj;
subject to{
constraint_1:
forall (c in speciality:(c-4) in speciality,r in OR,t in days)
sum (i in pazients,l in surgerylengthtypes) s[c][l]*x[c][r][t][i][l]<= w[r]*m[c][t][r];
constraint_2:
forall(c in speciality,i in pazients,l in surgerylengthtypes)
sum(r in OR,t in days) x[c][r][t][i][l]==p[c][i][l];
constraint_3:
forall(t in days)
sum(c in speciality,k in daysinICUcycle,l in surgerylengthtypes) (randU[c][l][k]*x[c][r][t][1][l]+dneg[t]-dpos[t])==b;
constraint_4:
forall (c in speciality)
sum (t in days,r in OR) m[c][r][t]<=h[c];
constraint_5:
forall (c in speciality,t in days)
sum (r in OR) m[c][r][t]<=g[c];
constraint_6:
forall (t in weekend)
sum (c in speciality,r in OR) m[c][r][t]<=0;
constraint_7:
forall (t in days,r in OR)
sum (c in speciality) m[c][r][t]<=1;
constraint_8:
forall (t in days)
dneg[t]>=0;
constraint_9:
forall (t in days)
dpos[t]>=0;
constraint_10:
forall (c in speciality,t in days,l in surgerylengthtypes)
x[c][r][t][i][l]>0;
在我的文件.dat下面:
nspeciality=3;
nor=4;
ndays=6;
npazients=1;
nsurgerylengthtypes=1;
ndaysinICUcycle=27;
nweekend=1;
s=[[1,1],[0,[1,0],0]];
w=[10,8,15,9];
v=[[1,1,0]];
j=[[0,1]];
h=[15,18,9,20];
g=[7,2,10];
解决方法
如果在IDE中运行,则会在“冲突”选项卡中看到一些冲突。
然后,如果您评论冲突中提到的约束,则:
// constraint_6:
// forall (t in weekend)
// sum (c in speciality,r in OR) m[c][r][t]<=0;
// constraint_7:
// forall (t in days,r in OR)
// sum (c in speciality) m[c][r][t]<=1;
constraint_8:
forall (t in days)
dneg[t]>=0;
constraint_9:
forall (t in days)
dpos[t]>=0;
// constraint_10:
// forall (c in speciality,r in OR,t in days,i in pazients,l in surgerylengthtypes)
// x[c][r][t][i][l]>=1;
那么您将获得可行的解决方案
NB:
更改
x[c][r][t][i][l]>0;
到
x[c][r][t][i][l]>=1;
将使您的模型同时适用于MIP和CP。