Cplex:模型制定和编程方法

Cplex: model formulation and programming method

我正在解决 Cplex 中的医院工作人员调度问题。我是 cplex 的新手,如果可以的话,我将不胜感激

寻求帮助!

问题描述:有一组医生,每天工作"Day",

"Evening"和"Night"period.There也是典型的调度约束

喜欢"no day period working after night working"。我目前的严重问题

是:每个医生在我的计划范围内可以要求3天的工作时间(7

天)。如果不满足要求(例如医生要求 "Day"

第 1 天的工作时段,但在当天被分配为 "evening" 个时段),

惩罚费用将被触发。

目标是最小化总成本。

{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;

**问题:对于医生的要求,我想我应该使用

建议的方法1

Daniel 并添加医生索引,因为每个医生可以发出 3 个请求。所以

这意味着例如第一到第三个请求指的是同一个医生?

     tuple doctorrequest {

     string doctor:

     int date;

     string period;

} 

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

--数据

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 

**问题:惩罚成本的约束-->我想写一个约束,

当医生的要求不被满足时,医生的惩罚费用为

添加到 objective 函数中。只有初步想法。

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

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

else {

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

}

感谢您的帮助!

我可以看到两个对请求建模的选项:

  1. 使用元组。在这种情况下,您还应该将医生作为字段添加到元组中。这样你就可以查到哪个请求是给哪个医生的。
  2. 如果每个医生只能有一个请求,那么您可以只使用由医生索引的参数 dataperiod,并为每个医生提供首选班次。

如果您使用元组方法,那么您可能需要查看有关如何初始化元组的文档和教程。您的初始化程序错误(这可能是 CPLEX 出错的原因)。元组数组的初始化应如下所示:

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

最后,在你的模型中,我看不到一个决定医生实际工作时间的决策变量。如果没有这样的变量,您将无法判断是否满足了医生的要求。