Week 5 · 2105623 Optimization of Chemical Processes
7 September 2026
The shape of today
| Time | Block | Duration |
|---|---|---|
| 0:00 – 0:10 | Opening: recap of Week 4, one question from HW1, today’s objectives | 10 min |
| 0:10 – 0:40 | Lecture 1: binaries as modeling devices, logic as linear constraints | 30 min |
| 0:40 – 1:00 | Activity 1: logic to linear, board race (pairs, paper) | 20 min |
| 1:00 – 1:30 | Lecture 2: big-M, how to choose it, and its two failures | 30 min |
| 1:30 – 1:45 | Break | 15 min |
| 1:45 – 2:10 | Activity 2: big-M roulette (computer, groups of 3 to 4) | 25 min |
| 2:10 – 2:35 | Lecture 3: convex hull versus big-M, formulation strength | 25 min |
| 2:35 – 2:55 | Activity 3: tighten it (groups of 3 to 4) | 20 min |
| 2:55 – 3:00 | Wrap-up, takeaways, what is due next week | 5 min |
Bring: the notebook w05-modeling4-logical-discrete.ipynb, the workbook w05-fixed-charge.xlsx, OpenSolver with the CBC engine, and one sheet of paper per pair. The three activities are written out in full on w05-activity-sheet.pdf.
Learning objectives
CLO 1 (formulation) and CLO 4 (implementation and solution). Reference: Williams, Ch. 9 and 10; Rao, Ch. 10.
Weeks 2 to 4
This week
The scope boundary
This week is about formulating discrete decisions, and about how the formulation changes the linear relaxation.
How a solver searches the resulting model — branch and bound, cutting planes, node selection — is Week 11.
The one sentence. Two formulations of the same discrete problem give the same answer, and can differ by orders of magnitude in the effort needed to prove it.
A continuous variable answers how much. A binary answers whether.
| Pattern | Meaning | Algebra |
|---|---|---|
| Yes/no decision | z = 1 if the unit is installed, the stream lined up, the contract signed | z ∈ {0, 1}, priced in the objective |
| Fixed charge | cost F paid if and only if the activity happens at all | F z in the objective, plus u ≤ M z |
| Minimum run rate | a pump that runs at all must run above L | u ≥ L z |
| Semicontinuous | the two above, together | u ∈ {0} ∪ [L, M] |
Why the link constraint is not optional. Without u ≤ M z the solver sets z = 0, pays no fixed charge, and still uses u > 0. The binary must be wired to the continuous variable, or it decorates the model instead of constraining it.
The set
u ∈ {0} ∪ [L, M]
the smallest nonconvex set that appears in process models.
What relaxing z does
Relax z to the interval [0, 1] and the pair of rows
L z ≤ u ≤ M z
sweeps out the wedge between the two lines u = L z and u = M z.
That wedge is the convex hull of the two pieces — the point z = 0, u = 0 and the segment z = 1, L ≤ u ≤ M.
The wedge is where every difficulty in this session begins. A fractional z buys a fraction of the fixed charge.
Five component streams blended into two gasoline grades — the Week 4 instance. Three operating realities were ignored there.
| Stream | cost USD/t | avail. t | fixed Fc USD | min run Lc t |
|---|---|---|---|---|
| Reformate | 760 | 3200 | 12 000 | 800 |
| FCC naphtha | 730 | 4000 | 9 000 | 1000 |
| Alkylate | 805 | 2000 | 15 000 | 500 |
| Butane | 510 | 900 | 4 000 | 200 |
| Straight run | 695 | 2600 | 7 000 | 600 |
The model
max Σg pg yg − Σc cc uc − Σc Fc zc
s.t. Lc zc ≤ uc ≤ availc zc, zc ∈ {0, 1}
plus every Week 4 row: grade balances, volume windows, octane, vapour pressure, sulfur.
| Margin | USD |
|---|---|
| A. LP, no discrete decisions | 413 439.75 |
| B. + fixed charges and minimum runs | 342 092.31 |
| cost of the discrete structure | 71 347.44 |
| of which fixed charges paid | 47 000.00 |
| of which minimum run rates | 24 347.44 |
| Stream | Lc | LP uc | MILP uc |
|---|---|---|---|
| Reformate | 800 | 3200.0 | 3200.0 |
| FCC naphtha | 1000 | 4000.0 | 4000.0 |
| Alkylate | 500 | 833.0 | 1533.0 |
| Butane | 200 | 574.5 | 633.9 |
| Straight run | 600 | 473.1 | 600.0 |
Read the last column. Straight run was used at 473.1 t in the LP. A minimum run rate of 600 t forces the plant either to move 600 t of a stream it did not want that much of, or to shut the line down entirely. The optimizer chose to run it and paid the difference — and the minimum run rates cost half as much again as all five fixed charges combined.
Exact and dimensionless — no constant is required
| Statement in words | Logic | Linear constraint |
|---|---|---|
| a implies b | a ⇒ b | za ≤ zb |
| a and b are equivalent | a ⇔ b | za = zb |
| at least one of a, b | a ∨ b | za + zb ≥ 1 |
| not both | ¬(a ∧ b) | za + zb ≤ 1 |
| exactly one of a set S | Σj∈S zj = 1 | |
| at least k of S | Σj∈S zj ≥ k | |
| at most k of S | Σj∈S zj ≤ k | |
| a and b together imply c | a ∧ b ⇒ c | za + zb − 1 ≤ zc |
| a implies b or c | a ⇒ b ∨ c | za ≤ zb + zc |
Every propositional statement over finitely many binaries can be written this way. These nine are the ones worth memorizing.
Definitional equivalences need three rows each
| Statement | Linear constraints |
|---|---|
| c ⇔ a ∧ b | zc ≤ za, zc ≤ zb, zc ≥ za + zb − 1 |
| c ⇔ a ∨ b | zc ≥ za, zc ≥ zb, zc ≤ za + zb |
Where continuous variables enter, and M appears
| Statement | Linear constraint |
|---|---|
| if a then u ≤ U1, else u ≤ U2 | u ≤ U1 za + U2(1 − za) |
| if a then g(x) ≤ 0 | g(x) ≤ M(1 − za) |
Everything above this line is exact. Everything below depends on a numerical constant, which is Lecture 2.
Verify, do not remember
Enumerate all 2n assignments, evaluate the proposition, evaluate the inequalities, and confirm they agree on every row. All ten translations in the notebook pass on every assignment.
The control case. Writing a ⇒ b as za + zb ≤ 1 fails the same harness: it is the translation of not both, and it forbids the assignment (1, 1) that the implication permits.
A wrong translation is silent. The model still solves, still reports optimal, and answers a different question. That is the Week 6 theme arriving early.
20 min · pairs · paper, then the board
Translate all eight statements into linear constraints in binary variables. Use zA, zB, zC, zD for the units, z1, z2, z3 for the technologies, uC for the run rate of unit C, and zW for the warehouse lease.
No products of binaries are permitted. At 12 minutes, eight pairs are called to the board, one statement each.
| Statement | Linear constraints | |
|---|---|---|
| 1 | A implies B | zA ≤ zB |
| 2 | at most two of four | zA + zB + zC + zD ≤ 2 |
| 3 | exactly one technology | z1 + z2 + z3 = 1 |
| 4 | A implies not B | zA + zB ≤ 1 |
| 5 | run at least 20 t/d or not at all | 20 zC ≤ uC ≤ UC zC, with UC the physical capacity |
| 6 | production over 100 t forces the lease | Σj pj ≤ 100 + M zW, M = Pmax − 100 |
| 7 | D only if both A and B | zD ≤ zA and zD ≤ zB |
| 8 | at least one of A, B, C; all three force a supervisor | zA + zB + zC ≥ 1 and zS ≥ zA + zB + zC − 2 |
The two that generate argument. 5 and 6 are the only ones needing a constant. 5 is the semicontinuous pattern; 6 is the bridge into Lecture 2. Note 6 is one-way — it does not forbid leasing at low production.
The commonest error. 7 written as zD ≤ zA + zB admits zD = 1 with only A built. The pair is correct; the single row 2 zD ≤ zA + zB is also correct but relaxes more weakly.
Two conditions on the tank farm: Σc zc ≤ 4 (cardinality), and zButane ≤ zStraight run (implication).
| Model | margin, USD | streams on |
|---|---|---|
| B. fixed charge + min run | 342 092.31 | all five |
| C1. + cardinality only | 335 539.13 | Ref, FCC, Alk, But |
| C2. + implication only | 342 092.31 | all five |
| C3. + both | 281 361.41 | Ref, FCC, But, SR |
| Cost of | USD |
|---|---|
| cardinality alone | 6 553.18 |
| implication alone | 0.00 |
| both together | 60 730.89 |
Restrictions interact, and the interaction is not additive. The implication alone costs nothing, because the unrestricted optimum already runs straight run. Once cardinality removes straight run, the implication also removes butane, and together they cost 60 731 USD — an order of magnitude more than the sum of their individual costs. Total cost of discrete reality: 413 439.75 − 281 361.41 = 132 078.33 USD, 31.9 percent of the LP margin.
A constraint that applies only when a binary is 1
g(x) ≤ M (1 − z), z ∈ {0, 1}
z = 1 — the row reads g(x) ≤ 0 and is enforced. z = 0 — the row reads g(x) ≤ M and must be non-binding.
The definition
Any M large enough to make the row non-binding when z = 0 is valid, and every valid M gives the same integer optimum. Only the smallest such value is tight:
M* = max { g(x) : x feasible for the other alternatives }
which is itself an optimization problem, usually a small LP.
What never to do. Pick a round number such as 106 because it looks big enough.
Two different things then go wrong, and they fail in different ways. The next two slides are one each.
A useful habit. Write M as a named expression in the units of the row it appears in — M_c = avail[c] — never as a bare literal. A big-M with units attached is a big-M somebody can check. In the workbook it gets its own visible cell, Model!$C$36.
Relaxing z to [0, 1] in u ≤ M z gives z ≥ u / M. A large M lets the relaxation buy the stream for a small fraction of its fixed charge.
| Formulation (same 34 rows in every case) | MILP optimum | LP bound | gap, USD | Σc zc in LP |
|---|---|---|---|---|
| tight Mc = availc | 281 361.41 | 379 170.50 | 97 809.08 | 3.6932 |
| loose M = 50 000 | 281 361.41 | 411 575.46 | 130 214.04 | 0.1836 |
| very loose M = 107 | 281 361.41 | 413 430.43 | 132 069.01 | 0.0009 |
Read the last column. With M = 107 the relaxation switches on all five streams for a total z-mass of 0.0009, so it pays 0.09 percent of the fixed charges and its bound is essentially the pure LP value.
A loose M does not change the answer. It changes how long the search takes to prove it, because the bound is what branch and bound must close. You will measure this yourself in Activity 2.
Solvers accept z as integral within an absolute tolerance, typically ε = 10−6. A value z = 10−6 is reported as z = 0, while u ≤ M z still permits u ≤ M ε.
| M | flow allowed, t | charge paid, USD |
|---|---|---|
| 3 200 | 0.0032 | 0.012 |
| 50 000 | 0.05 | 0.012 |
| 107 | 10 | 0.012 |
| 1010 | 10 000 | 0.012 |
Made concrete
Set M = 1010 and fix every zc = 10−6, which the solver reports as off:
Whose fault. The plan moves ten thousand tonnes through five lines the solution claims are switched off, and it looks 71 347 USD better than the true optimum. The model is not wrong in exact arithmetic. It is wrong in floating-point arithmetic, which is the only kind a solver has. M × ε is a modeling decision, not a solver defect.
Break
15 minutes.
Next: Activity 2, big-M roulette, at the computer, in groups of 3 to 4. Open w05-fixed-charge.xlsx and check that OpenSolver finds CBC.
Before you leave the room: form your group and collect your assigned value of M from the front. Every group solves the same model with a different M.
Three intermediates must be supplied; six candidate units are offered. This is the workbook model, and it is solved with Pyomo in section 6 of the notebook.
| Unit | fixed kUSD/yr | hours h/yr | min thru. t/yr |
|---|---|---|---|
| U1 mixer-extruder | 180 | 3500 | 500 |
| U2 roll press | 240 | 3400 | 450 |
| U3 slot-die coater | 300 | 3600 | 600 |
| U4 spray dryer | 150 | 3200 | 350 |
| U5 calciner | 260 | 3300 | 550 |
| U6 calender line | 210 | 3400 | 400 |
Rates rup, t/h (dash = not possible):
| Unit | anode | cathode | separator |
|---|---|---|---|
| U1 | 0.42 | – | – |
| U2 | 0.30 | 0.55 | – |
| U3 | – | 0.62 | 0.48 |
| U4 | 0.36 | – | 0.40 |
| U5 | – | 0.50 | 0.30 |
| U6 | – | 0.44 | 0.52 |
The model
min Σu Fu zu + Σ(u,p) cup xup / 1000
Σu xup = dp — demand
Σp xup / rup ≤ Hu — hours
Σp xup ≤ M zu — on/off link, the big-M
Σp xup ≥ Lu zu — minimum throughput
zU2 + zU6 = 1 — competing licences
zU4 ≤ zU3 — shared solvent recovery
Σu zu ≤ 4 — commissioning crew
Demand, t/yr: anode paste 1800, cathode sheet 2400, separator film 1500. The single number you change is the big-M in Model!$C$36.
25 min · groups of 3 to 4 · computer
Every group solves the same model in w05-fixed-charge.xlsx. Complete the yellow cells, set Model!$C$36 to your group’s M, and record three numbers: the LP relaxation objective (replace the bin constraint on $H$40:$H$45 by ≤ 1 and re-solve), the integer optimum with bin restored, and the solve time.
| Group | multiple | M, t/yr |
|---|---|---|
| 1 | M*, tightest | 2 232 |
| 2 | 2 M* | 4 464 |
| 3 | 10 M* | 22 320 |
| 4 | 103 M* | 2 232 000 |
| 5 | 106 M* | 2 232 000 000 |
| Group | M | LP bound | integer opt. | time, s |
|---|---|---|---|---|
| 1 | 2 232 | |||
| 2 | 4 464 | |||
| 3 | 22 320 | |||
| 4 | 2.232 × 106 | |||
| 5 | 2.232 × 109 |
This table goes on the board and is filled in from the floor.
Predict, before you solve, which of the three columns will differ between groups.
| Group | M, t/yr | LP bound, kUSD/yr | integer optimum | gap % | CBC time |
|---|---|---|---|---|---|
| 1 | 2 232 (M*) | 2 203.148 | 2 533.226 | 13.030 | < 0.05 s |
| 2 | 4 464 | 1 974.134 | 2 533.226 | 22.070 | < 0.05 s |
| 3 | 22 320 | 1 879.765 | 2 533.226 | 25.796 | < 0.05 s |
| 4 | 2 232 000 | 1 844.009 | 2 533.226 | 27.207 | < 0.05 s |
| 5 | 2 232 000 000 | 1 843.620 | 2 533.226 | 27.222 | < 0.05 s |
Two instructive wrong answers.
A group that never changed $C$36 reports the shipped default M = 2 500, LP bound 2 143.300, gap 15.39 percent.
A per-unit Mu (1470, 1870, 2232, 1280, 1650, 1726.8) beats every row of the table: LP bound 2 403.382, gap 5.126 percent. One number for six different units is already loose, and Lecture 3 goes further still.
The disjunction
⋁k [ Yk ; Ak x ≤ bk ] with exactly one Yk true.
Big-M
Ak x ≤ bk + Mk(1 − zk), Σk zk = 1
Convex hull, disaggregated (Balas)
x = Σk xk, Ak xk ≤ bk zk
0 ≤ xk ≤ xU zk, Σk zk = 1
The hull form is the tightest linear relaxation any formulation of that disjunction can have.
x1 = feed rate, x2 = product rate.
Configuration A, small continuous unit
10 ≤ x1 ≤ 40, 0.3 x1 ≤ x2 ≤ 0.5 x1
annualized fixed cost 120 kUSD.
Configuration B, large unit
60 ≤ x1 ≤ 90, 0.5 x1 ≤ x2 ≤ 0.7 x1
annualized fixed cost 260 kUSD.
Operating cost 1.8 kUSD per unit feed and 3.2 kUSD per unit product in either configuration; the section must deliver at least 25 units of product.
Row-wise tightest M, by LP
| A row | M* | B row | M* |
|---|---|---|---|
| x1 ≥ 10 | 0 | x1 ≥ 60 | 50 |
| x1 ≤ 40 | 50 | x1 ≤ 90 | 0 |
| x2 ≤ 0.5 x1 | 18 | x2 ≤ 0.7 x1 | 0 |
| x2 ≥ 0.3 x1 | 0 | x2 ≥ 0.5 x1 | 8 |
A zero means the row is already implied by the other alternative, so it needs no relaxation at all. Four of the eight rows are in that class, which no round-number M would ever discover.
Same disjunction, two formulations, two different relaxations
What the picture shows
The true feasible set is the union of the two boxes-with-slopes, A near the origin and B further out along x1.
The convex hull is the smallest convex set containing both — area 1100.
The tightest big-M region is strictly larger — area 1137.5.
A point that separates them. (x1, x2) = (22.5, 15.75) lies in the big-M relaxation and not in the hull.
It is in neither configuration: x1 = 22.5 is too large for A only in combination with x2 = 15.75, which exceeds 0.5 x1 = 11.25, and it is far below B’s floor of 60.
Draw the two regions on the board before showing the numbers on the next slide. The ordering of the areas is the whole argument.
Four formulations of one disjunction, same integer optimum 464.0
| Formulation | rows | cols | LP bound | gap % | relaxation area |
|---|---|---|---|---|---|
| big-M, M = 500 | 10 | 4 | 207.000 | 55.39 | 9600.00 |
| big-M, M = 120 (from bounds) | 10 | 4 | 229.167 | 50.61 | 9133.33 |
| big-M, row-wise tightest | 10 | 4 | 298.744 | 35.62 | 1137.50 |
| convex hull (disaggregated) | 16 | 8 | 298.744 | 35.62 | 1100.00 |
Definition
integrality gap = (zMILP − zLP) / zMILP for a minimization,
(zLP − zMILP) / zMILP for a maximization.
Why the gap and not the row count. Branch and bound stops when the incumbent and the best remaining bound meet, so the work is roughly a function of how far apart they start. An extra thousand rows that halve the gap are usually a bargain, and the number of rows is a poor proxy for difficulty.
Smaller is better in the last column, and it is the only column that predicts effort
| Instance | Formulation | rows | LP bound | MILP optimum | gap % |
|---|---|---|---|---|---|
| 20 units, 40 orders | big-M, M = 10 000 | 80 | 864.168 | 3548.408 | 75.6463 |
| 20 units, 40 orders | big-M, M = capacity | 60 | 3509.477 | 3548.408 | 1.0971 |
| 20 units, 40 orders | disaggregated (hull-derived) | 860 | 3548.340 | 3548.408 | 0.0019 |
| two-config. reactor | big-M, M = 500 | 10 | 207.000 | 464.000 | 55.3880 |
| two-config. reactor | big-M, row-wise tightest | 10 | 298.744 | 464.000 | 35.6150 |
| two-config. reactor | convex hull (disaggregated) | 16 | 298.744 | 464.000 | 35.6150 |
| blending, fixed charges | tight Mc = availc | 34 | 379 170.50 | 281 361.41 | 34.7628 |
| blending, fixed charges | very loose M = 107 | 34 | 413 430.43 | 281 361.41 | 46.9393 |
| zinc-air plant (Activity 2) | big-M on hours only | 18 | 2402.903 | 2533.226 | 5.1450 |
| zinc-air plant (Activity 2) | disaggregated (hull) | 29 | 2412.448 | 2533.226 | 4.7680 |
The row count moves by a factor of 86 across this table while the gap moves by a factor of 40 000. They are not the same quantity and they are not correlated.
20 min · groups of 3 to 4 · paper
Each constraint is written with a lazy M = 106. For each, derive the tightest valid M and give the one-line argument — an upper bound on the left-hand side over the rest of the feasible set.
One of the three has no finite valid M. Identify it and say what has to be added to the model.
(a) M* = 2 232 t/yr — the lazy M was 448 times too large. Maximize the left-hand side over the rest of the feasible set. Cathode sheet is the faster product, so all-cathode gives 3600 × 0.62 = 2232 t/yr; separator film is capped at 1500 t/yr by demand and needs 1500/0.48 = 3125 h to make less product, so no mix beats all-cathode.
(b) M* = 2 782.5 t — and the two cheaper recipes are both loose.
| recipe | M, t | source of the bound |
|---|---|---|
| availability sum | 4 700.0 | 12 700 − 8 000, ignores the volume windows |
| grade volume caps | 4 000.0 | 7 000 + 5 000 − 8 000, ignores the quality rows |
| LP over the feasible set | 2 782.5 | max Σc uc = 10 782.47, so M* = 10 782.47 − 8 000 |
The blender cannot reach 12 000 t because the octane floor on Premium and the vapour pressure and sulfur caps limit how much of the cheap high-RVP, high-sulfur streams may enter.
(c) No finite valid M exists, and a bigger number is not the fix. Rt has no upper bound, so max Rt is +∞ and no finite M leaves the row non-binding when y = 1. Whatever number you write becomes a silent, undocumented capacity limit on rented storage. The fix is physical: the contract offers at most 500 t per month, so add Rt ≤ 500, and then M* = 500 t.
When you add a binary to a model
Two smells. A declared parameter that no constraint references — a forgotten constraint. And a binary whose relaxed value is 10−3 at the LP optimum — a big-M that is too large.
Takeaways
Numbers established today
| Blending LP / MILP margin | 413 439.75 / 342 092.31 |
| Fixed charges / min runs | 47 000 / 24 347.44 |
| Full discrete model | 281 361.41 (−31.9%) |
| Big-M bound, tight / 107 | 379 171 / 413 430 |
| M = 1010, z = ε | margin 413 439.70 |
| Hull / tight big-M area | 1100 / 1137.5 |
| 20 units, gap loose/tight/hull | 75.6 / 1.10 / 0.002 % |
| Activity 2 optimum | 2533.226 kUSD/yr |
| A2 bound, M* / 106M* | 2203.1 / 1843.6 |
Finish
w05-modeling4-logical-discrete.ipynb, including the exercises. Sections 4 and 5 are the ones Activity 2 could not do in a spreadsheet.w05-fixed-charge.xlsx, if your group did not reach the integer optimum 2533.226 kUSD/yr.Read
Williams Ch. 9 (fixed charges, logical conditions, semicontinuous variables) and Ch. 10 (formulation strength). Rao Ch. 10 for the integer-programming vocabulary.
HW2 is due at the start of Week 6. Blending, pooling, logical and discrete modeling, plus the model-audit task.
Coming next: Week 6
A three-hour workshop. A language model drafts, the engineer verifies.
You will audit three generated models that all solve to optimal and are all wrong, and you will quantify what each error would have cost.
Bring a laptop with Pyomo and a solver working.
Before you go · 45 seconds
Five questions. Anonymous — no name, no email, no login.
The fourth question is the one I actually use.
The two most common answers open next week’s session.
oxidized-challenge-ed9.notion.site

Scan now — I will wait