Discord
@hash/genetic-programming
Simulation
2
0
Public

Genetic Programming - Employee Shifts

Genetic Programming Example

A simulation of a genetic algorithm for efficiently allocating employee work schedules.

Each agent represents a potential solution to the schedule, with 'bitfield' that contains an encoding of all the employee scheduled start and end times.

Every timestep, solutions calculate their fitness scores and share them with a manager agent. The manager agent selects the fittest agent and preserves that for the next timestep. The agents evolve new solutions through mutate.py and crossover.py, which introduce random new elements into the bitfield and mix and match among the bitfield, respectively.

Globals

"p": probability of a mutation for an element in a bitstring. "population": Number of solution candidates. "mutate_every_bit": If true, every bit potentially mutates, else only one potentially mutates. "employees": { "costs": array of costs for employees. Lower is fitter. "max_shift_length": Maximum amount of time an employee can be on a shift. }, "demand": Array of demand integers; higher demand == more valuable to have employees during that shift.

Visualization

Whenenver the manager agent determines the current best solution, it also generates a visualization of the corresponding employee schedule. Each employees is represented by a different color bar, which extends from the start to the end time of its shift.