The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

244 lines
10 KiB

2 months ago
  1. /* File: shiftcover.mod */
  2. /* WORKFORCE SHIFT COVERAGE assignment problem */
  3. /* Written by Larry D'Agostino <larrydag -at- sbcglobal -dot- com>
  4. Maximize Productivity with Industrial Engineer and Operations Research Tools
  5. http://industrialengineertools.blogspot.com
  6. /* The WORKFORCE SHIFT COVERAGE is an assigment problem that determines
  7. the schedule of crew given available time and shifts.
  8. The objective is to cover the available time given hourly demand with the minimum
  9. number of crew members.
  10. This is a set covering problem that is very common among finding crew
  11. and shift allocations. Notice in the data section the workforce shift allocation
  12. per day of the week.*/
  13. /* ----- Model PARAMTERS and SETS -----*/
  14. param numhrs;
  15. /* number of hours of operations in a given day */
  16. param dys;
  17. /* number of days in a week */
  18. set S;
  19. /* set of crew shifts */
  20. set H := 1..numhrs;
  21. /* set of hours of a day*/
  22. set D;
  23. /* set of days of a week*/
  24. param dmnd{h in H, d in D};
  25. /* demand for crew members given h hour and d day */
  26. param shifts{d in D, h in H, s in S};
  27. /* shifts to assign to crew members given d day, h hour, and s shift schedule
  28. /*----- Model VARIABLES -----*/
  29. var crew{s in S}, integer, >=0;
  30. /* number of crew assigned to shift S */
  31. /*----- Model CONSTRAINTS -----*/
  32. s.t. Coverage{h in H, d in D}: sum{s in S} crew[s]*shifts[d,h,s] >= dmnd[h,d];
  33. /* number of crew to cover with a shift given hourly demand and day */
  34. /*----- Model OBJECTIVE -----*/
  35. minimize obj: sum{s in S} crew[s];
  36. /* minimize number of crew to cover demand*/
  37. solve;
  38. display crew;
  39. printf "\n";
  40. printf "Total Crew: %3d\n\n", sum{s in S} crew[s];
  41. printf "\n\n";
  42. printf "Weekly Crew Schedule\n\n";
  43. printf "Hour ";
  44. printf{d in D} " %s ", d;
  45. printf "\n";
  46. for {h in H} {
  47. printf " %2s ",h;
  48. printf{d in D} " %3d ", sum{s in S} crew[s]*shifts[d,h,s];
  49. printf "\n";
  50. }
  51. printf"\n";
  52. data;
  53. param numhrs := 16;
  54. set D := SUN, MON, TUE, WED, THU, FRI, SAT;
  55. set S := Sh1, Sh2, Sh3, Sh4, Sh5, Sh6, Sh7, Sh8, Sh9;
  56. param dmnd : SUN MON TUE WED THU FRI SAT :=
  57. 1 0 3 3 4 3 2 0
  58. 2 0 14 14 16 14 12 12
  59. 3 0 24 24 27 24 20 15
  60. 4 0 28 28 32 28 23 15
  61. 5 0 33 33 37 33 24 16
  62. 6 0 34 34 38 34 24 15
  63. 7 0 35 35 39 35 25 11
  64. 8 0 35 35 40 35 27 0
  65. 9 0 34 34 39 34 25 0
  66. 10 0 31 31 35 31 24 0
  67. 11 2 24 24 27 24 25 0
  68. 12 3 19 19 21 19 21 0
  69. 13 2 24 24 27 24 13 0
  70. 14 2 16 16 18 16 0 0
  71. 15 0 7 7 7 7 0 0
  72. 16 0 5 5 5 5 0 0;
  73. param shifts :=
  74. ['SUN',*,*]:
  75. Sh1 Sh2 Sh3 Sh4 Sh5 Sh6 Sh7 Sh8 Sh9 :=
  76. 1 0 0 0 0 0 0 0 0 0
  77. 2 0 0 0 0 0 0 0 0 0
  78. 3 0 0 0 0 0 0 0 0 0
  79. 4 0 0 0 0 0 0 0 0 0
  80. 5 0 0 0 0 0 0 0 0 0
  81. 6 0 0 0 0 0 0 0 0 0
  82. 7 0 0 0 0 0 0 0 0 0
  83. 8 0 0 0 0 0 0 0 0 0
  84. 9 0 0 0 0 0 0 0 0 0
  85. 10 0 0 0 0 0 0 0 0 0
  86. 11 0 0 0 0 0 0 0 0 1
  87. 12 0 0 0 0 0 0 0 0 1
  88. 13 0 0 0 0 0 0 0 0 1
  89. 14 0 0 0 0 0 0 0 0 1
  90. 15 0 0 0 0 0 0 0 0 0
  91. 16 0 0 0 0 0 0 0 0 0
  92. ['MON',*,*]:
  93. Sh1 Sh2 Sh3 Sh4 Sh5 Sh6 Sh7 Sh8 Sh9 :=
  94. 1 1 0 0 0 0 0 0 0 0
  95. 2 1 1 0 0 0 0 0 0 0
  96. 3 1 1 1 0 0 0 0 0 0
  97. 4 1 1 1 1 0 0 0 0 0
  98. 5 0 1 1 1 1 0 0 0 0
  99. 6 1 0 1 1 1 1 0 0 1
  100. 7 1 1 0 1 1 1 1 0 1
  101. 8 1 1 1 0 1 1 1 1 1
  102. 9 1 1 1 1 0 1 1 1 1
  103. 10 0 1 1 1 1 0 1 1 1
  104. 11 0 0 1 1 1 1 0 1 0
  105. 12 0 0 0 1 1 1 1 0 1
  106. 13 0 0 0 0 1 1 1 1 1
  107. 14 0 0 0 0 0 1 1 1 1
  108. 15 0 0 0 0 0 0 1 1 1
  109. 16 0 0 0 0 0 0 0 1 1
  110. ['TUE',*,*]:
  111. Sh1 Sh2 Sh3 Sh4 Sh5 Sh6 Sh7 Sh8 Sh9 :=
  112. 1 1 0 0 0 0 0 0 0 0
  113. 2 1 1 0 0 0 0 0 0 0
  114. 3 1 1 1 0 0 0 0 0 0
  115. 4 1 1 1 1 0 0 0 0 0
  116. 5 0 1 1 1 1 0 0 0 0
  117. 6 1 0 1 1 1 1 0 0 1
  118. 7 1 1 0 1 1 1 1 0 1
  119. 8 1 1 1 0 1 1 1 1 1
  120. 9 1 1 1 1 0 1 1 1 1
  121. 10 0 1 1 1 1 0 1 1 1
  122. 11 0 0 1 1 1 1 0 1 0
  123. 12 0 0 0 1 1 1 1 0 1
  124. 13 0 0 0 0 1 1 1 1 1
  125. 14 0 0 0 0 0 1 1 1 1
  126. 15 0 0 0 0 0 0 1 1 1
  127. 16 0 0 0 0 0 0 0 1 1
  128. ['WED',*,*]:
  129. Sh1 Sh2 Sh3 Sh4 Sh5 Sh6 Sh7 Sh8 Sh9 :=
  130. 1 1 0 0 0 0 0 0 0 0
  131. 2 1 1 0 0 0 0 0 0 0
  132. 3 1 1 1 0 0 0 0 0 0
  133. 4 1 1 1 1 0 0 0 0 0
  134. 5 0 1 1 1 1 0 0 0 0
  135. 6 1 0 1 1 1 1 0 0 1
  136. 7 1 1 0 1 1 1 1 0 1
  137. 8 1 1 1 0 1 1 1 1 1
  138. 9 1 1 1 1 0 1 1 1 1
  139. 10 0 1 1 1 1 0 1 1 1
  140. 11 0 0 1 1 1 1 0 1 0
  141. 12 0 0 0 1 1 1 1 0 1
  142. 13 0 0 0 0 1 1 1 1 1
  143. 14 0 0 0 0 0 1 1 1 1
  144. 15 0 0 0 0 0 0 1 1 1
  145. 16 0 0 0 0 0 0 0 1 1
  146. ['THU',*,*]:
  147. Sh1 Sh2 Sh3 Sh4 Sh5 Sh6 Sh7 Sh8 Sh9 :=
  148. 1 1 0 0 0 0 0 0 0 0
  149. 2 1 1 0 0 0 0 0 0 0
  150. 3 1 1 1 0 0 0 0 0 0
  151. 4 1 1 1 1 0 0 0 0 0
  152. 5 0 1 1 1 1 0 0 0 0
  153. 6 1 0 1 1 1 1 0 0 0
  154. 7 1 1 0 1 1 1 1 0 0
  155. 8 1 1 1 0 1 1 1 1 0
  156. 9 1 1 1 1 0 1 1 1 0
  157. 10 0 1 1 1 1 0 1 1 0
  158. 11 0 0 1 1 1 1 0 1 0
  159. 12 0 0 0 1 1 1 1 0 0
  160. 13 0 0 0 0 1 1 1 1 0
  161. 14 0 0 0 0 0 1 1 1 0
  162. 15 0 0 0 0 0 0 1 1 0
  163. 16 0 0 0 0 0 0 0 1 0
  164. ['FRI',*,*]:
  165. Sh1 Sh2 Sh3 Sh4 Sh5 Sh6 Sh7 Sh8 Sh9 :=
  166. 1 1 0 0 0 0 0 0 0 0
  167. 2 1 1 0 0 0 0 0 0 0
  168. 3 1 1 1 0 0 0 0 0 0
  169. 4 1 1 1 1 0 0 0 0 0
  170. 5 0 1 1 1 1 0 0 0 0
  171. 6 1 0 1 1 1 1 0 0 0
  172. 7 1 1 0 1 1 1 1 0 0
  173. 8 1 1 1 0 1 1 1 1 0
  174. 9 1 1 1 1 0 1 1 1 0
  175. 10 0 1 1 1 1 0 1 1 0
  176. 11 0 0 1 1 1 1 0 1 0
  177. 12 0 0 0 1 1 1 1 0 0
  178. 13 0 0 0 0 1 1 1 1 0
  179. 14 0 0 0 0 0 1 1 1 0
  180. 15 0 0 0 0 0 0 1 1 0
  181. 16 0 0 0 0 0 0 0 1 0
  182. ['SAT',*,*]:
  183. Sh1 Sh2 Sh3 Sh4 Sh5 Sh6 Sh7 Sh8 Sh9 :=
  184. 1 0 0 0 0 0 0 0 0 0
  185. 2 0 0 0 0 0 0 0 0 1
  186. 3 0 0 0 0 0 0 0 0 1
  187. 4 0 0 0 0 0 0 0 0 1
  188. 5 0 0 0 0 0 0 0 0 1
  189. 6 0 0 0 0 0 0 0 0 1
  190. 7 0 0 0 0 0 0 0 0 1
  191. 8 0 0 0 0 0 0 0 0 0
  192. 9 0 0 0 0 0 0 0 0 0
  193. 10 0 0 0 0 0 0 0 0 0
  194. 11 0 0 0 0 0 0 0 0 0
  195. 12 0 0 0 0 0 0 0 0 0
  196. 13 0 0 0 0 0 0 0 0 0
  197. 14 0 0 0 0 0 0 0 0 0
  198. 15 0 0 0 0 0 0 0 0 0
  199. 16 0 0 0 0 0 0 0 0 0;