Adapting a Nurse Scheduling Problem to Fet

Started by Student in Need:), May 14, 2021, 07:50:47 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Student in Need:)

Hello all,

I am fairly new in FET and I am in need of  serious scheduling problem for my assignment. Actually I take a subject that is really hard for me(we decided the subject to do before using the program)  since I am new in FET and it is designed for scheduling timetables for students. My main problem is scheduling 15 nurses for 14 days over 3 shifts(morning-full-night) for 2 departments(internal medicine&endocrine). I have some constraints like;
-Each nurse should work max 40hours a week
-Necessary number of nurses must be met for the determined shifts each day
-A nurse working on full time shift mus have at least 48 hours off from the day he/she works
-Nurse 1 must work in internal medicine on mornings in weekdays
-Nurse 2 must work in endocrine on mornings in weekdays
-Nurse 3 is on annual leave bw 8th-12th days
-Nurses 4,5,6 should work only in the int. medicine
-Nurses 7,8 should work only in the endocrine
-Total shift assignments and each shift assignments should be as equal as possible

I have tried different things like making student-years as nurses, rooms as shifts etc. 
At my last trial I put nurses to teachers,departments to subject(to define qualified nurses), shifts as students(Morning-weekday,full-weekday,full-weekend etc) and shift-department pairs as rooms(to make the desired number of nurses for each shift to specify) among other things like activity planning. The FET found the timetable instantly and something ridiculous like putting nurse1 into only 1 day&1shift etc.
After a lot of reading different sites,articles and watching volkerr dir video list on youtube among the other videos , I still can not figure out to put what to where and it somehow gets complicated while thinking more about it. Therefore, I would be very,very grateful if you could give me an idea of "where to place what and how to do it" .

I attached the detailed explanation of my proposal for this project.(There can be some simplifications on impossible constrained:)

Thank you.

Liviu Lalescu

Hello, Anonymous Student  :)  ,

I just saw your message and I will try to think of it, a bit later. Could you please:

- Let me know if it is legal/moral for you to ask for help and for us to help you, knowing that it is a project assigned for you;
- Scan the paper in a higher resolution and put it as a pdf? (I printed your picture, but it is a bit unclear).

Student in Need:)

Hello Liviu Lalescu,

First of all, I would like to thank you for helping me out.

I assure you I got permission to write my problem in the forum from my professor.
I scanned the paper as pdf and attached it below. If it is not readible it might because my hand writing is not beautiful and I can write it on word document if it is hard for you to read :)

Thank you.

Liviu Lalescu

#3
Hello,

Please call me Liviu  :)

I think you can try to use FET (version 6 and later) in this special way:

The FET days are the nurses (Nurse 1, Nurse 2, ...) and the FET hours are the real-life slots, like this: Day 1 8-16, Day 1 16-0, Day 1 0-8, Day 2 8-16, Day 2 16-0, Day 2 0-8, ... .

There are a fixed number of activities only with subject (you don't use students), which have duration 1 (M or N) and duration 2 (F). They are assigned to FET days (real-life nurses) and hours (real-life time slots).

I think you need to add a constraint that all activities are not overlapping.

1) max 40 hpw: constraints activities occupy max time slots from selection.

2) necessary n of nurses: I think this comes naturally. You might need to add for each activity the preferred (allowed, 100%) times per week. Not for each one in part, but using shortcuts as tags.

3) constraints activities occupy max time slots from selection.

4) add dummy activities for each F activity with duration 6, and constraints two activities consecutive.

5) days-off as far: we need to think of this. Maybe add specific activities with duration 3, one for each day off of each nurse, constrain each of them for a specific nurse (with constraints activities preferred times), and add min gaps between activities.

6) - 10) - easy, with constraints all activities preferred time slots, not allowed 100% in the respective slots.

11) - 13) - maybe possible with constraints activities occupy max/min time slots from selection, so that for instance night shifts of nurses are max 2 for each nurse and min 1 for each nurse (add one constraint for each nurse = FET day).

Hmm, just now I saw that there are two departments, internal medicine and endocrinology. But maybe it will work this way: the FET hours will become like this: Day 1 8-16 IM, Day 1 8-16 E, Day 1 16-0 IM, Day 1 16-0 E, Day 1 0-8 IM, Day 1 0-8 E, Day 2 8-16 IM, Day 2 8-16 E, Day 2 16-0 IM, Day 2 16-0 E, Day 2 0-8 IM, Day 2 0-8 E, and double the duration of each activity, and half of the activities will have preferred time 100% to begin on even FET hours and the other half 100% to begin on odd FET hours.

