Recipe
Translate a word problem into an optimization model
Use when: you're given a paragraph describing a real decision, with no equations or inequalities written yet
Goal: a complete model -- decision variables with units, an objective function, and a full constraint list -- ready to classify and solve
Quick recipe
-
1
Read the whole problem once. Identify what kinds of things it's about — products, locations, time periods, people.
Example
"A bakery bakes loaves and bagels" names one set: {loaves, bagels}, the products the bakery makes.
Why: naming the categories first keeps the variables you define next organized around real, distinct choices instead of one tangled quantity.
-
2
Pull out every number in the problem that's already fixed — a cost, a capacity, a price, a supply on hand — and label what each one measures.
Example
"Oven time available: 8 hours" and "ingredient budget: $30" are both parameters — the bakery didn't choose either number, they're facts of the situation.
Why: a parameter and a variable are easy to mix up mid-paragraph; separating them explicitly before writing any algebra prevents that confusion from ever reaching the equations.
-
3
For each set item the solver actually chooses about, name a variable and state exactly what it counts, including its units.
Example
Let x = loaves of bread baked today, y = dozens of bagels baked today.
- every variable is continuous — this stays an LP or NLP.
- any variable must be a whole number or a yes/no choice — the model is an IP or MINLP instead (Section 5).
Why: "let x = bread" leaves it ambiguous whether x counts loaves, dollars, or pounds of flour — a variable definition that doesn't name units isn't finished.
-
4
State, in one sentence, what single quantity the problem wants maximized or minimized, then write it as a function of the variables just defined.
Example
"Maximize total profit" becomes f(x,y) = 1.5x + 2y, using 1.50 profit per loaf and 2.00 profit per dozen bagels.
Why: the objective has to be a function of variables you've already named — writing it first, before the variables exist, is what produces an objective nobody can actually evaluate.
-
5
Translate every stated limit into an equation or inequality in the same variables, watching for "at least" versus "at most," and never forgetting the ordinary nonnegativity constraints.
Example
"At most 8 oven-hours" becomes 0.3x + 0.2y \le 8; "at most 30 for ingredients" becomes 0.8x + 1.2y \le 30; and x, y \ge 0$ always belongs on the list unless the problem says otherwise.
Why: an objective function with no constraint list attached describes an unconstrained problem, which is rarely what the real situation actually means.
Common mistakes
- Writing the objective before the variables are defined, then discovering the objective needs a variable that was never named.
- Dropping x, y \ge 0 because it "seemed obvious" — an omitted nonnegativity constraint can let a solver return a nonsensical negative quantity.
- Translating "at least" as \le instead of \ge, or the reverse.
- Treating a parameter (a given cost or capacity) as if it were a variable the model gets to choose.