Introduction, the optimization workflow, and the tool stack

Week 1 · 2105623 Optimization of Chemical Processes

Soorathep Kheawhom

10 August 2026

Three hours, nine blocks

Today

  • 5 min Welcome. What this course is, and what it is not
  • 15 min Activity 1 — the one-minute pitch
  • 35 min Block 1: what optimization is, and the five-stage workflow
  • 10 min Break
  • 45 min Block 2: anatomy, classification, feasibility, LP geometry
  • 15 min Activity 2 — your research as an optimization problem
  • 10 min Break
  • 40 min Block 3: the tool stack, one model three ways, logistics
  • 5 min Wrap-up and what to do before Week 2

 

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.

By three o’clock you should be able to

Learning objectives · CLO 1 and CLO 4

Name the four parts

Variables, parameters, objective, constraints, and find each one in a written problem.

State the five stages

The artifact each stage produces, and the characteristic failure of each.

Classify a problem

LP, NLP, IP, MILP, stochastic, global, and which solver class each one needs.

Explain the vertex

Why an LP with a finite optimum has an optimal corner, geometrically.

Separate the two failures

Infeasible from unbounded, and what each says about the model.

Place the tools

What the modeling layer and the solver layer each do, and which week uses which.

The one-minute pitch

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.

Four questions. Sixty seconds.

Activity 1

  1. My name is ___
  2. I graduated from ___ (university, degree, field)
  3. Currently I am working with ___ (advisor, research group, or company)
  4. I am here because ___ (what you want out of this course)

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.

What optimization is, and the five stages

Lecture block 1 · 35 minutes

One definition, one diagram,
and one small problem walked end to end.

Choosing, under constraints, against a stated criterion

What optimization is

Optimization is the discipline of choosing, under constraints, against a stated criterion.

If nothing is chosen

It is simulation. A model evaluated, not searched.

If nothing constrains

The answer is trivial, and the model is wrong.

If the criterion is unstated

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.

Where it appears in process engineering

Four places, one mathematics

Design

Equipment sizing. Reactor network selection. Heat exchanger network synthesis. Superstructures: which route to build at all.

Planning and scheduling

Product mix on shared equipment, today’s example. Multiperiod production and inventory, Week 2. Blending and pooling, Week 4.

Operation

Set-point selection and real-time optimization. Battery dispatch against a tariff. Debottlenecking: where is the next hour worth most.

Data and experiment

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.

Five stages. Every week of this course.

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.

What each stage produces, and how each one fails

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.

Stage 1 · a plant that makes two things

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.

Stage 2 · the structured specification

Written before any algebra

Object Symbol Meaning Units
set pP product on the shared equipment
set rR 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

  1. Hours used on each resource cannot exceed hours available.
  2. Production cannot be negative.
  3. Everything produced can be sold, so there is no demand limit.

R3 is an assumption. Writing it down as a numbered restriction is exactly what makes it possible to challenge it later.

Stage 3 · the algebra, and the units check

The mathematics, and the thirty-second habit

General form

maximize   Σp cp xp   over x ≥ 0

subject to   Σp arp xpbr   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.

Stage 4 · the same model in two dialects

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.

Stage 5 · the solution, and what it actually says

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.

The number you take to a capital request

And the range over which it is true

  • Buy reactor hours The first extra hour is worth 100 USD. So is the second. The shadow price is what a capacity purchase is worth per hour, before you negotiate a price.
  • Do not buy separation Its shadow price is zero. Adding capacity there buys nothing, because separation is not what stops the plan.
  • But shadow prices are local Raise packaging from 9 h to 14 h and the margin reaches only 3,400.00 USD/week, at the plan (4, 6). The hundred dollars an hour stops paying once a different constraint takes over.
  • Which is why Week 8 exists Sensitivity analysis gives the exact range over which each shadow price holds. Quoting one outside its range is a stage-5 failure.

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

Anatomy, classification, geometry

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.

Every optimization problem is exactly four things

Anatomy

  1. Decision variables The quantities you are free to choose, collected in the decision vector x with n components. A quantity you cannot change is a parameter, not a variable.
  2. Parameters Numbers fixed before the problem is solved: prices, capacities, yields, demands, constants. They are the data.
  3. Objective function One scalar function f(x) measuring how good a choice is. Maximizing f is the same as minimizing minus f, so every problem can be written as a minimization.
  4. Constraints The rules a choice must satisfy: inequalities g(x) ≤ 0, equalities h(x) = 0, and simple bounds on x.

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.

Types, and one decision that is yours

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
xLxxU 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.

Two questions settle almost every case

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.

One example each, and what each class promises

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 eE/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

“I rounded the LP answer, so I solved the integer problem”

A sentence to be suspicious of

The claim

It sounds reasonable

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

It is wrong

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.

Optimal, infeasible, unbounded

