<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Nurse Scheduling question in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/410042#M2037</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;for the reading. &amp;nbsp;I got an email that you posted a question about the cyclic nature, but I don't see it here. &amp;nbsp;Yes, the idea is that the schedule will start on a Monday (week 1) and will finish at Week 6 and then start back again to week 1. &amp;nbsp;The idea is that the nurses will then know that Week 2 of the schedule, they're doing a particular shift and can plan their lives accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm hoping this makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks again for your time&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Fri, 03 Nov 2017 00:04:44 GMT</pubDate>
    <dc:creator>DarthPathos</dc:creator>
    <dc:date>2017-11-03T00:04:44Z</dc:date>
    <item>
      <title>Nurse Scheduling question</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/409511#M2033</link>
      <description>&lt;P&gt;Good morning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nothing like learning a new SAS skill with a horribly complex project &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to build a 6 week Schedule Template for the nurses that work in the Recovery area for my hospital.&amp;nbsp; A couple of key things about my organisation:&lt;/P&gt;
&lt;P&gt;1) We are Monday - Friday only, without inpatients etc. (100% ambulatory/outpatient surgery and clinics)&lt;/P&gt;
&lt;P&gt;2) Our nurses do not go to other units; they are dedicated to the Recovery area.&lt;/P&gt;
&lt;P&gt;3) Our Nursing Union is extremely strict on the scheduling requirements, and so these need to be met as&amp;nbsp;part of the schedule.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to build a Template so that I can keep reusing the plan - holidays and closures will impact the schedule, but this template will cover 95% of the year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here&amp;nbsp;are the constraints that I've been able to put together so far:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) All Full Time nurses must work 4 Mondays in the 6 week schedule&lt;/P&gt;
&lt;P&gt;2) All Full Time nurses must work 4 Fridays in the 6 week schedule&lt;/P&gt;
&lt;P&gt;3) Full Time hours is 75 hours per 2 week pay-period, and must be met&lt;/P&gt;
&lt;P&gt;4) All FT nurses must work the same number of 7, 10, and 12 hour shifts per 6 week cycle.&lt;/P&gt;
&lt;P&gt;5) FT nurses can't do two weeks of 12 hour shifts, and can't have more than 3 days off in a row (excluding weekends)&lt;/P&gt;
&lt;P&gt;6) We have 3 PT Nurses&amp;nbsp;at 0.6 FTE, 1 at 0.5 FTE, and 1 at 0.4 FTE (45 hours, 37.5 (round to 38)&amp;nbsp;hours and 30 hours)&lt;/P&gt;
&lt;P&gt;7) The PT Nurses&amp;nbsp;must meet their hours in a&amp;nbsp;2&amp;nbsp;pay-period, no more or less.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; We have 9 Full Time Nurses, 5 PT, and 7 Casual.&amp;nbsp; Casuals do not need to pick up minimum hours.&lt;/P&gt;
&lt;P&gt;9) I can only have a total of&amp;nbsp;3 shifts per day for the PT / Casual staff (ideal would be 2, but 3 shifts is OK)&lt;/P&gt;
&lt;P&gt;10)&amp;nbsp;There are&amp;nbsp;3 12-hour shifts, 3 10-hour shifts, and 7 8-hour shifts per day&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've read through &lt;A href="http://www.math.cmu.edu/~af1p/Teaching/OR2/Projects/P23/ORProject_Final_Copy.pdf" target="_self"&gt;A Brief Study of the Nurse Scheduling Problem (NSP)&lt;/A&gt;, which was good but not SAS-related.&amp;nbsp;I've been trying to put the constraints in terms of mathematical notation but getting lost in all the symbols; although not needed for the project, if I can have help putting the forumulae together, that would be amazing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've gone through the Building and Solving Optimization Models with SAS/OR Course Notes, and the SAS/OR Documentation online.&amp;nbsp; Because I'm trying to constrain both rows (number of hours for each nurse) and columns (number of shifts per day), I'm going around in circles.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We don't need to take into account nurses' preferences for this template.&amp;nbsp; This is just a "proof of concept" for the Nurse Manager, and I'll work with Human Resources and the leadership team to fine-tune the scheduling model.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd appreciate any ideas you have, or links to documentation that may help.&amp;nbsp; I'm happy and willing to do the work, I just need some guidance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your time and have a great day&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 15:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/409511#M2033</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2017-11-01T15:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Nurse Scheduling question</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/409517#M2034</link>
      <description>&lt;P&gt;Here are a couple of related doc examples:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetVersion=14.3&amp;amp;docsetTarget=ormpug_milpsolver_examples01.htm&amp;amp;locale=en" target="_self"&gt;Example 8.1 Scheduling&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetVersion=14.3&amp;amp;docsetTarget=ormpug_clpsolver_examples06.htm&amp;amp;locale=en" target="_self"&gt;Example 6.3 Work-Shift Scheduling Problem&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 15:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/409517#M2034</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-11-01T15:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Nurse Scheduling question</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/410042#M2037</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;for the reading. &amp;nbsp;I got an email that you posted a question about the cyclic nature, but I don't see it here. &amp;nbsp;Yes, the idea is that the schedule will start on a Monday (week 1) and will finish at Week 6 and then start back again to week 1. &amp;nbsp;The idea is that the nurses will then know that Week 2 of the schedule, they're doing a particular shift and can plan their lives accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm hoping this makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks again for your time&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 00:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/410042#M2037</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2017-11-03T00:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Nurse Scheduling question</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/410045#M2038</link>
      <description>&lt;P&gt;Yes, I had posted asking whether the schedule should be cyclic in the sense that a shift that starts near the end of the six weeks should wrap around to the beginning of the six weeks.&amp;nbsp; But then I reread that the nurses work Monday-Friday and realized that this can't happen because no shift is that long to start on Friday and end on Monday.&amp;nbsp; So I deleted the post.&amp;nbsp; Sorry for the confusion.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 00:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/410045#M2038</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-11-03T00:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Nurse Scheduling question</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/410476#M2039</link>
      <description>&lt;P&gt;Are the shift start times predetermined, or are they supposed to be determined by the solver?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 21:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/410476#M2039</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-11-03T21:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Nurse Scheduling question</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/411650#M2050</link>
      <description>&lt;P&gt;Hi Rob&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apologies for the delay, been a rough week.&amp;nbsp; The start times will be determined by the shift (12 hour is 630-1830, 8 hour is 8-4, 10 hour is 1000-1900).&amp;nbsp; We are looking at adding shifts based on skill set but that'll be down the road.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and have a good day&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 19:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/411650#M2050</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2017-11-08T19:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Nurse Scheduling question</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/411729#M2051</link>
      <description>&lt;P&gt;I'm not sure I have interpreted all your rules correctly.&amp;nbsp; For example, does four Mondays mean exactly four or at least four?&amp;nbsp; In any case, the code below should give you a nudge in the right direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I added an objective to minimize the total number of hours worked.&amp;nbsp; You can replace this with whatever you want.&amp;nbsp; Also, it seems that you were missing some rule about at most one shift per day per nurse, so I added a constraint for that.&amp;nbsp;&amp;nbsp;Workforce scheduling problems like this usually have a constraint to make sure that some forecasted demand for each period is covered.&amp;nbsp; In particular, there is nothing in this model that prevents some hour from having no staff assigned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, when I run this the resulting optimal schedule does not use any Casual nurses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you have any further questions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data nurse_data(drop=i);
   length type $6.;
   do i = 1 to 9;
      nurse + 1;
      type = 'FULL';
      hours = 75;
      output;
   end;
   do i = 1 to 3;
      nurse + 1;
      type = 'PT';
      hours = 45;
      output;
   end;
   nurse + 1;
   hours = 38;
   output;
   nurse + 1;
   hours = 30;
   output;
   do i = 1 to 7;
      nurse + 1;
      type = 'Casual';
      hours = 0;
      output;
   end;