You might want to read the help of FET for the block planning mode, FET block planning contains a few additional constraints which might help with the fair distribution.

Student in Need:)

Hello again Liviu :)

I am trying different things acording to what you wrote (actually more that what I can understand  ;D )and trying to understand the Fet better like more than 5 hours. I have done this things because I couldn't understand  this part "There are a fixed number of activities only with subject (you don't use students), which have duration 1 (M or N) and duration 2 (F). They are assigned to FET days (real-life nurses) and hours (real-life time slots)." so some other things also  get confusing at some point.

I entered DAYS as Nurses(Nurse1,..,Nurse15)
HOURS as day_shift_department ( Day1_8-16_IM)

SUBJECTS as department_weekday/end_shift (IM_WD_M(internal med_weekday_morning), IM_WE_M, ...., E_WE_N, E_WE_N(endocrin_weekend_night))>>12 subjects occured

ACTIVITIES
To make sure that each nurse requirements in the 1st Table are met for each department.
For example ,I thought making duration 3 with min days 3 and 100%weight consecutive (for internal medicine morning-weekday requirement) will be enough.Then I can add 2 constraints preferred time slots for week1(day1-day5) and for week2(day8-day12).
I did this for all subjects.

After that I selected preffered time slots for all activities.For ex, IM_WD_M(all days in weekday with 8-16_IM)

Then to meet 2nd table which are total assignments required which contains all nurses; I add a constraint "A set of actv occupies min time slots from selectin" For ex,  E_WE_N ( all days in weekends with 0-8_E) with min occupied=8 since 8 nurse-assignments is required for that shift in weekends.

Once I tried to generate at this point, errors occured such that  "Activities occupy min time slots from selection' with the total duration of the selected activities being 2, but the number of requested minimum slots is 8, which is greater - impossible. "
Therefore, I am stucked and lost at this point:(

Thank you so much for your help.

Liviu Lalescu

Quote from: Student in Need:) on May 15, 2021, 09:44:00 PM
HOURS as day_shift_department ( Day1_8-16_IM)

So, 14 real days * 3 real hours per real day * 2 (IM/E) = 70 hours per day (I hope I am not mistaking). After the first real slot of IM comes the first real slot of E, then the second real slot of IM, ... . Oh, and +1, because the last E slot will have an activity with duration 2. So 71 hours per day.

Quote
SUBJECTS as department_weekday/end_shift (IM_WD_M(internal med_weekday_morning), IM_WE_M, ...., E_WE_N, E_WE_N(endocrin_weekend_night))>>12 subjects occured

2 (IM/E) * 2 (W/WE) * 3 shifts, indeed, 12 subjects.

Quote
ACTIVITIES
To make sure that each nurse requirements in the 1st Table are met for each department.
For example ,I thought making duration 3 with min days 3 and 100%weight consecutive (for internal medicine morning-weekday requirement) will be enough.Then I can add 2 constraints preferred time slots for week1(day1-day5) and for week2(day8-day12).
I did this for all subjects.

No. Add each activity of IM/E for Morning or Night with duration 2 (not split) and for Full-day duration 4. Why double (2*1, and 2*2)? Because of continuity from IM to E. You don't use min days between activities, because you are using FET in an unusual way.

Quote
After that I selected preffered time slots for all activities.For ex, IM_WD_M(all days in weekday with 8-16_IM)

Preferred starting times. IM on odd hours, E on even hours.

Quote
Then to meet 2nd table which are total assignments required which contains all nurses; I add a constraint "A set of actv occupies min time slots from selectin" For ex,  E_WE_N ( all days in weekends with 0-8_E) with min occupied=8 since 8 nurse-assignments is required for that shift in weekends.

I think you need to make all activities not overlapping, and add 15 constraints activities occupy max 40*2 slots from selection, all activities, selected slots = all slots of that nurse. I am not sure I understand the requirement above, but let's start this way and see after that.

Quote
Once I tried to generate at this point, errors occured such that  "Activities occupy min time slots from selection' with the total duration of the selected activities being 2, but the number of requested minimum slots is 8, which is greater - impossible. "
Therefore, I am stucked and lost at this point:(

Thank you so much for your help.

Of course, this is wrong. See what I wrote above and try and let me know. Then, if successful (only the beginning), we'll try to add constraints.

You might want to have a look at the complex example for block planning mode for FET-6 (find it in the examples archive, open the Blocks-8-overflow_data_and_timetable.fet file, generate and see the all activities timetable as HTML).

Student in Need:)

