'Model for scheduling surgeries

I am developing a model in GAMS to schedule surgeries. I think I am not getting the right results and think some equations may not be well formulated. Bellow you can find the entire model I developed. I think my main issues lie in:

eq08:it is supposed to only allow one surgery to be scheduled during the entire duration of said surgery. For example, if surgery s has duration=7 and it's scheduled at t=4, on a day and a room, no other surgery can be scheduled at t=4,5,6,7,8,9,10 for that day and room. I think the equation is not doing this.

eq21: no surgeries that require ag (=1 in the data) can be scheduled in room 1, but i think it is not doing this, instead it is not scheduling any surgery in room 1.

eq22: surgeons can only be performing 1 surgery at a time, but I think it is not doing that.

eq24: some surgeons have pre-assigned times frames and no other surgeon can use them, but when I include this constraint it says the output file is too big.

Thank you, Gonçalo


 
Sets    s "Surgeries"
        c "Surgeons" 
        d "days of the week" / monday, tuesday, wednesday, thursday, friday, saturday /
        r "Operating Rooms" / 1 * 10 /
        t "Timeslots, every timeslot represents 15 min" / 1*64 / 
        e "Surgical Spelciaties" / angyopraphy, plastic, maxilo, vascular , dermatology, neuro, general, orthopedic, urology, internal, gynecology, ophthalmology, cardiotoracic, cardiac, otolaryngology  /
        surg 'surgeData Header' / ds, agh, uciph /
;
        
Table surgData(s<,c<,e,surg) 'Surgery Data'
$onDelim
s,c,e,ds,agh,uciph
1,539662512,plastic,3,0,0
2,539662512,plastic,3,0,0
3,539662512,plastic,4,0,0
4,27840008,cardiac,18,1,1
5,61903721,general,8,1,0
6,13060008,vascular,28,1,1
7,58975712,neuro,6,1,0
8,126454322,orthopedic,11,1,0
9,772850351,orthopedic,9,1,0
10,772850351,orthopedic,6,1,0
11,999961932,orthopedic,7,1,0
12,999961932,orthopedic,8,1,0
13,999961932,orthopedic,12,1,0
14,32025401,otolaryngology,8,1,0
15,175707281,urology,7,1,0
16,175707281,urology,10,1,0
17,959053412,urology,5,1,0
18,959053412,urology,2,1,0
19,476072132,angyopraphy,4,0,0
20,6820005,angyopraphy,4,0,0
21,797391361,angyopraphy,5,0,0
22,797391361,angyopraphy,4,0,1
23,797391361,angyopraphy,3,0,1
24,6820005,angyopraphy,3,0,0
25,539662512,plastic,7,0,0
26,539662512,plastic,7,1,0
27,27740008,general,4,0,0
28,27740008,general,5,1,0
29,54140008,general,3,1,0
30,27740008,general,5,1,0
31,54140008,general,5,1,0
32,37964022,general,3,1,0
33,83940008,general,11,1,0
34,83940008,general,6,1,0
35,600739601,maxilo,5,1,0
36,4213405,maxilo,5,1,0
37,84213405,maxilo,5,1,0
38,84213405,maxilo,9,1,0
39,13060008,vascular,9,1,0
40,907897812,gynecology,11,1,0
41,54140008,internal,4,1,0
42,6030005,neuro,2,0,0
43,55837332,neuro,21,1,1
44,6030005,neuro,12,1,0
45,96440008,ophthalmology,2,0,0
46,96440008,ophthalmology,2,0,0
47,96440008,ophthalmology,2,1,0
48,96440008,ophthalmology,4,1,0
49,60551181,ophthalmology,1,0,0
50,911073202,ophthalmology,1,0,0
51,686633612,orthopedic, 9,0,0
52,6251005,orthopedic,7,1,0
53,502682702,orthopedic,5,1,0
54,502682702,orthopedic,4,1,0
55,63840008,orthopedic,7,1,0
56,502682702,orthopedic,7,1,0
57,63840008,orthopedic,5,1,0
58,489248032,orthopedic,4,1,0
59,63840008,orthopedic,9,1,1
60,6251005,orthopedic,11,0,0
61,770964121,otolaryngology,7,1,0
62,5670005,otolaryngology,10,1,0
63,70964121,otolaryngology,5,1,0
64,5670005,otolaryngology,8,1,0
65,9231005,urology,2,0,0
66,9231005,urology,6,1,1
67,9231005,urology,11,1,0
68,608075771,urology,5,1,0
69,749054931,urology,5,1,1
70,4820005,angyopraphy,4,0,1
71,4820005,angyopraphy,8,0,1
72,4820005,angyopraphy,9,0,1
73,27740008,general,6,0,0
74,27740008,general,4,1,0
75,54140008,general,7,1,0
76,27740008,general,18,1,0
77,54140008,general,3,1,0
78,27740008,general,9,1,0
79,987063311,general,9,1,0
80,987063311,general,4,1,0
81,987063311,general,4,1,0
82,987063311,general,6,1,0
83,13060008,vascular,5,1,0
84,13060008,vascular,11,1,1
85,81060008,dermatology,2,0,0
86,81060008,dermatology,2,0,0
87,81060008,dermatology,2,0,0
88,81060008,dermatology,2,0,0
89,81060008,dermatology,2,0,0
90,13060008,internal,11,1,0
91,24590008,neuro,13,1,0
92,6030005,neuro,15,1,0
93,96440008,ophthalmology,2,0,0
94,96440008,ophthalmology,2,0,0
95,96440008,ophthalmology,2,0,0
96,96440008,ophthalmology,2,0,0
97,96440008,ophthalmology,1,0,0
98,911073202,ophthalmology,7,1,0
99,96440008,ophthalmology,3,1,0
100,96440008,ophthalmology,2,1,0
$offDelim
;

