3
votes

I have a problem creating 3-shift scheduling for my application that run on top of .Net C#.

To define the problem we need to determine the shift and the number of employee/s(eN).

Now the client has only 3 default shift which are:

  1. Morning - 8:00am to 4:00pm
  2. Swing - 4:00pm to 12:00am
  3. Graveyard - 12:00am to 8:00am

And their total of employee is LEAST 7 employees

Now how can i accommodate all employees in a week or 7 days with a balance shift personnel each day regardless of employee numbers and each should shuffle when every time one employee has a day-off. And I would like that every employee should have a day-off per week.

To clarify the problem here is my illustration:

In this case we will have a 7 Employees in each day for the whole week. Employee should shuffle whenever one employee is day-off to balance healthy shifting process.

DAY 1 - 7
---------------------------
Morning     |  2 Employees
Swing       |  2 Employees
Graveyard   |  2 Employees
Day-Off     |  1 Employee

Another example:

Now we will have 8 Employees. To balance the shift personnel i would like to do this pattern:

DAY 1
---------------------------
Morning     |  3 Employees
Swing       |  2 Employees
Graveyard   |  2 Employees
Day-Off     |  1 Employee

DAY 2
---------------------------
Morning     |  2 Employees
Swing       |  2 Employees
Graveyard   |  3 Employees
Day-Off     |  1 Employee

DAY 3
---------------------------
Morning     |  2 Employees
Swing       |  3 Employees
Graveyard   |  2 Employees
Day-Off     |  1 Employee

DAY 4
---------------------------
Morning     |  2 Employees
Swing       |  2 Employees
Graveyard   |  2 Employees
Day-Off     |  2 Employee

DAY 5
---------------------------
Morning     |  2 Employees
Swing       |  3 Employees
Graveyard   |  2 Employees
Day-Off     |  1 Employee

DAY 6
---------------------------
Morning     |  3 Employees
Swing       |  2 Employees
Graveyard   |  2 Employees
Day-Off     |  1 Employee

DAY 7
---------------------------
Morning     |  2 Employees
Swing       |  2 Employees
Graveyard   |  3 Employees
Day-Off     |  1 Employee

But the system must not only limited to 7 or 8 employee it should be dynamic in accommodating regardless of the number of employeee.

Here is a logical sequence of shifts:

            Morning   |   Swing   | Graveyard   |   Day-Off
Morning        ✔                                      ✔
Swing          ✔           ✔                         ✔
Graveyard      ✔           ✔           ✔             ✔
Day-Off        ✔           ✔           ✔              

NOTE: I don't ask for code for to create such a pattern, I would like you to help me comes up with a solution or dynamic helpful pattern that will help me solve this one.

I googled and search every scheduling site but it doesn't provide necessary idea or answer.'

Your HELP is highly appreciated.

3
And I would like that every employee should have a day-off per week. -> that will leave you with 0 employees. Last time I did that we did blocks of 9 days work (3x3 every shift, on handover days with only 8 hours break) followed by 6 days off ;) - TomTom
@TomTom not i think because when 1 employee is day off the other employee should replace that shift to balance employee personnel. - Roel
You make serious mistakes here. 1: Most people have rights for more days off. Particularly when doing shift work 2: People have holidays. 3: People get sick. You can not run that with no reserves. - TomTom
aside from no. 1 let us set aside the other factor of days such as holidays, vacation, sickness or absent. For now let us focus on personnel balance without any such given days. It is not possible to work with it sir? - Roel
Good. Then here is a tip: Do not go for a 7 day roster. Go for a much longer schedule. We went 9/6 for a reason. After 3 such revolutions you start again at the beginning. Unless you want surreal scheduling (people working 2 shifts back to back etc.) you need more than 7 days to make it sensible in a repetitive way. - TomTom

3 Answers

1
votes

When I worked close with an OPS team they had a simple pattern, but they done scheduling manually. How they worked was:

Employee 1: 
  Week 1: Morning
  Week 2: Swing
  Week 3: Graveyard

Employee 2:
  Week 1:  Morning
  Week 2:  Graveyard
  Week 3:  Swing

