Optimizing Your Time Off: A PTO Planner Built on CP-SAT
I built a web app that treats vacation planning as a constrained optimization problem. CP-SAT sweeps a Pareto frontier over vacation-block counts and hands back three strategies to pick from.
Every January I stare at a calendar trying to figure out where to put my PTO days, bridge this holiday, or save the days for a long trip. It's a combinatorial problem, so I did what any optimization person would do: formulated it and let a solver decide. The result is a free web app, live at pto.christopherrobertwhite.com.
The formulation
Each workday in the year gets a binary decision variable: PTO or not. Weekends, public holidays, and company days off are fixed "off" days. The solver (Google OR-Tools CP-SAT) maximizes a weighted objective built around adjacency, since consecutive off-days are worth more than scattered ones, with bonuses for leveraging holidays, taking full weeks off, and traveling in cheap windows. Hard constraints cover the PTO budget, locked and blackout dates, monthly caps, and max consecutive days.
The part I had the most fun with is the parametric sweep. The number of vacation blocks K is an exact constraint, and the app solves the model for every K from 3 to 15. That traces a Pareto frontier, and three strategies get picked off of it:
- Long Weekends (K=15): many short 3-4 day breaks, bridging every holiday
- Balanced (K=7): picked at the knee of the frontier, holiday bridges plus a couple of full weeks
- Deep Rest (K=3): a few extended 9-11 day vacations in optimal travel windows
Details I enjoyed building
You can drag-to-reorder the holidays you care about, and ranked holidays get steeply higher solver bonuses. Thanksgiving with family always makes the plan, even when it isn't the mathematically cheapest choice. A daily travel cost index, built from BLS airline-fare CPI seasonality plus holiday-week premiums, nudges the solver toward off-peak vacation windows (about 5% of the objective), and each vacation block gets a Low/Average/High/Peak cost rating in the UI. Solver objective values don't mean much to people, though, so every plan also gets re-scored on six interpretable 0-100 dimensions: holiday leverage, block quality, efficiency (total days off per PTO day spent), spread, work realism, and coverage.
Stack
Python • OR-Tools CP-SAT • FastAPI • Pandas • React • Vite • Tailwind • Docker • Caddy
Try it
Pick your country (15+ supported, holidays auto-detected), enter your PTO budget, and get three optimized calendars: pto.christopherrobertwhite.com.
Related
How Much Should You Order? A Stochastic Optimization Demo You Can Play With
I built a web app that solves a textbook inventory problem in a non-textbook way: it optimizes a reorder policy over thousands of simulated demand futures instead of one forecast.
Building a Dual-Hop VPN with Terraform and V2Ray
Ahead of a trip where I knew everyday tools would be blocked, I built a multi-hop VPN from scratch with Terraform, Docker, V2Ray, and Nginx, and recently open-sourced it.