Table Max_Timeslots(d,r) "maximum time each or can be open on each day"
                    1    2    3    4    5    6    7    8    9    10
        monday      64   64   64   64   64   64   64   48   64   64
        tuesday     64   64   64   64   64   64   64   48   64   64
        wednesday   64   64   64   64   64   64   64   48   64   64
        thursday    64   64   64   64   64   64   64   48   64   64
        friday      64   64   64   64   64   64   64   48   64   64 
        saturday    32   32   32   32   32   32   32   32   32   32
;

Scalars laser "number of urology lasers available" / 2 /
        orthopedic "number of orthopedic surgeries allowed at the same time" / 4 /
        ucip "number of available beds in the UCIP on day d" / 7 /
        TimeSlotDuration "one timeslot of 15 minutes" /1/;
        
Parameter time(t) "set to scalar" /
        1 1,2 2,3 3,4 4,5 5, 6 6,7 7,8 8,9 9,10 10,11 11,12 12,13 13,14 14,15 15,16 16,17 17,18 18,19 19,20 20,21 21,22 22,23 23,24 24,25 25,26 26,27 27,28 28,29 29,30 30,31 31,32 32,33 33,34 34,35 35,36 36,37 37,38 38,39 39,40 41,42 42,43 43,44 44,45 45,46 46,47 47,48 48,49 49,50 50,51 51,52 52,53 53,54 54,55 55,56 56,57 57,58 58,59 59,60 60,61 61,62 62,63 63,64 64       
/;


Parameter UrologyLimit(e) /urology 1/;

Parameter OrthopedicLimit(e) /orthopedic 1/;

Parameter SpecialtyRoom (r,e) / 1  .(ophthalmology) 1
                                2  .(neuro) 1
                                3  .(general) 1
                                4  .(general) 1
                                5  .(orthopedic) 1
                                6  .(orthopedic) 1
                                7  .(urology, gynecology) 1
                                8  .(angyopraphy, plastic, maxilo, vascular , dermatology, neuro, general, orthopedic, urology, internal, gynecology, ophthalmology, cardiotoracic, cardiac, otolaryngology) 1
                                9  .(otolaryngology) 1
                                10 .(angyopraphy, vascular, internal, cardiac, maxilo, plastic) 1/;
                                
Parameter AGroom(r) /1 0,2 1,3 1,4 1,5 1,6 1,7 1,8 1,9 1,10 1/;

parameter SurgeonsSlots(c,d,r,t)
/
6030005 .(tuesday) .(2). (1*24) 1
70640008 .(thursday) .(4). (1*28) 1
9240005 .(tuesday) .(5). (1*32) 1
7150005 .(monday) .(6). (1*26) 1
9480005 .(monday) .(6). (40*64) 1
3670005 .(wednesday) .(7). (25*64) 1
70240008 .(wednesday) .(8). (40*64) 1
/;

Set couple(s,c,e) 'Sugery, surgeon, specialty';
option couple<surgData;

Variables
  alpha_start(s,c,e,d,t,r)                 '1 if surgery s is scheduled to start by surgeon c in timeslot t, room r, day d, 0 otherwise'
  obj1                                 'objective variable'
;
Binary variable alpha_start;
Free Variable obj1;

