query for development of a rota application
how can we prepare a rota application which changes the shift so that all the employees get to work in different shifts and in the month end开发者_如何学编程 the number of shifts done by all the employees should be the same..
Any help?
Okay, if I understood correctly, the problem you want to solve is the following:
Input:: You define S
different Shifts for a Month M
, and you have E
employees.
Output:: Given the input, you have to define a schedule for each employee, that is, assign Shifts from S
to them along the month M
. When doing so, you must meet two objectives:
- All Employees get to work in different Shifts
- The total amount of Shifts assigned to each Employee must be the same
To achieve this, there are lots of possible algorithms. Off the top of my head, here's one in C-style pseudocode (you write in VB.NET):
CircularArray shifts = GetDefinedShifts();
foreach(day in Month){
foreach( employee in Employees ){
employee.Schedule.AssignShift( Month, day, shifts.Current() );
shifts.Next();
}
}
A CircularArray
goes back to the first element when you call Next
standing on the last one. However, this algorithm fails if #E == #S
: every employee gets always the same shift. So it's not that easy. But this naive algorithm can get you started thinking a better one. If I come up with something better, I'll post it.
On the other hand, why reinvent the wheel? There are open source solutions available, such as this one. And there's a list of similar software here.
精彩评论