This repo contains a code to build schedules for a set of agents under linear constraints, following our paper. We recommend reading it before running the code. The project revolves aroung the Integer Linear Programming (ILP) optimization problem formalism. The problem is solved using the PuLP library.
The script is primarily intended to design schedules for a hospital service under a list of its specific constraints, but can be adapted for any similar problem. The parameters and constraints provided correspond to a real-life case in a French hospital's service. It enabled to ensure the compliance of the computed solutions with the expectations of the service's management.
Two sets of agents are dealt with in the repo:
- nurses (refered to with the "inf" suffix in filenames, standing for "infirmier" in French)
- caregivers (refered to with the "as" suffix in filenames, standing for "aide-soignant" in French)
The output .xlsx file should look like the following screenshot:

scheduler_core.py: Abstract base class for schedule optimizationnurse_scheduler.py/caregiver_scheduler.py: Agent-specific scheduler implementationsconfig_manager.py: Configuration management for different agent typesexcel_export.py: OpenPyXL functions to generate the output.xlsxschedule filesobjectives.py: PuLP objective functions for optimization criteria
script_inf.py/script_as.py: Original scripts to build nurse/caregiver schedulesparameters/parametres_inf.py/parameters/parametres_as.py: Parameter files for the original scripts
streamlit_app.py: Streamlit web interface for easy schedulingstart_streamlit.sh: Startup script for the web interface.streamlit/config.toml: Streamlit configuration
output/nurses_schedule.xlsx/output/caregivers_schedule.xlsx: Example output schedules
Pandas, OpenPyXL, PuLP and Streamlit.
uv syncpip install -r requirements.txtFor the easiest experience, use the Streamlit web interface:
# Quick start
./start_streamlit.sh
# Or manually
source .venv/bin/activate
streamlit run streamlit_app.pyThen open your browser to http://localhost:8501
# Schedule nurses
python schedule_nurses.py
# Schedule caregivers
python schedule_caregivers.py
# Schedule both
python unified_scheduler.pyTo run the original code and generate a nurse schedule, fill the parameters/parametres_inf.py file and run:
python script_inf.pyThe logs will indicate if the problem was successfully resolved (logs will display Optimal solution) or if it failed (logs will display Infeasible).
If the program is successful, the resulting .xlsx file will be stored in the output folder.
This code is made available for use under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). You may obtain a copy of the License at: https://creativecommons.org/licenses/by-nc-sa/4.0/.
If you use this work, consider citing our paper available on ResearchGate: :
@misc{https://doi.org/10.13140/rg.2.2.28819.90405,
doi = {10.13140/RG.2.2.28819.90405},
url = {https://rgdoi.net/10.13140/RG.2.2.28819.90405},
author = {Chirol, Louis and Zeroual, Jad},
language = {en},
title = {Using fairness as a constraint in the Nurse scheduling problem (NSP): the case of a French hospital},
publisher = {Unpublished},
year = {2024}
}