Equations
    eq01       'the number of surgeries scheduled for the week is maximized (objective)'
    eq03(s,c,e)       'ensure that all surgeries are scheduled at most once'
    eq07(d,r)       'not allow to surpass the available time on each room on each day'
    eq08(d,r)       'the surgery starting in a timeslot, room and day is scheduled at least for the number of timeslots correspondent to its duration'
    eq09(s,c,e,d,t,r) 'not allow for overtime'
    eq13(d)       'ICU capacity can’t be exceeded '
    eq17(t)       'no surgery is scheduled in a way that exceeds the number of urology lasers'
    eq20(t) 'max of 4 orthopedic surgeries at the same time'
    eq21(s,c,e,d,t,r) 'no surgery requiring genereal anestheology in r=1'
    eq22(s,c,e,d,t) 'each surgeon participates at most in one surgery at any point in time'
    eq24(c,d,t,r) 'certain surgeons have a pre-assigned time frame and no other surgeon can use that time frame'


    
;

Alias(s,si);
Alias(d,di);
Alias(t,ti);
Alias(r,ri);
Alias(c,ci);
Alias(e,ei);

* Objective (test the equation bellow as well where certain specialties should be scheduled in certain rooms'

eq01.. obj1 =e= sum(couple(s,c,e), sum(di,sum(ti,sum(ri, alpha_start(couple, di,ti,ri)))));

*eq01.. obj1 =e= sum(si,sum(ci, sum(di,sum(ti,sum(ri, sum(ei, SpecialtyRoom(ri,ei)*alpha_start(si,ci,ei,di,ti,ri)))))));


* Ceneral Constraints
eq03(couple)..     sum(di, sum(ti, sum(ri, alpha_start(couple,di,ti,ri)))) =l= 1;
eq07(d,r)..       sum(couple(s,c,e), sum(ti, alpha_start(couple,d,ti,r)*surgData(couple,"ds"))) =l= Max_Timeslots(d,r);
*eq08(d,r)..   sum(couple(s,c,e),sum(ti$[ord(ti) <= time(ti)+surgData(couple,"ds")-1],alpha_start(couple,d,ti,r))) =l= 1;
eq09(couple,d,t,r).. alpha_start(couple,d,t,r)*surgData(couple,"ds") =l= card(t)- time(t);

*Specialties/Equipment Constraints

eq13(d)..     sum(couple(s,c,e),sum(ti, sum(ri, surgData(couple,"uciph")*alpha_start(couple,d,ti,ri)))) =l= ucip;
eq17(t)..     sum(couple(s,c,e),sum(ri, sum(di, UrologyLimit(e)*alpha_start(couple,di,t,ri)))) =l= laser;
eq20(t)..     sum(couple(s,c,e), sum(ri, sum(di, OrthopedicLimit(e)*alpha_start(couple,di,t,ri)))) =l= orthopedic;
eq21(couple,d,t,r).. alpha_start(couple,d,t,r)*surgData(couple,"agh") =l= AGroom(r);
eq22(couple,d,t).. sum(ri, alpha_start(couple,d,t,ri)) =l= 1;
*eq24(c,d,t,r)$(SurgeonsSlots(c,d,r,t)).. sum(si, alpha_start(si,c,d,t,r)) =l= SurgeonsSlots(c,d,r,t);


model ORScheduling / all /;

option limcol=0,limrow=0,solprint=off;

Solve ORScheduling using mip maximizing obj1;

Display obj1.l;
Display alpha_start.l; 


Solution 1:[1]

I'm happy to give you some feedback on the eq08. In order to ensure that the OP's are not occupied twice, an equation must be set up for each possible treatment duration, which ensures that there is no new "alphastart" during the treatment time. I would have implemented it as follows for treatment durations of 2, 3 and 4 time units:

eq10(d,r,t)..           1-sum(couple(s,e)$(surgData(couple,"ds")=2),alpha_start(couple,d,r,t)) =g= sum(couple(s,e),sum(ti$(time(ti) > ord(t) and time(ti) < ord(t)+2),alpha_start(couple,d,r,ti)));
eq11(d,r,t)..           1-sum(couple(s,e)$(surgData(couple,"ds")=3),alpha_start(couple,d,r,t)) =g= sum(couple(s,e),sum(ti$(time(ti) > ord(t) and time(ti) < ord(t)+3),alpha_start(couple,d,r,ti)));
eq12(d,r,t)..           1-sum(couple(s,e)$(surgData(couple,"ds")=4),alpha_start(couple,d,r,t)) =g= sum(couple(s,e),sum(ti$(time(ti) > ord(t) and time(ti) < ord(t)+4),alpha_start(couple,d,r,ti)));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cigien