Three Bugs That Would Have Stayed Hidden in Excel

When you convert an optimization model from Excel to standalone Python, you expect to do some work. You expect to rewrite the data loading, restructure the variable definitions, test the output. What you don’t expect is for the model to fail in three distinct ways, each one caused by something the Excel version was handling silently without you knowing it.

Handling PuLP solver errors in a Python optimization model

That’s what happened here. Three bugs. All real. All the kind that would have stayed invisible forever if the model had stayed in the spreadsheet.

Continue reading “Three Bugs That Would Have Stayed Hidden in Excel”

PuLP, MILP, and CBC: The Alphabet Soup Behind Your Schedule

PuLP is a Python library for writing optimization models. MILP stands for Mixed Integer Linear Program. CBC is an open-source solver. Together, they’re what makes the Staff Scheduler work — and together, they represent something I find genuinely interesting: the fact that problems that used to require expensive commercial software and specialized hardware can now be solved on a laptop, for free, in a few seconds.

PuLP, MILP and CBC working together in a Python optimization model

Let me explain what’s actually happening under the hood.

Continue reading “PuLP, MILP, and CBC: The Alphabet Soup Behind Your Schedule”

How I Solved the Shortest Superstring Problem in Excel

A while back I wrote an introduction to the shortest superstring problem and promised two follow-ups: one showing the greedy algorithm I wrote in VBA, and another showing how I bolted optimization on top to do better than greedy alone. Then I did what I usually do with “future work” and let it sit. Here, finally, is that follow-up — the whole thing in one post, because this is really the story of how I solved the shortest superstring problem in Excel with two stages of the same machine: a VBA pass that generates candidates, and an optimization model that picks the best of them.

Continue reading “How I Solved the Shortest Superstring Problem in Excel”

Hall’s Marriage Theorem Meets the DraftKings Entry Form

This is the last post in my accidental Fourier-Motzkin trilogy (part one: the method; part two: the baseball lineups), and it’s about the bill coming due. Because when you use elimination to throw variables out of a model, the mathematics is very clear about what you keep — and very quiet about what you lose. I found out exactly what I’d lost the first time DraftKings rejected a lineup my spreadsheet swore was legal. The story runs straight through a beautiful piece of combinatorics called Hall’s marriage theorem, so we’ll pick that up along the way.

Continue reading “Hall’s Marriage Theorem Meets the DraftKings Entry Form”

A Fourier-Motzkin Elimination Example: DraftKings Lineups

In my last post about Fourier-Motzkin elimination I promised a real example involving baseball, and I keep my promises. This is the story of how a dusty 19th-century math trick ended up picking my daily fantasy lineups — and how I stumbled into a genuine Fourier-Motzkin elimination example without fully realizing that’s what I was doing until much later.

Continue reading “A Fourier-Motzkin Elimination Example: DraftKings Lineups”