Week 2 · 2105623 Optimization of Chemical Processes · one-hour session
17 August 2026
Today
Both classroom activities move out of the room today. They are in the pack, they have a deadline, and Week 3 opens with your answers.
Recap of Week 1
1Verbalthe problem in prose
2Specificationwe are here
3Algebraand here
4CodeWeeks 7 and 8
5InterpretationWeeks 7 and 8
Week 1 established
The four parts of any problem, the standard form, the classification table, the tool stack, and one solved LP: x* = (6, 3) t/week at z* = 3,300.00 USD/week with two binding resources.
And the geometry
An LP with a finite optimum has an optimal vertex. That argument is not repeated today. Every model in this session is an LP and the same picture applies, unchanged.
The modeling block is stages 2 and 3, done four times on four kinds of structure. Weeks 2 to 5 add no new mathematics at all.
Lecture block 1 · 35 minutes
One document, four patterns,
and one small model in which all four are visible at once.
Why a document, and not algebra
Why this and not algebra
Algebra hides assumptions. The symbol It looks precise, but it does not say whether inventory is measured at the start or the end of the period. The specification has to say so in words, where a reader can disagree with it.
A specification that requires guessing will be guessed at, and the guess will be plausible, silent and unlabeled.
The code is a translation of this document. If the specification is right, writing the algebra and then the model file is close to mechanical.
This is what Part A of the pack asks you to fill in
| Section | What goes in it | The question it forces you to answer |
|---|---|---|
| Sets and indices | every dimension of the problem, named, with its membership | What is repeated, and over what? |
| Parameters | symbol, meaning, unit, source of the number | Which numbers are fixed before the model is solved, and who owns them? |
| Decision variables | symbol with full index, unit, bounds | What is genuinely under your control? |
| Objective | one sentence in words, with its unit | What counts as better, in what currency, over what period? |
| Constraints | numbered, in words | What must hold, and is each one hard or soft? |
| Assumptions | numbered alongside the constraints | What did you decide to ignore, and would a reviewer accept it? |
Assumptions are written as numbered restrictions, not as prose. “Everything produced is sold” is a modeling decision with a cost attached, and numbering it is what lets somebody challenge it.
Specification, row 2
| Symbol | Meaning | Unit | Where the number comes from |
|---|---|---|---|
| dt | demand in period t | t/month | sales forecast, revision date recorded |
| Ct | production capacity | t/month | line rate times available hours |
| ct | unit production cost | USD/t | standard cost plus the electricity contract |
| h | inventory holding cost | USD/t/month | working capital plus storage |
| b | backlog penalty | USD/t/month | expedited freight plus contractual damages |
| I0 | opening inventory | t | the stock ledger at the planning date |
| ρp | reactor hours per tonne of p | h/t | the process, measured and not assumed |
A parameter is anything fixed before the problem is solved. If you can change it, it is a variable; if you cannot, it is a parameter. Confusing the two is the commonest stage-2 error.
h and b carry per month in their unit. That is what makes a backlog charged again in every period until it is cleared — and it is exactly the modeling decision that drives the answer at half past two.
Specification, row 3
| Symbol | Meaning | Unit |
|---|---|---|
| xt ≥ 0 | production in period t | t |
| It ≥ 0 | inventory carried out of t | t |
| Bt ≥ 0 | backlog carried out of t | t |
Bounds are free performance and free safety
An unbounded variable is the commonest cause of an unbounded model, and an unbounded integer variable will cripple a solver’s presolve in Week 11. Write the physical bound even when you believe the constraints already imply it. It costs one line and it documents the physics.
A variable is not a formula
It is a variable that the balance equation ties to production and demand. Do not write it as an expression. Keeping it a variable is what lets you bound it, price it, and read its dual.
Thirty seconds, every time
The check, applied to the inventory balance
It−1 [t] − Bt−1 [t] + xt [t] − dt [t] = It [t] − Bt [t]
Every term is a tonnage. If any one of them had carried a rate, the equation would be wrong, and it would still solve.
And to the objective
ct [USD/t] · xt [t] + h [USD/t/month] · It [t] · 1 [month] ⇒ [USD]
The “one period” in the holding term is implicit. Writing it out is what stops you putting a weekly rate into a monthly model.
The class of error units catch
Mixing a stock (tonnes) with a flow (tonnes per month), or mixing two time bases. Neither produces an error message. Both produce a plan that is confidently wrong by a factor of four or five.
The same relation repeated over a family
Template
i ∈ I and then xi ⟶ xi,t
| Dimension | Index | Set |
|---|---|---|
| product or grade | p | P |
| resource or operation | r, s | R, S |
| period | t | T, ordered |
| node or site | i, j | N |
| scenario | ω | Ω |
Ordered sets matter
A time set must be ordered, because the model needs to know what t − 1 means. In Pyomo, pyo.Set(initialize=T, ordered=True), then m.T.prev(t). In a spreadsheet, “the column immediately to the left” is the same statement — and it is why periods run across columns.
What goes in equals what goes out plus what accumulates
Template
accumulation = inflow − outflow
It−1 + xt − dt = It
The most expensive class of error
A missing balance is worse than a wrong one. The model still solves. It still reports a plan. It has simply stopped conserving material, and nothing on the screen says so.
Patterns 1 and 2 together
Written once, expanded over the ordered set T. One line of specification becomes six rows in the spreadsheet, and the six rows are what make it a plan rather than six unrelated decisions.
A shared resource limits a sum
Template
Σi ari xi ≤ br for every r ∈ R
Renewable, or consumed once
xt ≤ Ct for every t versus Σt xt ≤ C
Line hours that reset every month give one inequality per period. A fixed allocation of catalyst consumed once over the horizon gives one inequality summed over t.
They behave completely differently, and nothing in the English of a problem statement tells you which is meant. The specification has to say.
A variable in one block constrains another
Template
any constraint whose index
spans more than one block
Temporal linking · block 2
The inventory balance carries stock from t − 1 into t, so the periods cannot be planned one at a time.
Resource linking · block 3
One shared reactor is used by both products, so the products cannot be planned one at a time.
Remove both and the model falls apart into a stack of independent one-period problems that nobody needs a solver for.
Why they are worth naming
| 1 Index set | 2 Balance | 3 Capacity | 4 Linking | |
|---|---|---|---|---|
| Refinery blend | feedstocks c, properties q | volume balance: blend = Σ components | feedstock availability, over c | quality specs, over q |
| Staff roster | staff e, shifts t | only if headcount carries across periods | cover per shift; hours per person | rest rules, over consecutive t |
| Battery dispatch | hours t, |T| = 24 | state-of-charge balance, over t | power limit and energy capacity per t | the state-of-charge balance itself |
| Warehouse network | plants i, warehouses j, customers k | node balance at each warehouse | plant supply; warehouse throughput | the warehouse node balance |
The honest nuance. The roster’s balance row is arguable. If staff are simply assigned to shifts, the cover requirement is a capacity constraint with a ≥ sense and there is no balance at all. A balance appears only if a pool of people is carried across periods. Both readings are defensible — and the specification is where you say which one you chose.
All four patterns, in a model small enough to hold in the head
A finishing shop attached to the electrolyte plant packages two grades for zinc-air cell assembly, a Standard grade and a HighPurity grade. Both pass through the same three operations in order: mixing, ion-exchange purification, and filling. The three operations have different weekly hour allocations because they are shared with other campaigns. HighPurity is worth more per tonne but spends four times as long in purification. Everything finished is sold.
| Operation | Standard, h/t | HighPurity, h/t | Available, h/week |
|---|---|---|---|
| Mixing | 2 | 3 | 120 |
| Ion-exchange purification | 1 | 4 | 104 |
| Filling | 1 | 1 | 44 |
| Contribution margin, USD/t | 520 | 790 |
Stage 2, restrictions in words. R1. On each operation, the hours consumed cannot exceed the hours allocated. R2. Production cannot be negative. R3. There is no demand limit, because everything finished is sold — and R3 is an assumption, numbered so that it can be challenged. Stage 3. max Σp cp xp subject to Σp asp xp ≤ bs for every s, with xp ≥ 0 and [h/t]·[t/week] = [h/week] on every row.
Busiest and binding are different words
| Operation | Used, h | Avail., h | Slack, h | Dual, USD/h |
|---|---|---|---|---|
| Mixing | 108 | 120 | 12 | 0 |
| Purification | 104 | 104 | 0 | 90 |
| Filling | 44 | 44 | 0 | 430 |
The answer
24 t of Standard and 20 t of HighPurity, for 28,280.00 USD of contribution margin in the week.
Verified two ways in the notebook: vertex enumeration in NumPy, and a finite-difference check on every dual.
The engineering reading
Buy an overtime shift on filling first, not on the operation that looks busiest.
Mixing consumes 108 hours, more than either other operation in absolute terms, and it is worth exactly zero at the margin.
And the limitation we spend the rest of the day removing
This plans one week in isolation. It has no memory. It cannot build stock now for a peak later, and it cannot say that a shortfall this week must be delivered next week.
Pattern 4, drawn
Without the amber arrows these are six independent problems. Each would be solved on its own, and nothing at all would be gained by solving them together. The optimization would be arithmetic.
The amber arrows are the linking constraint of pattern 4. Everything a multiperiod model can do about seasonality, a demand spike or a cost profile passes through them.
Pattern 2, with the boundary drawn around a period
Accumulation equals inflow minus outflow, around a period
It−1 − Bt−1 + xt − dt = It − Bt for every t ∈ T
with I0 given and B0 = 0.
The sheet you are about to complete
| Algebraic symbol | Range | Pyomo component |
|---|---|---|
| t ∈ T | C5:H5 |
Set(..., ordered=True) |
| dt, Ct, ct | C6:H8 |
Param(m.T, ...) |
| h, b, I0, B0 | C9:H10, C11:C12 |
scalar Param |
| x, I, B ≥ 0 | C16:H18 |
three Var(m.T, ...) |
| balance ∀ t | C28:C33 |
Constraint(m.T, rule=...) |
| xt ≤ Ct | C34:C39 |
Constraint(m.T, ...) |
| objective | C24 |
Objective(sense=minimize) |
The transposition. In Week 1 the model ran down the rows. Here periods run across columns, so each constraint family becomes a block of rows. Only the layout changed.
Due Week 4
The instruction that carries the most marks
Write the specification before any algebra.
A correct model with no specification loses marks. A specification that states its assumptions and its start-versus-end convention earns them even where the algebra slips.
Two habits to carry into it
A unit on every symbol, and a bound on every variable. Both are checkable by a reader in thirty seconds, and both catch the errors a solver never reports.
Before we meet again
One PDF, on myCourseVille, before midnight this Friday, 21 August. Week 3 opens with the ambiguities you found in Part A.
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