← Portfolio All Demos
Operations Research • CP-SAT
Jump to Solver ↓
Google OR-Tools • Constraint Programming Python CP-SAT Engine

Multi-Location Shift & Constraint Optimizer

A mathematical constraint optimization solver formulated in Python using Google OR-Tools CP-SAT. Solves globally optimal weekly staff schedules across 8 retail branches and 12+ employees in under 2 seconds, honoring strict labor law constraints, mandatory rest periods, and shift fairness.

⚡

Interactive Sandbox · 100% Mock Data

Simulates the exact production CP-SAT optimization logic using mock store locations and staff profiles. Production database write access is isolated for data protection.

CP

Boba Cafe · OR-Tools Shift Optimizer v2.4 CP-SAT

Streamlit / Python Simulation Environment

Week: Oct 19 – Oct 25, 2026

Coverage

100%

56 / 56 shifts filled

Feasibility

OPTIMAL

0 Hard Conflicts

Avg Hours/Staff

33.5 h

0 Overtime Hours

Solve Duration

1.42 s

2,016 Boolean Vars

CP-SAT Solver Execution Stream Ready
[0.00s] OR-Tools CP-SAT Solver v9.8 initialized.
[0.15s] Loaded 12 staff profiles across 8 retail store branches.
[0.32s] Formulated 2,016 decision variables: X[employee, store, day, shift].
[0.65s] Enforced strict 12h rest interval constraints <= 0 violations.
[1.02s] Enforced 40h weekly cap. Soft fairness penalty minimized.
[1.42s] STATUS: OPTIMAL | Objective Value: 34.0 | Feasible: 100%
Branch Location Mon Tue Wed Thu Fri Sat Sun Hrs
Morning (08:00 - 16:00) Mid-Day (11:00 - 19:00) Evening (14:00 - 22:00) Rest Day
All 12-hour rest constraints satisfied

Hard Constraints (Strict Feasibility)

The solver rejects any candidate schedule violating even one hard constraint, guaranteeing legal compliance and complete physical coverage.

  • •
    Store Coverage Demand:

    Exactly 2 baristas present for morning prep, 3 staff during peak midday rush, and 2 staff for closing reconciliation.

  • •
    Mandatory Rest Interval:

    Strict minimum of 12 continuous rest hours between shifts. A barista finishing an evening shift at 22:00 cannot open at 08:00.

  • •
    Weekly Maximum Hours Cap:

    Absolute cap at 40 hours per week per employee, eliminating unwanted overtime expenses and labor law penalties.

  • •
    Single Branch Assignment:

    No employee can be assigned to multiple branches or conflicting overlapping slots on the same calendar day.

Objective Function & Fairness Optimization

Soft constraints guide the solver toward the highest quality, most equitable schedule through weighted penalty minimization.

  • •
    Weekend Fairness Balancing:

    Minimizes the variance of Saturday and Sunday shifts across staff, ensuring no team member is disproportionately scheduled on weekends.

  • •
    Commute Distance Minimization:

    Weights staff-to-branch residential zones so employees are assigned to the closest available retail locations.

  • •
    Availability & PTO Respect:

    Applies heavy reward bonuses for honoring voluntary shift preferences and pre-approved time-off requests.

  • •
    Rapid Tree Traversal:

    Google OR-Tools boolean satisfiability tree search finds provably optimal schedule solutions in < 2 seconds.

Production Operations Impact

< 2 sec

Average Solve Time

30+ hrs

Manager Time Saved / Mo

8

Retail Stores Solved

100%

Labor Law Compliance

← Return to David Gao's Portfolio Explore All Interactive Engineering Demos →