Three outcomes, read in this order

Optimal

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.

Infeasible

No plan satisfies every constraint at once. The feasible region is empty. This is a statement about the model.

Unbounded

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.

Two broken models, one afternoon apart

What each failure looks like

Infeasible

Two requirements that cannot both hold

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

A missing constraint, exhibited as a ray

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.

The feasible region is a polytope

LP geometry · 1 of 3

246810 2468 x₁ Additive, t/week x₂ Binder, t/week (0,0)(8,0)(6,3)(2,7)(0,8) reactor 3x₁+2x₂ ≤ 24separation x₁+2x₂ ≤ 16packaging x₁+x₂ ≤ 9feasible region
  • Each constraint is a half plane The region is the intersection of five of them: three resources, two non-negativity bounds.
  • An intersection of half planes is convex It has flat faces. Such a set is a polyhedron, and when it is bounded, a polytope.
  • Its corners are the vertices In two variables a vertex is where two constraint boundaries meet. Here there are five.
  • Convexity is what makes LP easy And it is exactly what pooling destroys in Week 4.

The gradient, and the isoprofit lines

LP geometry · 2 of 3

246810 2468 x₁ Additive, t/week x₂ Binder, t/week isoprofit: z = 1200, 1800, 2400 ∇z = (400, 300)
  • The dotted lines are isoprofit lines The margin takes the same value along each one. They are parallel, with slope minus four thirds.
  • The arrow is the objective gradient It is the coefficient vector (400, 300), perpendicular to every isoprofit line, pointing where the margin rises fastest.
  • A linear objective has a constant gradient It is the same at every point. One improving direction for the whole plane, and it never changes.
  • So solving the LP is one geometric act Push the isoprofit line as far as it goes along the gradient, while keeping at least one feasible point on it.

Push until it last touches

LP geometry · 3 of 3

246810 2468 x₁ Additive, t/week x₂ Binder, t/week last touching line, z = 3300 x* = (6, 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.

Your research as an optimization problem

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.

Five lines. Fifteen minutes.

Activity 2

Your card

  1. One decision that you, your advisor or your company actually has to make.
  2. The decision variables, with units.
  3. The objective, maximum or minimum, with units.
  4. Two constraints, written in words.
  5. Your guess at the class: LP, NLP, IP, MILP or stochastic.
  1. 0 to 6 min · alone Write the card.
  2. 6 to 11 min · in pairs Exchange. Find one thing your partner left undefined.
  3. 11 to 15 min · plenary Three cards read out and classified live.

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

The tool stack

Lecture block 3 · 40 minutes

What each layer does, what it cannot do,
and which one this course uses in which week.

Two layers, and neither knows what the other knows

The stack

Modeling layer

Excel Solver

Target cell, changing cells, constraints, all on a worksheet

Modeling layer

OpenSolver

The same worksheet layout, sent to CBC or HiGHS instead

Modeling layer

Pyomo

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

What each tool is for, and where it stops

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.

One model, three ways, one answer

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:D14F12: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.

Weeks 1 to 3 Excel. Week 4 Python. And why.

The tool plan, designed and not accidental

Weeks 1 to 3 · Excel and OpenSolver

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.

Week 4 · the crossover to Python

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.

Weeks 5 onward · Python and Pyomo

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.

The fifteen weeks

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.

How you are graded

Assessment, homework, project

Weights

Final examination
35 %
Midterm examination
25 %
Assignments, HW1 to HW4
15 %
Computational project
15 %
Participation and quizzes
10 %

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

What the AI policy actually says

Read this before you ask

Permitted, and expected

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.

What is graded is verification

Disclose which parts were AI-drafted and which tests validated them. The disclosure section is part of the project report.

No credit without it

An unverified generated model earns no credit for model correctness, however good it looks.

Prohibited in examinations

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.

Numbers established today

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 parts, five stages Variables, parameters, one objective, constraints. Verbal, specification, algebra, code, interpretation. Stage 2 before any algebra, and a unit on every symbol.
  • The class decides the guarantee And rounding an LP answer is not an integer method.
  • The optimum is at a corner Convex polytope, constant gradient, so the isoprofit line stops at a vertex. Week 7 makes that an algorithm.
  • Read the status first Infeasible means the constraints contradict each other. Unbounded means one is missing.

Before we meet again

Four things, and one of them is not optional

  1. Install the environment 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.
  2. Enable Excel Solver File, Options, Add-ins, Manage: Excel Add-ins, Go, tick Solver Add-in. Then install OpenSolver from opensolver.org, unzipped outside Downloads.
  3. Run the Week 1 notebook W01_introduction_first_model.ipynb, end to end, including Exercises 1 to 3.
  4. Bring a working laptop to Week 2 There is no clinic time in Week 2.

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

How was today?

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

QR code linking to the weekly feedback form

Scan now — I will wait