# Nurse scheduling problem

• ### Question

• I have a 6 employee

I have  4 shifts Early(E) Late(L) Night(N) Off(O)

For each day 2 Early 2 Late One night  it means in each day there is (EELLN)

Each employee should have one day off in the week

Is Microsoft Solver Foundation can solve that schedule and can generate it?

how can i build the model and the constraint ?

Is there an example of visual studio employee generating shift sample vb.net or c# ?

Monday, January 9, 2017 7:54 AM

### All replies

• Hi,

If they work five days in one week, how do they take two "Off" days in the week?
Does "Off" come next to "Night" automatically? or Do they change it as they like?

Regards,
Ashidacchi
• Edited by Monday, January 9, 2017 8:11 AM
• Proposed as answer by Monday, January 9, 2017 9:18 AM
Monday, January 9, 2017 8:10 AM
• They toke one day OFF

Something like this table

 1/1 2/1 3/1 4/1 5/1 6/1 7/1 EELLN EELLN EELLN EELLN EELLN EELLN EELLN EMP0 E E E L L L EMP1 E E E L L N EMP2 L L L L N N EMP3 L L L N L E EMP4 N N N E E E EMP5 E E E E L

Monday, January 9, 2017 9:13 AM
• Hi,

How should I take account of holidays and non-consultation days?

Regards,
Ashidacchi
Tuesday, January 10, 2017 3:04 AM
• I'm trying to make things simple to understand the solver.and after understanding it i will add other constraints

like holidays and non-consultion days.

if you can build that model or any complex model in vb.net or c# depending on Microsoft solver foundation can you please post it for me or send it to me

I need things to be simple  and the solver generate the  shift

Tuesday, January 10, 2017 5:54 AM
• I'm thinking about schedule with Excel VBA.
If it would satisfy your need, I could make it with VB.NET.

Is it "MUST" to use Microsoft Solver Foundation?
Tuesday, January 10, 2017 7:02 AM
• What i'm trying to do is to understand the Microsoft Solver Foundation by using this example . and then extending it with more constrains and more employees that what i want to

this is a linear  programming

http://softwareengineering.stackexchange.com/questions/246099/is-microsoft-solver-capable-of-solving-such-complex-scheduling-problems?rq=1

also  java have a solver optaplanner see it

http://docs.jboss.org/drools/release/6.0.0.Beta3/optaplanner-docs/html_single/#nurseRostering

--------------------------------------------------------------------------------------------------------------

Tuesday, January 10, 2017 8:19 AM
• Hi,

In advance, sorry I can't(won't) use the Microsoft Solver Foundation.

Now, I've shared my sample (Excel with VBA) via Dropbox.
Excel NurseSchedule.xlsm

(VBA does not work with cloud)

That's all what I can do and understand.

Regards,
Ashidacchi
• Edited by Tuesday, January 10, 2017 8:48 AM
Tuesday, January 10, 2017 8:47 AM
• can you explain to me the vba code and what do u mean by dummy
Tuesday, January 10, 2017 9:59 AM
• Hi,

```Select Case row
Case Is = 21 ' -- Employee 1
Cells(21, col).Value = Cells(row + 1, col - 1).Value
Case Is = 22 ' -- Empoyee 2
Cells(22, col).Value = Cells(row + 1, col - 1).Value
(... snip ...)
Case Is = 27 ' -- dummy
Cells(27, col).Value = Cells(21, col).Value
End Select```
Case is = 21--26:  "row + 1" is used.
If dummy row(27) does not exist, "row + 1" does not work as I expect. So I use dummy row(27).

# If there does not exception(e.g. holidays in calendar), I suppose, creating schedule would be simple like my code. So, I asked about it before...
How should I take account of holidays and non-consultation days?

# I hope you will answer my questions straightforward.

Regards,
Ashidacchi
Tuesday, January 10, 2017 10:10 AM
• if dummy pattern is off then it will produce wrong schedule

thank you

Tuesday, January 10, 2017 10:26 AM
• How should I take account of holidays and non-consultation days?

Maybe we can fix them manual

or putting them in the calendar from the beginning

Tuesday, January 10, 2017 10:39 AM
• 1. Is it "MUST" to use Microsoft Solver Foundation?

2. If you put holiday in the calendar, can I think the day does not exist, i.e. each employee's schedule will continue from the previous working day (excluding the holiday)?
• Edited by Tuesday, January 10, 2017 10:50 AM
Tuesday, January 10, 2017 10:49 AM
• We can not using it at all

i was trying to understand Microsoft Solver Foundation because it has a lot of things

assume we need to have 2 days off and the employee should have them consecutive

Yes you can think the day does not exist

Tuesday, January 10, 2017 11:07 AM
• Hi Ashidacchi,

Excel nurseSchedule.xlsm is not available in the folder.

Am trying to design a solution for the nurses who have different shift patterns. For e.g

1) ( 2 days Ons, 2 days offs, 3 days Ons, 2 days offs, 2 days Ons, 3 days Offs). Pattern repeats after 2 weeks.

Regards

Rakesh Dighe

Thursday, November 22, 2018 2:48 PM
• Hi Rakesh Dighe,