Skip to content

yan-sln/sat-planning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

SAT-based Staff Scheduling

This project implements a constraint-based staff scheduling system using a SAT solver.
It generates and transforms work schedules for 20 people across multiple weeks, under strict rules of work distribution and rest.


Features

  • SAT formulation of the scheduling problem:
    • 20 people assigned to stations over 14 days per week.
    • Different numbers of daytime and nighttime stations.
    • Constraints on workload, rest, and distribution.
  • Exportable schedule:
    • planning_table.csv: station-based assignments.
    • planning_par_personne.csv: person-based assignments with statistics.
  • Transformations & Statistics:
    • Number of days, nights, and Sundays worked per person.
    • Easy-to-read pivot table (per person × per day).

Constraints

The schedule must satisfy:

  1. Each station is occupied by exactly one person.
  2. A person cannot be assigned to more than one station per day/night.
  3. Maximum 4 worked days among days 1–6.
  4. Minimum 2 worked days among days 1–6.
  5. Maximum 3 assignments between Sunday (day 7) and nights (days 8–14).
  6. Minimum 1 assignment between Sunday (day 7) and nights (days 8–14).
  7. Mandatory rest: if a person works a night, they cannot work the following day.

Project Structure

.
├── planning\_sat.py              # SAT encoding and solving
├── planning\_transformer.py      # Transform station-based to person-based planning
├── planning\_table.csv           # Example output (station-based)
├── planning\_par\_personne.csv   # Example output (person-based with stats)
└── README.md                     # Project documentation


Dependencies

  • PySAT – SAT encoding and solving
  • pandas – data manipulation
  • itertools – combinatorial generation (standard library)
  • re, string, csv – standard Python libraries

Usage

1. Generate a schedule with SAT solver

python planning_sat.py

This creates the file:

  • planning_table.csv → schedule organized by station.

2. Transform into person-based planning

python planning_transformer.py

This creates:

  • planning_par_personne.csv → schedule organized by person, with workload stats.

Example Output

Station-based (planning_table.csv)

station S1_day1 S1_night1 ...
CD1 A ...
CD2 B ...
... ... ... ...

Person-based (planning_par_personne.csv)

person S1 - Monday - day S1 - Monday - night ... nb_jours nb_dimanche_jour nb_nuits
A CD1 ... 3 1 2
B CD2 ... 4 0 1

TODO

  • Add option for a free week
  • Separate Sunday and night constraints
  • Refactor into OOP (object-oriented design)
  • GUI interface for easier usage
  • Better error handling and file management

About

This project implements a constraint-based staff scheduling system using a SAT solver. It generates and transforms work schedules for 20 people across multiple weeks, under strict rules of work distribution and rest.

Resources

Stars

Watchers

Forks

Contributors

Languages