A break scheduling algorithm based on the principle of „least frequent break pattern”

Break matrix

Let’s have N pause patterns (substantially different from each other). For simplicity, assign colours to each pattern (red, blue, yellow, green…)

We want to determine the colour of a new shift beam without a break, so that the k beams in this group already have a colour. The control principle is: the color of the new beam should be the least frequent color in the time interval of the beam. To do this, we consider the parts of the other already coloured beams (which can be the whole beam if they have a common start) that fall within the time interval of the new beam to be coloured (between the start and the end). We count the number of time-atoms (e.g. 10 minutes) and the colour of the time-atoms represented. These are summed up by colour and the colour with the smallest sum total becomes the new colour to be searched for. If there are more than one of these (this can happen especially at the beginning of the schedule), a random number generator is used to draw the colour we are looking for. This is useful for diversifying lunch times. So, for example, if the breaks on the first beam are from 10-20 every hour, the second beam should not necessarily be the 20-30 pattern, but could be the 40-50 pattern for example!

The long or “lunch break” time is defined as follows:

A time may be specified separately for the morning/lunch shifts, the “nearest” short break to which is extended by extending the end time. The closest short break shall not be the first or last break of the shift. The selector time for the morning-afternoon shift grouping and the corresponding long break mean time may be specified per rule type.

The JavaScript function to be developed shall receive the start, length and colour of the already scheduled beams of the break group, and the start and length of the new beam to be scheduled. The function returns the color of the new beam.