Simple Scheduling

Wolfram is not the fastest software on the planet, neither the easiest. It’s great for prototyping ideas and the fact that it has everything in one environment is a blessing and a curse.

Scheduling and job shop problems are not straightforward (compared to, say, Google OR Tools) in Wolfram but you can do it with some constructs.
Here is an assignment problem consisting of persons with varying skills assigned to different locations. Think of cleaning staff having to be scheduled to places.
The aims is to minimize the time necessary, taking into account the constraints.

Let’s take a handful of locations, three people and assign the time necessary at each location:

Schedule_1.gif

The skills matrix : rows are people, columns are locations (1 means the person has the skill for that location):

Schedule_2.png

Next, we need decision variables which hold whether a person gets assigned to a location: assign[i, j] is 1 if person i is assigned to location j

Schedule_3.png

The set of constraints is a list which gets filled up hereafter:

Schedule_4.png

Each location must be assigned to exactly one person:

Schedule_5.png

This results in a set of linear equations:

Schedule_6.png

Schedule_7.png

Each person can only be assigned to locations for which they have the skill:

Schedule_8.png

This actually simplifies the problem since, on inspection, it reveals that various variables are zero:

Schedule_9.png

Schedule_10.png

Ensure that assignment variables are either 0 or 1 (ie. we have a Boolean variable):

Schedule_11.png

The objective function is to minimize the total workload ( total time):

Schedule_12.png

Written out this is again a linear equation:

Schedule_13.png

Schedule_14.png

The optimization now consists of:

Schedule_15.png

Schedule_16.png

Schedule_17.png

To extract the assignment results from the solution:

Schedule_18.gif

Schedule_19.png

To visualize this we need to create a concrete date. Let’s pick one a start the day at 8AM:

Schedule_20.png

Convert the intervals to time spans:

Schedule_21.png

Giving this nice visualization:

Schedule_22.png

Schedule_23.gif

Created with the Wolfram Language