Week 1 · 2105623 Optimization of Chemical Processes
10 August 2026
Today
A solver will always answer
the question you asked it.
This course is about making that
the question you meant.
Fifteen weeks, and almost none of them are about the arithmetic.
Learning objectives · CLO 1 and CLO 4
Variables, parameters, objective, constraints, and find each one in a written problem.
The artifact each stage produces, and the characteristic failure of each.
LP, NLP, IP, MILP, stochastic, global, and which solver class each one needs.
Why an LP with a finite optimum has an optimal corner, geometrically.
Infeasible from unbounded, and what each says about the model.
What the modeling layer and the solver layer each do, and which week uses which.
Activity 1 · 15 minutes · whole class
Everybody speaks. One minute each, standing.
I go first, so you can see how short a minute is.
We are going to spend fifteen weeks arguing about models together. We should know who is in the room.
Activity 1
Question 4 is the one I write down. Activity 2 this afternoon asks you to bring your own research into the room, so it helps that everyone knows who works on what.
Lecture block 1 · 35 minutes
One definition, one diagram,
and one small problem walked end to end.
What optimization is
Optimization is the discipline of choosing, under constraints, against a stated criterion.
It is simulation. A model evaluated, not searched.
The answer is trivial, and the model is wrong.
There is no problem yet. “Improve the plant” is not a criterion.
“Maximize weekly contribution margin, in USD per week” is a criterion. Notice that it carries a unit.
Four places, one mathematics
Equipment sizing. Reactor network selection. Heat exchanger network synthesis. Superstructures: which route to build at all.
Product mix on shared equipment, today’s example. Multiperiod production and inventory, Week 2. Blending and pooling, Week 4.
Set-point selection and real-time optimization. Battery dispatch against a tariff. Debottlenecking: where is the next hour worth most.
Parameter estimation for kinetics. Equivalent-circuit fitting. Design of experiments and surrogates, Week 13.
The mathematics is the same in all four. What changes is the interpretation of the symbols.
The optimization workflow
1Verbalthe problem in prose
2Specificationsets, data, decisions, units
3Algebraobjective and constraints
4CodePyomo, or a worksheet
5Interpretationstatus, values, duals
Each stage consumes the artifact of the one before it and produces one that is more formal and less ambiguous. They are not interchangeable and they are not optional.
Skipping stage 2 and writing code straight from a paragraph is the commonest cause of a model that runs, returns a number, and is wrong.
The workflow, in a table
| Stage | Artifact it produces | Characteristic failure |
|---|---|---|
| 1 Verbal | Prose, plus a data source for every number in it | Optimizing the wrong thing, or a decision the plant cannot execute |
| 2 Specification | Sets, parameters with units, variables with units, one objective, numbered restrictions | Missing constraint, unstated assumption, a parameter treated as a variable |
| 3 Algebra | min f(x) subject to g(x) ≤ 0, h(x) = 0, every symbol defined | Units that do not balance, an index on one side only, accidental nonlinearity |
| 4 Code | A Pyomo ConcreteModel, or a worksheet layout |
Data typed into model logic, an off-by-one index, a sign error |
| 5 Interpretation | Status, values, duals, a figure, one actionable sentence | Reporting numbers without reading the status |
Three rules: stage 2 before any algebra; every symbol carries a unit; no number is quoted until the termination condition has been read.
The verbal problem
A unit supplying the zinc-air battery industry makes two products on shared equipment: an electrolyte Additive that suppresses zinc dendrite growth, and a Binder solution for air-cathode coating. Both pass through a reactor train, then separation and drying, then finishing and packaging. The plant plans one week at a time.
| Resource | Additive, h/t | Binder, h/t | Available, h/week |
|---|---|---|---|
| Reactor train | 3 | 2 | 24 |
| Separation and drying | 1 | 2 | 16 |
| Finishing and packaging | 1 | 1 | 9 |
| Contribution margin, USD/t | 400 | 300 |
The reactor train is shared with other campaigns, which is why only 24 h/week are allocated. Contribution margin is selling price minus variable cost. Everything produced can be sold. Choose the weekly plan with the largest total contribution margin.
Written before any algebra
| Object | Symbol | Meaning | Units |
|---|---|---|---|
| set | p ∈ P | product on the shared equipment | – |
| set | r ∈ R | shared resource | – |
| parameter | cp | contribution margin | USD/t |
| parameter | arp | use of resource r per tonne of p | h/t |
| parameter | br | hours of r available | h/week |
| decision | xp ≥ 0 | tonnes of p made | t/week |
Objective, in words
Maximize total weekly contribution margin, in USD per week.
Restrictions, in words
R3 is an assumption. Writing it down as a numbered restriction is exactly what makes it possible to challenge it later.
The mathematics, and the thirty-second habit
General form
maximize Σp cp xp over x ≥ 0
subject to Σp arp xp ≤ br for every r
This week’s data, written out
max z = 400 x₁ + 300 x₂ [USD/week]
s.t. 3x₁ + 2x₂ ≤ 24 reactor
x₁ + 2x₂ ≤ 16 separation
x₁ + x₂ ≤ 9 packaging
x₁ ≥ 0, x₂ ≥ 0
The units check
On every constraint, [h/t] · [t/week] = [h/week], which matches the right-hand side.
In the objective, [USD/t] · [t/week] = [USD/week].
A units check catches more modeling errors than any other single habit, and it costs thirty seconds.
Code
Spreadsheet · W01_product_mix
B5:C5 changing cells, tonnes per week
B8:C8 margins, blue: given data
B12:C14 the coefficient block
D12:D14 =SUMPRODUCT($B$5:$C$5,B12:C12)
F12:F14 right-hand sides, own column
D9 objective cell, Set Objective, To: Max
Pyomo · W01_introduction_first_model
m.P = pyo.Set(...), m.R = pyo.Set(...)
m.margin = pyo.Param(m.P, ...)
m.use = pyo.Param(m.R, m.P, ...)
m.avail = pyo.Param(m.R, ...)
m.x = pyo.Var(m.P, domain=NonNegativeReals)
m.resource = pyo.Constraint(m.R, rule=...)
m.profit = pyo.Objective(..., sense=maximize)
One named component per algebraic object. Never type a number inside a formula, in either dialect.
Read the status first, then the numbers
| Resource | Used, h | Available, h | Slack, h | Status | Shadow price, USD/h |
|---|---|---|---|---|---|
| Reactor train | 24 | 24 | 0 | binding | 100 |
| Separation and drying | 12 | 16 | 4 | slack | 0 |
| Finishing and packaging | 9 | 9 | 0 | binding | 100 |
The answer
x* = (6, 3) t/week, z* = 3,300.00 USD/week.
Make 6 t of Additive and 3 t of Binder. Two resources are fully used; separation has 4 h/week to spare.
The identity that is not a coincidence
100(24) + 0(16) + 100(9) = 3,300, which is exactly z*.
That is strong duality, and it is Week 8.
And the range over which it is true
Marginal value, valid locally, is still the most useful single output of a linear program.
10
minute break
Then: anatomy of a model, classification, and the geometry that puts the optimum in a corner
Lecture block 2 · 45 minutes
What a model is made of, what class it belongs to,
and why the optimum of a linear program sits in a corner.
Anatomy
The model is not the plant, and an optimizer exploits every error in it. A model wrong in a way that pays returns an answer that is confidently wrong.
Variables, constraints, hard and soft
| Variable | Domain | Example |
|---|---|---|
| continuous | x ∈ ℝ | tonnes per week |
| integer | x ∈ ℤ | number of batches |
| binary | x ∈ {0, 1} | build this unit or not |
| Constraint | Meaning |
|---|---|
| g(x) ≤ 0 | a capacity or a spec limit |
| h(x) = 0 | a material or energy balance |
| xL ≤ x ≤ xU | a bound: cheap, handled separately |
Hard or soft is a modeling decision
A hard constraint may never be violated. A soft constraint may be violated at a price, written into the model as a slack variable with a penalty.
Which one a requirement is, is not a property of the problem. It is a decision you make and must defend. A safety limit is hard. A delivery date is usually soft, because the plant would in fact pay expediting cost rather than shut down.
Writing a soft requirement as hard is the commonest cause of a model that reports infeasible on a situation the plant handles every week.
Classification
Q1. Are the objective and all constraints linear in x? Q2. Must any variable take a discrete value?
| Linear? | Discrete? | Class | Typical algorithm |
|---|---|---|---|
| linear | none | LP | simplex, interior point |
| linear | all | IP | branch and bound |
| linear | some | MILP | branch and cut |
| nonlinear | none | NLP | interior point, SQP |
| nonlinear | some | MINLP | branch and bound over NLP subproblems |
Two features cut across the table. Stochastic: a parameter is unknown when the decision is made, Week 12. Global: the objective or the feasible set is nonconvex, so a local optimum need not be global, Weeks 4 and 13. Products of variables, ratios, powers, exponentials, logarithms and trigonometric functions all break linearity; counts, yes-or-no decisions and batch multiples are all discrete.
Why the class matters
| Class | One chemical engineering example | What you are promised |
|---|---|---|
| LP | Gasoline blending: linear costs, linear octane, sulfur and vapor pressure limits | Solved reliably at very large scale, and the optimum is global |
| NLP | CSTR temperature and residence time with Arrhenius kinetics, k = k0 e−E/RT | A local optimum, unless the problem is convex |
| IP / MILP | Which of eight heat exchanger matches to install; siting five plants and routing tonnages | Worst-case effort grows exponentially; how you write the model matters more than which solver you buy |
| Stochastic | Commit cell capacity before demand is revealed, three scenarios | Size grows with scenarios, and the answer hedges rather than bets |
| Global | Least-squares fit of a battery equivalent circuit, many local minima | Certifying a global optimum costs far more than finding a local one |
A sentence to be suspicious of
The claim
The LP optimum is (6, 3). The reactor can only be charged in whole 4 t batches. So round down to whole batches and you have your answer.
On this week’s data
True integer optimum: (8, 0), z = 3,200.00 USD/week.
Rounding (6, 3) down: (4, 0), z = 1,600.00 USD/week.
The rounded point is suboptimal here by half the objective. On a tighter problem it can be infeasible.
Three outcomes, read in this order
A feasible solution exists and cannot be improved. Read the plan, then the constraint activity, then the duals, then write one sentence an engineer can act on.
No plan satisfies every constraint at once. The feasible region is empty. This is a statement about the model.
The region is non-empty but the objective improves without limit. In a physical problem this always means a constraint has been forgotten.
Read solver.termination_condition, not the coarse status. In Pyomo, assert it after every solve. In Excel, read the Solver Results dialog before you look at the sheet. Both broken models leave numbers on the screen if you do not check.
What each failure looks like
Infeasible
Add a supply contract: x₁ + x₂ ≥ 12.
Packaging needs 1 h/t for either product and has 9 h/week, so x₁ + x₂ ≤ 9. Since 12 > 9 the region is empty, and no solver was needed to see it.
Diagnose on the constraints. Drop them in groups, ask for an irreducible infeasible subset, or add elastic slacks with a large penalty and read which ones go nonzero.
Unbounded
Delete the three resource limits, keep only x₂ − x₁ ≤ 5.
Take the ray x(t) = (t, t) for t ≥ 0. Every point on it is feasible, and z = 700 t, which grows without limit. At t = 10,000 the model reports 7,000,000 USD/week.
Find the ray and the missing constraint is obvious. A capacity row deleted, a cost with the wrong sign, a purchase left unbounded above.
LP geometry · 1 of 3
LP geometry · 2 of 3
LP geometry · 3 of 3
| Active pair | Vertex | z, USD/week |
|---|---|---|
| x₁ = 0, x₂ = 0 | (0,0) | 0 |
| separation, x₁ = 0 | (0,8) | 2,400 |
| separation, packaging | (2,7) | 2,900 |
| reactor, x₂ = 0 | (8,0) | 3,200 |
| reactor, packaging | (6,3) | 3,300 |
Sliding along the gradient, the last point the region touches is the corner (6, 3). An LP with a finite optimum has an optimal vertex, or a whole optimal edge if the isoprofit line is parallel to one. That turns an infinite search into a finite one: list the vertices, evaluate the margin, take the best.
Week 7 walks vertex to vertex uphill instead of listing them. Today the argument is geometric only.
Activity 2 · 15 minutes · individual, then pairs
Do not think about this course for the next six minutes.
Think about your own work.
I am collecting these cards, and they become the starting list for your project.
Activity 2
Your card
Why now: it converts the vocabulary of the last forty-five minutes into your own work while it is still fresh, and it is much harder than it looks.
Hand back the card with your partner’s comment written on it. All cards are collected and become the seed list for the computational project.
10
minute break
Then: the tool stack, today’s model solved three ways, and how you are graded
Lecture block 3 · 40 minutes
What each layer does, what it cannot do,
and which one this course uses in which week.
The stack
Modeling layer
Target cell, changing cells, constraints, all on a worksheet
Modeling layer
The same worksheet layout, sent to CBC or HiGHS instead
Modeling layer
Set, Param, Var, Constraint, Objective
Translation: an .lp, .mps or .nl file, or an in-memory API
Solver layer
HiGHS, GLPK, CBC · LP and MILP
Solver layer
Ipopt · NLP
Solver layer
Bonmin, Couenne · MINLP
Solver layer
Gurobi, CPLEX, BARON · commercial
Honest limits
| Tool | What it does | Where it stops |
|---|---|---|
| Excel Solver | Ships with Excel. Simplex LP, GRG Nonlinear and Evolutionary engines on a worksheet. | 200 changing cells, 100 explicit constraints. The model lives in cell formulas, so it cannot be version controlled or unit tested. |
| OpenSolver | Free add-in. Keeps the worksheet layout, sends the model to CBC or HiGHS, removes the size limit. | Its default engines are LP and MILP only. Nonlinear models need a different tool. |
| Pyomo | Python algebraic modeling language. Separates structure from data and from solver choice. Scales to hundreds of thousands of variables. | Solves nothing by itself. Without a solver installed, a Pyomo model is only a data structure. |
| Solver layer | Simplex or interior point for LP, branch and cut for MILP, interior point or SQP for NLP. | A solver cannot tell you that your model is wrong. It answers the question you asked. |
No commercial solver is required at any point in this course. Everything runs on HiGHS, CBC, GLPK and Ipopt.
The cheapest verification available
| Route | What you do | x*, t/week | z*, USD/week |
|---|---|---|---|
| Graphical | Draw five half planes, list the vertices, evaluate z at each | (6, 3) | 3,300.00 |
| Spreadsheet | B5:C5 changing, D9 objective, D12:D14 ≤ F12:F14 |
(6, 3) | 3,300.00 |
| Pyomo | ConcreteModel, then SolverFactory and one solve |
(6, 3) | 3,300.00 |
Why do this at all
Three interfaces to one mathematical object. Only the third scales, but the geometry of the first is what you should see in your head when a solver reports an answer, and the second is where most industrial models still live.
Two implementations that agree is evidence
The Week 1 notebook asserts it: assert np.allclose(x_graph, x_pyomo). If the spreadsheet and the notebook ever disagree, the spreadsheet is wrong. This habit is expected on every result in this course.
The tool plan, designed and not accidental
The data is naturally tabular and the models are small. Everyone succeeds on day one with no installation. Periods across columns and cost matrices read the way a spreadsheet reads.
Linear blending is done in OpenSolver. Then pooling forces the move: it multiplies a flow by a quality, which a spreadsheet cannot handle at all. The crossover happens for a mathematical reason, not a matter of taste.
Models must scale, be re-solved dozens of times, and be verified programmatically. Week 5 opens in the spreadsheet and then moves to Python. From Week 6 the work is Python only.
The rule: a spreadsheet is right when the data is tabular and the model is small. Python becomes necessary when the model must scale, be re-solved many times, or be verified programmatically.
Course map
| W | Topic |
|---|---|
| 1 | Introduction, workflow, tool stack |
| 2 | Linear models, product mix, multiperiod, inventory |
| 3 | Networks, transportation, transshipment, superstructures |
| 4 | Blending, pooling, quality specs, entry to nonlinearity |
| 5 | Logical and discrete decisions, big-M versus convex hull |
| 6 | AI-assisted modeling and model debugging |
| 7 | LP theory: geometry, simplex, what a solver does |
| W | Topic |
|---|---|
| 8 | Duality and sensitivity, economic interpretation |
| 9 | Unconstrained NLP: convexity, line search, Newton |
| 10 | Constrained NLP: Lagrange, KKT, penalty, SQP |
| 11 | Integer and mixed-integer programming, branch and bound |
| 12 | Optimization under uncertainty: DP, stochastic, robust |
| 13 | Data-driven and AI-based optimization |
| 14, 15 | Project presentations and wrap-up |
The midterm is held after Week 8 and covers Weeks 1 to 8, with no nonlinear programming. The final is cumulative, with emphasis on Weeks 9 to 13.
Assessment, homework, project
Weights
The midterm sits after Week 8 and contains no nonlinear programming.
| Homework | Out | Due |
|---|---|---|
| HW1 linear and network models | W2 | W4 |
| HW2 blending, discrete, audit | W4 | W6 |
| HW3 LP theory and duality | W7 | W9 |
| HW4 NLP and MILP | W10 | W12 |
| Project milestone | When |
|---|---|
| Group registration and candidate topics | W4 |
| Proposal due: a structured specification | W6 |
| Formulation checkpoint: algebra, size, tests | W9 |
| Preliminary results and full test suite | W12 |
| Presentations, 12 min plus 3 of questions | W14, W15 |
| Report, code, tests, disclosure section | end W15 |
Read this before you ask
Generative AI is permitted for assignments and for the project. Using it to draft models is expected rather than merely tolerated. Week 6 is a three-hour workshop on how to do it well.
Disclose which parts were AI-drafted and which tests validated them. The disclosure section is part of the project report.
An unverified generated model earns no credit for model correctness, however good it looks.
Both the midterm and the final. No exceptions, and no ambiguity.
A solver answers the question you asked. So does a language model. In both cases the verification is your job, and in this course it is the part that carries the marks.
Summary
| Quantity | Value |
|---|---|
| Optimal plan x* | (6, 3) t/week |
| Optimal margin z* | 3,300.00 USD/week |
| Reactor, used / available | 24 / 24 h |
| Separation, used / available | 12 / 16 h |
| Packaging, used / available | 9 / 9 h |
| Shadow prices | 100, 0, 100 USD/h |
| Packaging raised 9 to 14 h | 3,400.00 at (4, 6) |
| Whole 4 t batches, IP | (8, 0), 3,200.00 |
| LP answer rounded down | (4, 0), 1,600.00 |
| Concave price variant, NLP | (2.5, 6.5), 2,825.00 |
Four things, and one of them is not optional
pip install pyomo highspy gives the modeling layer and an LP/MILP solver. Then conda install -c conda-forge ipopt glpk coincbc adds an NLP solver and two more.W01_introduction_first_model.ipynb, end to end, including Exercises 1 to 3.Reading
Rao, Ch. 1, all of it. Short, and it fixes the vocabulary.
Edgar, Himmelblau and Lasdon, Ch. 1, for the process-industry framing.
Williams, Ch. 1 and 2, for the modeling stance this course takes.
HW1 is released next week and is due in Week 4.
Week 2 · 17 August — Linear models: product mix, multiperiod planning, and inventory.
Not: what is the answer?
But: is this the question
I actually meant to ask?
See you next Monday. Bring the laptop.
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