#6
QuoteSo, 14 real days * 3 real hours per real day * 2 (IM/E) = 70 hours per day (I hope I am not mistaking). After the first real slot of IM comes the first real slot of E, then the second real slot of IM, ... . Oh, and +1, because the last E slot will have an activity with duration 2. So 71 hours per day.

Actually I did 84 thinking like 14*3*2 as you wrote above but I didn't understand your point of view in the calculations above quite well.

QuoteNo. Add each activity of IM/E for Morning or Night with duration 2 (not split) and for Full-day duration 4. Why double (2*1, and 2*2)? Because of continuity from IM to E. You don't use min days between activities, because you are using FET in an unusual way.
I did this and make all  "department_weekday/end_M" or "department_weekday/end_M" and "department_weekday/end_N" or "department_weekday/end_N" activities' duration equal to 2; and "department_weekday/end_F" or "department_weekday/end_F"  activities' duration equal to 4. So, totally 12 activities occured.

QuotePreferred starting times. IM on odd hours, E on even hours.

I did this part before using preffered time slots constraint not starting times and thought like :

For IM_WD_M activity(internal medicine-weekday-morning shift"8-16", Allowing the weekdays -days {1,2,3,4,5,8,9,10,11,12} for all nurses  such that  "Day1_8-16_IM,Day2_8-16_IM,...., Day12_8-16_IM" .
But according to your instruction quote above, I thought odd hours ass odd days and even hours as even days, and for all nurses seperately I created a preffered starting time constraint with IM odd days and E even days.

QuoteI think you need to make all activities not overlapping, and add 15 constraints activities occupy max 40*2 slots from selection, all activities, selected slots = all slots of that nurse. I am not sure I understand the requirement above, but let's start this way and see after that.

I added 15 constraints with max 80 slots for each nurse choosing all activities.


After I tried to generate the table to see whether there is an error or not and this error occured for all activity id's
"Activity with id=1 has no allowed slot - please correct that"

Am I using wrongly the "activities" part because there is something that confuse me. I am thinking how to make desired number of nurses(assignments in our case) for each shift for both weekdays and weekends for 2 departments. How can we come up 12 activities to 168 activities since we have a total of 168 assignments(slots) needed to be done according to 2nd Table(last page)  in the pdf that I upload above. We have a 84*15=1260 assignabel slots but we need to assign 168 plots??


Liviu Lalescu

Quote from: Student in Need:) on May 16, 2021, 01:41:00 AM
QuoteSo, 14 real days * 3 real hours per real day * 2 (IM/E) = 70 hours per day (I hope I am not mistaking). After the first real slot of IM comes the first real slot of E, then the second real slot of IM, ... . Oh, and +1, because the last E slot will have an activity with duration 2. So 71 hours per day.

Actually I did 84 thinking like 14*3*2 as you wrote above but I didn't understand your point of view in the calculations above quite well.

Yes, sorry, 84, not 70. +1 because the last slot must be doubled. So 85. The FET hours are the real-life time slots (days x hours).

Quote
QuoteNo. Add each activity of IM/E for Morning or Night with duration 2 (not split) and for Full-day duration 4. Why double (2*1, and 2*2)? Because of continuity from IM to E. You don't use min days between activities, because you are using FET in an unusual way.
I did this and make all  "department_weekday/end_M" or "department_weekday/end_M" and "department_weekday/end_N" or "department_weekday/end_N" activities' duration equal to 2; and "department_weekday/end_F" or "department_weekday/end_F"  activities' duration equal to 4. So, totally 12 activities occured.

Not only 12. I think 168 activities is the correct number, but you know better than me. Each activity will have a subject and one or more activity tags (activity tags just to help you). Each activity represents a nurse working 2 (M, N) or 4 (F) FET hours.

Quote
QuotePreferred starting times. IM on odd hours, E on even hours.

I did this part before using preffered time slots constraint not starting times and thought like :

