When Natural Variables Are Not Enough: Teaching Integer Programming with Sudoku
Abstract
Sudoku is a compact and familiar setting for teaching a surprisingly deep lesson in integer linear programming, namely that the most natural decision variables are not always enough to produce an effective or convenient linear model. This paper compares two formulations of Sudoku. The first uses binary assignment variables indicating whether a particular digit is assigned to a particular cell. This formulation is less natural from the perspective of the puzzle board itself, but it encodes the puzzle rules through simple assignment constraints and extends easily to variants such as Killer Sudoku. The second formulation uses the more natural approach of assigning one integer variable to represent the value in each cell, but then the central requirement is that the values in each row, column, and block must be all different. When this all-different requirement must be expressed using linear constraints while retaining the cell-value variables, the formulation becomes a large collection of pairwise disjunctions linearised by big-M inequalities. The paper includes AMPL code for both the assignment model and the natural all-different model, and derives a second integer program for certifying uniqueness. The paper also uses generalised Sudoku as a careful entry point to computational complexity, while emphasising that the standard nine-by-nine puzzle is not itself an asymptotic problem class.
Turn this paper into a full lesson
ArcXiv compiles a staged curriculum from this paper: 8-12 lessons across beginner → advanced, synthesised section guides, visuals, flashcards, a quiz, exercises, and on-demand deep dives per section. Grounded in the abstract, never invented.