0

I am developing a scheduler which will automatically schedule employees to various departments based on departments they are allow to work in (or are trained to work in).

Let's say for example the PCworld store has four departments: Laptop, TV, Cameras, Warehouse. EmployeeN is trained to work in Laptop and Cameras.

Let's say I have to schedule 100 PCworld colleagues based on the departments they are trained to work in. I have an employee class which has a list of departments the employee is allowed to work in. I have also a department class which has each individual department criteria such as minimum employee count needed.

Let's say I have a global list of employee instances and a list of department instances. So, if I have 4 departments then I need to create 4 lists of assigned employees from the global list of employees, ensuring that the department requirements such as minimum and maximum employee counts are satisfied. I don't know if that make sense sorry guys.

What's the best ways to tackle this solution, or what's the best algorithm to use to assign employees to departments?

Thank you guys.

Geoff
  • 8,139
  • 1
  • 35
  • 46
  • 2
    This is pretty broad. Do you have a specific question about code you've written? – tnw Apr 01 '14 at 18:34
  • ok lets say I have list of employees and list of department. so if i have 4 departments then I need to create 4 list of employees from the list of employees sorted to the department requirement such as minim employees and maximum employees. I don't know if that make sense sorry guys. – user3182535 Apr 01 '14 at 18:39
  • 1
    @tnw - I reworded this to hopefully make it a bit clearer - I don't think it's too broad, and in fact is an interesting problem from an algorithmic point of view. – Geoff Apr 01 '14 at 19:49

3 Answers3

2

Surprisingly this is a well-studied, non-trivial optimisation problem - for example, there's an interesting paper on staff rostering here (PDF). One example subset of this is the Nurse Scheduling Problem.

An optimal solution would take quite a bit of work. Instead, I'd start by just hand-optimising this, for example sorting your departments by the number of applicable employees (ascending), i.e. deal with the hardest first. Then, sort your staff by the number of skills (ascending), i.e. deal with the least skilled staff first.

Then start assigning your staff one-by-one to the department list, looping until everything is satisfied or you end up with a broken solution - e.g. you run out of staff to assign to a department. Then, apply a new heuristic - for example, move the problem department up one slot in your original sort order, and start again.

From there, if an optimal solution is really important, you could research genetic algorithms, linear programming and so on - but I suspect that's really overkill in this situation. Otherwise, just keep tuning your assignment algorithm by hand.

As far as modelling the list of staff and departments, that's fairly straight-forward; you'd just use a class or struct for each staff member / department, and store them in lists. That gives you access to all the LINQ functionality, allowing you to generate sorted lists and subsets on demand. There are a ton of examples online; for one discussion (and a good reference to LINQPad), see this question.

Community
  • 1
  • 1
Geoff
  • 8,139
  • 1
  • 35
  • 46
0

if your using Linq, you could try a .contains() method.

Here is a link to a msdn page about it.

http://msdn.microsoft.com/en-us/library/bb352880(v=vs.110).aspx

You could check to see if an employeeN contains certain fields of a PCWorld.

Assuming the employee has the laptops and cameras within their class objects and so does PCWorld.

Robin Q
  • 62
  • 1
  • 8
0

In my opinion, it is more optimal to have a collection of employees on Department level, not vise versa. You can have this configured via

Dictionary<Department, List<Employee>>

or explicitly define Employee collection property in the Department type.