A work in progress python utility for solving the congregational duty scheduling constraint problem
-
Once csvs are updated with your information, you may run this program to create a schedule that optimizes for fairly scheduling people to tasks. Fairness here means that the average assignment frequency difference between men signed up for a particular task is minimized across all people and tasks.
-
Before exiting, the program will start a webapp where the schedule can be edited in place (drag-and-drop names, edit names) for any manual tweaks that need to be made.
-
From the webapp, a reveal-on-hover control menu in the upper left hand corner of the screen provides a 'Download PDF' button and a 'Commit' button.
-
'Commit' will save the current schedule to persistent csv file-store which will be used for the next non-year-month matching schedule generation.
Conda is used for managing the environment/packages needed to run the library that solves the scheduling constraint problem (PuLP).
-
I installed the anaconda distribution found here
-
Once installed (
$ conda
) shows output, and you are in the base environment ($ conda activate base
) we need to create the custom environment we will use to install packages needed to run this application. Do so with:
$ conda env create -f environment.yml
- If needed, activate this new environment
$ conda activate roster
- Make
run.py
executable:chmod u+x run.py
- Run
$ ./run.py <month number> <year> <path/to/pdf/file> <path/to/optional/history/csv/file>
For example
./run.py 11 2024 /Users/Desktop/congregation-roster/roster-11-2024.pdf previous-assignments-test.csv
-
prefs.csv
: contains all men available for duty scheduling in the first column, the other columns are the duties to be scheduled for, cell values of a1
indicate that that man may be assigned a task -
exclusions.csv
: this file is an adjacency matrix of duties. If a cell value contains a 1, this indicates this duty should not be assigned to the same man. -
duty-codes.csv
: this file contains 'codes' for each duty. These codes will be referenced to determine what days or weeks a duty should be scheduled for. A future code may be for gospel meeting duty scheduling. Codes may be 1 of the following- a number between 0 and 6: represents the day of the week the duty is to be performed (0 for Sunday, 3 for Wednesday, etc.)
- 'w': a weekly duty
- 'm': a monthly duty
-
duty-names.csv
: this file is a mapping of the duty "id" to a human-readable name we'll use on the schedule -
previous-assignments.csv
: you will not see this file until you run the script the first time without a command-line override. This file contains the historical assignment frequencies for everyone. This is the script's persistent datastore. This file doesn't make since to be checked into this project.
Jupyter has a nice interface for viewing csvs, or you can export into excel or google sheets.
This solver was initially developed using jupyter, it is still possible to do so but any changes made to the logic that need to be persisted in the script will need to be manually copied back into solver.py. It is still a nice way of seeing intermediate output and testing python snippets.
- Install Anaconda Navigator
- Open a Jupyter Lab instance from Anaconda Navigator
- Navigate to the congregation-roster project directory in Jupyter Lab