$ondollar title ONB Shift Scheduling (LP) Example 4.5 of Rardin(1998) $offsymxref offsymlist offuelxref offuellist offupper option limrow = 0, limcol = 0; sets h "hours of the day" /11*21/, f(h) "full time shifts" /11*13/, p(h) "part time shifts" /11*18/; alias (h,hp); scalar nightp "night h position" /8/; scalars wagefull "hourly wage of full time employees" /11/, wagepart "hourly wage of part time employees" /7/, nightdif "night hours differential" /1/, cot "cost of overtime", numstns "number of stations" /35/, maxot "maximum daily overtime" /20/, prodf "production of full time per hour (000)" /1.000/, prodp "production of part time per hour (000)" /0.800/, maxback "backlog limit (000)" /20/; cot = 1.5*(wagefull+nightdif); display cot; parameter arr(h) "arrivals at h (000)" /11 10, 12 11, 13 15, 14 20, 15 25, 16 28, 17 32, 18 50, 19 30, 20 20, 21 8/; parameter cf(h) "cost per full time shift starting at h"; cf(h)$f(h)= 8*wagefull + max(0, ord(h)+9-nightp)*nightdif; display cf; parameter cp(h) "cost per part time shift starting at h"; cp(h)$p(h) = 4*wagepart + max(0, ord(h)+4-nightp)*nightdif; display cp; table dutyf(h,hp) "whether full time shift hp is on duty at hour h" 11 12 13 11 1 12 1 1 13 1 1 1 14 1 1 1 15 1 1 16 1 1 17 1 1 18 1 1 1 19 1 1 1 20 1 1 21 1; table dutyp(h,hp) "whether part time shift hp is on duty at hour h" 11 12 13 14 15 16 17 18 11 1 12 1 1 13 1 1 1 14 1 1 1 1 15 1 1 1 1 16 1 1 1 1 17 1 1 1 1 18 1 1 1 1 19 1 1 1 20 1 1 21 1; positive variables w(h) "backlog at h (000)", x(h) "full time shifts starting at h", y(h) "full time starting at h working overtime", z(h) "part time shifts starting at h"; w.up(h) = maxback; w.up('11') = 0; y.up('13') = 0; free variable cost "total cost"; equations obj "total pay", stn(h) "number of stations at h", otshft(h) "overtime limit per shift h", ottot "total overtime limit" cover(h) "cover constraint for h"; obj.. cost =e= sum(h$f(h), cf(h)*x(h) + cot*y(h)) +sum(h$p(h), cp(h)*z(h)); stn(h).. sum(hp$f(hp), dutyf(h,hp)*x(hp)) + y(h-9) + sum(hp$p(hp), dutyp(h,hp)*z(hp)) =l= numstns; otshft(h)$f(h).. y(h) =l= .5*x(h); ottot.. sum(h$f(h), y(h)) =l= maxot; cover(h).. sum(hp$f(hp), prodf*dutyf(h,hp)*x(hp)) + prodf*y(h-9) + sum(hp$p(hp), prodp*dutyp(h,hp)*z(hp)) =g= arr(h) + w(h) - w(h+1); model onb /all/; solve onb using lp minimizing cost;