run;

data shift_data;
   input shift length daily_count;
   datalines;
1 12 3
2 10 3
3  8 7
;

proc optmodel;
   num num_weeks = 6;
   num num_days_per_week = 5;
   set WEEKS = 0..num_weeks-1;
   set DAYS = 0..num_weeks*num_days_per_week-1;
   num week {d in DAYS} = floor(d/num_days_per_week);
   num dow {d in DAYS} = mod(d,num_days_per_week); /* Monday = 0, ..., Friday = 4 */
   str dow_name {0..4} = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
   print week dow {d in DAYS} dow_name[dow[d]];

   set NURSES;
   str nurse_type {NURSES};
   num nurse_hours {NURSES};
   read data nurse_data into NURSES=[nurse] nurse_type=type nurse_hours=hours;

   set SHIFTS;
   num shift_length {SHIFTS};
   num shift_count {SHIFTS};
   read data shift_data into SHIFTS=[shift] shift_length=length shift_count=daily_count;

   /* Assign[n,d,s] = 1 if nurse n works on day d in shift s */
   var Assign {NURSES, DAYS, SHIFTS} binary;

   set FT_NURSES     = {n in NURSES: nurse_type[n] = 'FULL'};
   set PT_NURSES     = {n in NURSES: nurse_type[n] = 'PT'};
   set CASUAL_NURSES = {n in NURSES: nurse_type[n] = 'Casual'};

   con Con1 {n in FT_NURSES}:
      sum {d in DAYS: dow_name[dow[d]] = 'Mon'} sum {s in SHIFTS} Assign[n,d,s] &amp;gt;= 4;

   con Con2 {n in FT_NURSES}:
      sum {d in DAYS: dow_name[dow[d]] = 'Fri'} sum {s in SHIFTS} Assign[n,d,s] &amp;gt;= 4;

   con Con3 {n in NURSES, w in 0..num_weeks-1 by 2}:
      sum {d in DAYS: week[d] in {w,w+1}} sum {s in SHIFTS} shift_length[s]*Assign[n,d,s] &amp;gt;= nurse_hours[n];

   var FTShiftCount {SHIFTS} &amp;gt;= 0 integer;
   con Con4 {n in FT_NURSES, s in SHIFTS}:
      sum {d in DAYS} Assign[n,d,s] = FTShiftCount[s];

   /* at least one non 12-hour shift every 10 days */
   con Con5a {n in FT_NURSES, start in DAYS: start+9 in DAYS}:
      sum {d in start..start+9} sum {s in SHIFTS: shift_length[s] ne 12} Assign[n,d,s] &amp;gt;= 1;

   /* at least one shift every four days */
   con Con5b {n in FT_NURSES, start in DAYS: start+3 in DAYS}:
      sum {d in start..start+3, s in SHIFTS} Assign[n,d,s] &amp;gt;= 1;

   con Con9 {d in DAYS}:
      sum {n in PT_NURSES union CASUAL_NURSES, s in SHIFTS} Assign[n,d,s] &amp;lt;= 3;

   con Con10 {d in DAYS, s in SHIFTS}:
      sum {n in NURSES} Assign[n,d,s] &amp;lt;= shift_count[s];

   /* for each nurse, at most one shift per day */
   con OneShiftPerDay {n in NURSES, d in DAYS}:
      sum {s in SHIFTS} Assign[n,d,s] &amp;lt;= 1;

   /* minimize total number of hours worked */
   min TotalHours = 
      sum {n in NURSES, d in DAYS, s in SHIFTS} shift_length[s]*Assign[n,d,s];

   /* call MILP solver */
   solve;

   print shift_length FTShiftCount;
   print Con1.body Con1.lb;
   print Con2.body Con2.lb;
   print Con3.body Con3.lb;

   /* create output data set */
   create data solution_data from [nurse day shift]=
      {n in NURSES, d in DAYS, s in SHIFTS: Assign[n,d,s].sol &amp;gt; 0.5}
      week[d] dow=dow_name[dow[d]] nurse_type[n] shift_length[s];
quit;

proc sort data=solution_data;
   by nurse day shift;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 22:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/411729#M2051</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-11-08T22:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Nurse Scheduling question</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/412302#M2060</link>
      <description>&lt;P&gt;I'm currently at home with food poisoning (I think that's what it is at least) so won't have a chance to play with this till Monday, but &lt;EM&gt;holy cow&lt;/EM&gt; this is awesome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the feedback re: Constraints etc.&amp;nbsp; I am really excited to use this to help my organization move forward, and excited to see what I can learn.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best and have a great weekend&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 12:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Nurse-Scheduling-question/m-p/412302#M2060</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2017-11-10T12:51:53Z</dc:date>
    </item>
  </channel>
</rss>