For IM_WD_M activity(internal medicine-weekday-morning shift"8-16", Allowing the weekdays -days {1,2,3,4,5,8,9,10,11,12} for all nurses  such that  "Day1_8-16_IM,Day2_8-16_IM,...., Day12_8-16_IM" .
But according to your instruction quote above, I thought odd hours ass odd days and even hours as even days, and for all nurses seperately I created a preffered starting time constraint with IM odd days and E even days.

I think not. Use preferred starting times, disallow odd FET hours for endocrin and even FET hours for im.

Quote
QuoteI think you need to make all activities not overlapping, and add 15 constraints activities occupy max 40*2 slots from selection, all activities, selected slots = all slots of that nurse. I am not sure I understand the requirement above, but let's start this way and see after that.

I added 15 constraints with max 80 slots for each nurse choosing all activities.


After I tried to generate the table to see whether there is an error or not and this error occured for all activity id's
"Activity with id=1 has no allowed slot - please correct that"

Am I using wrongly the "activities" part because there is something that confuse me. I am thinking how to make desired number of nurses(assignments in our case) for each shift for both weekdays and weekends for 2 departments. How can we come up 12 activities to 168 activities since we have a total of 168 assignments(slots) needed to be done according to 2nd Table(last page)  in the pdf that I upload above. We have a 84*15=1260 assignabel slots but we need to assign 168 plots??
I attached the fet file which is with the last updated constraints up until now.

Yes, I think the total number of activities in your file should be 168, some with duration 2 and some with duration 4. And after an initial partial success, you might need to add some more dummy activities to help with the other constraints. But this will come later.

Student in Need:)

#8
Hello again Liviu  :)

I hope this day finds you well.

I have tried different things and finally I was able to get a timetable  ;D
I was not able to use what you wrote about "preferred starting times"
QuoteI think not. Use preferred starting times, disallow odd FET hours for endocrin and even FET hours for im.
and "activities with duration 2 and some with duration 4"
QuoteYes, I think the total number of activities in your file should be 168, some with duration 2 and some with duration 4.
And after an initial partial success, you might need to add some more dummy activities to help with the other constraints. But this will come later.
Also I have doubled the last slot
QuoteYes, sorry, 84, not 70. +1 because the last slot must be doubled. So 85. The FET hours are the real-life time slots (days x hours).
as you said but I didn't use it at all  :-\
>>I have created 168 activities, all with duration=1(because otherwise preffered time slots constraints created errors).
*Activities are like: 3 of "IM_M_D1" as Internal Medicine for Morning shift ,1 of "IM_F_D1"as Internal Medicine for Full shift, 2 of "IM_N_D1" as  Internal Medicine for Night shift and same for endocrine as "E_M_D1" , "E_F_D1" and "E_N_D1" for 14days.(Days in weekends has 2 activities for each department_shift pairs )

>> I have used the preffered time slots to achieve "6th,7th,8th,9th, and 10th constraints described in the pdf I uploaded. By this I achieved those constraints and I could able to put desired number of nurse in each shift.

>>After Fet created a table successfully, I have noticed that a nurse is assigned to a 2 or 3 shift for a given day which is impossible and not desired according to 3rd constraint in the pdf. I have find a solution(activities occupies max time slots from selection) but I am not sure it will work in every way and I didn't want to apply this for all nurse_day pairs since I am not sure. The plane of mine is selecting max occupied=1 with a nurse and day pair with all available activities for that day. For example, for nurse3 day5 activities (the table assigned all 3 shifts for endocrine) I selected all day5 activities and selected the slots in the intersection of day5 hoursOfDay and nurse3 with max occupied=1. This removed the problem of assigning 3 shifts for that nurse but I am not sure if I apply this logic for every day_nurse pairs with the activities of that day that there will be no error with the preffered time constraint.


Apart from above subjects I have a couple of constraints in the pdf such as 48hours off after full day shift and total of 40 working hours(5 shift assignment makes 40 hours so a nurse can have at most 5 shifts in a week??). Are these constraints possible to make on my fet design?

I have attached the final fet file.

Liviu Lalescu

Hello!  :)

I saw your file. You need to define the durations like I told you. Add preferred starting times, not preferred time slots. Durations 2 and 4 ensure that a nurse does not work IM and E same time, and duration 4 ensures a nurse does not need to be in two works at the same time.

For nurses assigned 2 or 3 shifts per day, I think you could use more (unfortunately many) constraints activities occupy max time slots from selection. For each group of activities, select the slots of each nurse, each day the 6 hours, max occupied = 4 (so that each nurse cannot work more than 2 real-life shifts), and also select with X (red, if you use colors) the first 2 slots and the last 2 slots of each day, max occupied = 2. You need to think carefully to this, because it is a large job and you should go correctly from the start with it. I advise you to create a program to write this information automatically - see the XML .fet structure and imitate it, then you can copy/paste into your XML .fet file.

Total 40 hours: maybe 15 constraints activities (all activities) occupy max slots from selection.

48 hours off after full day: add dummy activities, consecutive (constraint two activities are consecutive) with the full-day activities.