This meant that employees did not work with somebody 2 consecutive weeks, and had a fixed pattern.

In our case it was more complex as they worked 5 days and then had 2 days off, except night shift/graveyard which worked 4 days (due to extra time required to recover, extra fatigue, and after working graveyard you can't work until the next day (so graveyard to swing or morning meant that you had an extra day).

What ever your shift pattern there will be a minimum number of people you need and a maximum. After the max, people end up with more time off. Then you need to consider other factors such as illness, holidays etc.

In our case what we done was that we had extra people to cover these factors. So that the Swing & Graveyard had a max number of people (2 people) and any 'left over' were put onto the day shift, as in our case there was more work during the day so more than 2 people were needed anyway.

So you would need to decide what happens if you have more than the max number of employees, or you have illness, holidays etc. (A question to the business)

My suggestion would be to work out your min and max numbers for your shift pattern, then map it out on pen and paper (or excel!), then add extra people and see how to schedule them. Then once you know this then you have your model and can code it.

You might also need a way to override this manually, so for example change employee1 to employee7 in case of illness. Then you have the nightmare of rescheduling, to determine what impact this has.

If I map this into Excel, using 8 employees then I get the following;

Schedule

Here, I have highlighted "Fred" and you can see the pattern as he goes through the weeks. But, for every employee over your minimum (7) then you end up with more days off and a long pattern. E.g. 9 people = 3 people off and a 9 week pattern.

In the end, you you know the business rules that have to be applied such as amount of time between shifts, days off per week, what to do in case of illness, holiday etc.

You could of course adjust this to be a 6 day week or a 5 day week as needed. And rather than giving people a whole week off, then on these weeks they are 'extra' resources assign to the day shift.

1
votes

Here is some of my thinking, hope helpful.

Configuration

  1. Configuration of the 7 day roster

Scheduling

  1. Consider a round of assignment is for a week
  2. Be aware of annual leave application and public/company holiday
  3. Get the how many employee-shift of each employee should have with a week

    Employee Shift
    A        6
    B        7
    ...
    
    • For full time employee, it may be 6 employee-shift one week
    • For part time employee, it may be 4 employee-shift one week
    • It may be a configuration of employee information
    • Say for a full time employee, if there is a public holiday with the week 5 employee-shift (6-1) of this employee
    • And if he apply one day annual leave, then 4 employee-shift (5-1) of this employee
  4. Employee can apply fixed leave/shift (pre scheduling)

  5. For other free slots of shift and free employee-shift, use a fair way to schedule. At that time, you can consider a table like that:

    Shift      Mon      Tue    Wed        Thu      ...
    Shift 1    ?        ?      ?          ?(Not B as AL)
    Shift 2    ?        ?      B(Fixed)   ?(Not B as AL)
    Shift 3    ?        ?      ?          ?(Not B as AL)
    Dayoff     A(Fixed) ?      ?          ?(Not B as AL)
    
    • Consider day by day to fill up the slot
    • Each assign of slot will affect next assign as (employee-shift), (available employee of that day) and (score) changed.
  6. Manage a score of each employee being assigned to each shift during a period of time (e.g. each month).

    Employee   Shift      Count
    A          Morning    10
    A          Swing      3
    A          Graveyard  5
    B          Morning    2
    B          Swing      2
    B          Graveyard  0 (selected)
    ...
    
  7. Assigning the slots of a shift based on the score scheme.

  8. Prevent Graveyard and next date Morning situation by considering the logical sequence. Filter the avaliable candidate for assigning, and based by the score.
  9. For unassign employee-shift after a round of assignment, assign them to some other time slot random or by other rule

Other consideration

  1. Consider number of avaliable employee fewer than the employee need of a date in the configuration
1
votes

Becasue its only 15 employes I would use brute force. Try every posibility in some nice loops for every employe. Evaluate every possiblity. If you find the first true in your evaluation step skip and take this sheduling. If you reach the end, you got a problem because its imposible to find a scheduler.
During the evalutation step of each possilbe scheduling you need to check if for every person every condition is meet. This can be none polynomic in calculation. But for only 15 person it should take no time for the PC.