AMPL中的护士调度模型公式

时间:2015-11-13 08:09:58

标签: job-scheduling ampl operations-research

在以下情况下,我一直在研究AMPL中的护士调度问题:

总数没有。护士= 20

总数没有。 shits = 3#morning,day,night

规划地平线7天:让我们说M T W R F Sa Su

伴随以下限制:

  1. 最多不。一周的工作日:5
  2. 连续4天后的休息日 夜班。
  3. 不允许连续夜班和早班。
  4. 每班需求是7名护士。
  5. 护士每天只能工作一班,即早晚,白天
  6. 成本方案:

    Morning shift: $12
    Day shift: $13
    Night shift : $15
    

    目标函数是根据护士偏好最小化操作成本。

    有谁能让我知道如何制定这个问题?

2 个答案:

答案 0 :(得分:0)

首先,在您的问题定义中有一些不寻常的事情:

  1. 这不是一个真正的优化问题,因为你的目标函数是按照定义固定的(每个班次有7名护士,每个护士每班的价格相同)
  2. 在您的问题中,您每班制定7名护士,最长为5个工作日。因此,您需要7天七班三名护士。这相当于147护士/班次。但是,如果上限为五个工作日,每天只有一个班次,那么您只需要有5名轮班的20名护士,相当于100名护士/班次。
  3. 我在Mathprog中构建了问题,但代码应该或多或少等于AMPL。我开始为护士,日和轮班设置三套。

    set shifts := {1,2,3};
    set days := {1,2,3,4,5,6,7};
    set nurses := {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
    

    shedule被定义为一组二进制变量:

    var schedule{nurses, days, shifts}, binary;
    

    简单目标包含本周所有护士/班次与相关价格的总和:

    minimize cost: sum{i in nurses, j in days}(schedule[i,j,1]*c_morning+schedule[i,j,2]*c_day+schedule[i,j,3]*c_night);
    

    对于您的第一个约束,可以将每位护士的所有班次总和限制为5,因为每天只有一个班次:

    s.t. working_days{n in nurses}:
    sum{i in days, j in shifts}(schedule[n,i,j]) <= 5;
    

    休息日是问题中最困难的部分。为了简单起见,我创建了另一套只包含日子的套装,护士可以连续四个班次。您还可以使用原始天数制定约束,并排除前四天。

    set nigth_days := {5,6,7};
        s.t. rest{n in nurses,i in nigth_days}:
        (schedule[n,i-4,3]+schedule[n,i-3,3]+schedule[n,i-2,3]+schedule[n,i-1,3]+sum{j in shifts}(schedule[n,i,j])) <= 4;
    

    由于夜班后没有早班,我使用了与休息日相同的尝试。第七天被排除在外,因为没有第八天我们可以寻找早班。

        set yester_days := {1,2,3,4,5,6};
    s.t. night_morning{i in yester_days, n in nurses}:
    (schedule[n,i,3]+schedule[n,i+1,1]) <= 1;
    

    应该满足每班四名护士的需求(由于5班制限制,我已经减少了4名以上的护士是不可行的)

    s.t. demand_shift{i in days, j in shifts}:
    sum{n in nurses}(schedule[n,i,j]) = 4;
    

    第五个限制是将每天的班次限制为最多一次。

    s.t. one_shift{n in nurses, i in days}:
    sum{ j in shifts}(schedule[n,i,j]) <= 1;
    

答案 1 :(得分:0)

set nurse; #no. of full time employees working in the facility
set days;  #planning horizon 
set shift; #no. of shift in a day
set S; #shift correseponding to the outsourced nurses
set D;#day corresponding to the outsourced nurses
set N;#


# ith nurse working on day j

# j starts from Monday (j=1), Tuesday( j=2), Wednesday (j=3), Thursday(j=4), Friday(j=5), Saturday(j=6), Sunday(j=7)
#s be the shift as morning, day and night  



param availability{i in nurse, j in days};
param costpershift{i in nurse, j in days, s in shift};
param outcost{n in N, l in D, m in S};

var nurseavailability{i in nurse,j in days,s in shift} binary; # = 1 if nurse i is available on jth day working on sth shift, 0 otherwise
var outsourced{n in N, l in D, m in S} integer;


#Objective function

minimize Cost: sum{i in nurse, j in days, s in shift} costpershift[i,j,s]*nurseavailability[i,j,s]+ sum{ n in N, l in D, m in S}outcost[n,l,m]*outsourced[n,l,m];


#constraints

#maximum no. of shifts per day

subject to maximum_shifts_perday {i in nurse,j in days}:
 sum{s in shift} nurseavailability[i,j,s]*availability[i,j] <= 1;

#maximum no. of working says a week

subject to maximum_days_of_work {i in nurse}:  
sum{j in days,s in shift} availability[i,j]*nurseavailability[i,j,s]<=5; #maximum working days irrespective of shifts

# rest days after night shifts

subject to rest_days_after_night_shift{i in nurse}:  
sum{j in days} availability[i,j]*nurseavailability[i,j,3]<=4;


#demand per shift

subject to supply{j in days, s in shift, l in D, m in S}: 
sum{i in nurse} availability[i,j]*nurseavailability[i,j,s] + sum{n in N} outsourced[n,l,m]=7;


#outsourcing only works well when there is more variability in supply.
#increasing the staff no. would be effective for reducing the cost variability in demand.
#considering a budget of $16,000 per week
#outsourcing constraints: a maximum of 20 nurses can be outsourced per shift
# no. of fulltime employees=30
#demand is 7 nurses per shift
#the average variability 
#all nurses are paid equally @ $12 per hour.
#cost of an outsourced shift is $144.
#cost of morning shift is $96.
#cost of day shift is $104.
#cost of night shift is $120.

data;                                                                                                                                                                                                                                                                                                                                                                           


#set nurse ordered:=    nurse1  nurse2  nurse3  nurse4  nurse5  nurse6  nurse7  nurse8  
#nurse9 nurse10 nurse11 nurse12 nurse13 nurse14 nurse15 nurse16 nurse17 
#nurse18    nurse19 nurse20;

set nurse:= 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30;

#set days ordered:= Monday Tuesday  Wednesday Thursday Friday Saturday Sunday;

set days:= 1 2 3 4 5 6 7;                                                                                                                                                                                                                                                                                                                                           

#set shift ordered:=    Morning Day Night;

set shift:= 1 2 3;  

set D:= 1 2 3 4 5 6 7; #outsourced days
set S:=1 2 3; #outshit 
set N := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20;




   param outcost

   [*,*,1]:
                         1     2   3   4   5   6   7:=

                      1  144  144 144 144 144 144 144
                      2  144  144 144 144 144 144 144
                      3  144  144 144 144 144 144 144
                      4  144  144 144 144 144 144 144
                      5  144  144 144 144 144 144 144
                      6  144  144 144 144 144 144 144
                      7  144  144 144 144 144 144 144
                      8  144  144 144 144 144 144 144
                      9  144  144 144 144 144 144 144
                     10  144  144 144 144 144 144 144
                     11  144  144 144 144 144 144 144
                     12  144  144 144 144 144 144 144
                     13  144  144 144 144 144 144 144
                     14  144  144 144 144 144 144 144
                     15  144  144 144 144 144 144 144
                     16  144  144 144 144 144 144 144
                     17  144  144 144 144 144 144 144
                     18  144  144 144 144 144 144 144
                     19  144  144 144 144 144 144 144
                     20  144  144 144 144 144 144 144


    [*,*,2]:
                            1     2   3   4   5   6   7:=

                      1  144  144 144 144 144 144 144
                      2  144  144 144 144 144 144 144
                      3  144  144 144 144 144 144 144
                      4  144  144 144 144 144 144 144
                      5  144  144 144 144 144 144 144
                      6  144  144 144 144 144 144 144
                      7  144  144 144 144 144 144 144
                      8  144  144 144 144 144 144 144
                      9  144  144 144 144 144 144 144
                     10  144  144 144 144 144 144 144
                     11  144  144 144 144 144 144 144
                     12  144  144 144 144 144 144 144
                     13  144  144 144 144 144 144 144
                     14  144  144 144 144 144 144 144
                     15  144  144 144 144 144 144 144
                     16  144  144 144 144 144 144 144
                     17  144  144 144 144 144 144 144
                     18  144  144 144 144 144 144 144
                     19  144  144 144 144 144 144 144
                     20  144  144 144 144 144 144 144

     [*,*,3]:

                          1     2   3   4   5   6   7:=

                      1  144  144 144 144 144 144 144
                      2  144  144 144 144 144 144 144
                      3  144  144 144 144 144 144 144
                      4  144  144 144 144 144 144 144
                      5  144  144 144 144 144 144 144
                      6  144  144 144 144 144 144 144
                      7  144  144 144 144 144 144 144
                      8  144  144 144 144 144 144 144
                      9  144  144 144 144 144 144 144
                     10  144  144 144 144 144 144 144
                     11  144  144 144 144 144 144 144
                     12  144  144 144 144 144 144 144
                     13  144  144 144 144 144 144 144
                     14  144  144 144 144 144 144 144
                     15  144  144 144 144 144 144 144
                     16  144  144 144 144 144 144 144
                     17  144  144 144 144 144 144 144
                     18  144  144 144 144 144 144 144
                     19  144  144 144 144 144 144 144
                     20  144  144 144 144 144 144 144;






   param availability:                                                                                                                                                                                                                                                                                                                                                                      
            1          2        3           4          5        6         7 :=  

    1       0          0        0           0          0        0         0                                                                                                                                                                                                                                                                                                                                 
    2       1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                 
    3       1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                 
    4       1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    5       1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    6       1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    7       1          0        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    8       1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    9       1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    10      1          1        1           1          1        1         1 
    11      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    12      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    13      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    14      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    15      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    16      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    17      0          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    18      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    19      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    20      1          1        1           1          1        1         1
    21      1          1        1           1          1        1         1 
    22      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    23      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    24      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    25      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    26      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    27      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    28      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    29      1          1        1           1          1        1         1                                                                                                                                                                                                                                                                                                                                     
    30      1          1        1           1          1        1         1;                                                                                                                                                                                                                                                                                                                                    




param costpershift:= 


[*,*,1]:     1          2        3           4         5        6          7 := 


    1       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    2       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    3       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    4       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    5       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    6       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    7       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    8       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    9       96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    10      96         96       96          96         96       96        96    
    11      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    12      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    13      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    14      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    15      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    16      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    17      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    18      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    19      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    20      96         96       96          96         96       96        96
    21      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    22      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    23      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    24      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    25      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    26      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    27      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    28      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    29      96         96       96          96         96       96        96                                                                                                                                                                                                                                                                                                                                        
    30      96         96       96          96         96       96        96





  [*,*,2] : 1          2        3           4          5        6         7 :=      


    1       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    2       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    3       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    4       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    5       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    6       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    7       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    8       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    9       104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    10      104        104      104         104        104      104       104   
    11      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    12      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    13      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    14      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    15      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    16      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    17      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    18      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    19      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    20      104        104      104         104        104      104       104
    21      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    22      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    23      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    24      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    25      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    26      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    27      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    28      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    29      104        104      104         104        104      104       104                                                                                                                                                                                                                                                                                                                                       
    30      104        104      104         104        104      104       104



  [*,*,3] :  1         2         3          4          5        6         7 :=  


    1       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    2       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    3       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    4       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    5       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    6       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    7       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    8       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    9       120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    10      120        120      120         120        120      120       120   
    11      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    12      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    13      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    14      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    15      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    16      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    17      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    18      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    19      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    20      120        120      120         120        120      120       120
    21      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    22      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    23      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    24      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    25      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    26      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    27      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    28      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    29      120        120      120         120        120      120       120                                                                                                                                                                                                                                                                                                                                       
    30      120        120      120         120        120      120       120;