Optimization Modeling for Chemical Engineers
Worked Problems with Pyomo
Preface
This workbook develops mathematical optimization models for graduate students in chemical engineering. Each chapter connects a process description to equations, executable Pyomo code, a verified numerical solution, and a brief engineering interpretation.
The problem collection is based on Williams (2013). Source problem numbers and any changes are stated in each chapter. The explanations, Python implementations, and figures are prepared for this workbook. Numerical results are generated by solving the models, rather than transcribed from the textbook.
How to use this workbook
- Read the problem statement and sketch the material flows before looking at the formulation.
- Define decision variables with units. Distinguish inputs from decisions.
- Explain each constraint in words before implementing it.
- Run the code and check feasibility before interpreting the objective value.
- Change one assumption at a time and explain the resulting decision.
Basic material balances, algebra, and Python are assumed. The first chapter introduces linear programming through blending and inventory planning; it does not assume prior Pyomo experience.
Computational approach
Pyomo describes the optimization model. HiGHS solves the linear program. Pandas organizes results, and Matplotlib generates figures using the lab’s skh_palette module. The source .qmd files and accompanying .py files are the editable master copies.
The code uses the Pyomo APPSI interface. Rendering instructions and the tested package versions are provided in README.md and requirements.txt.
Scope and source mapping
The workbook contains all 29 problem themes from Chapter 12 of Williams (2013), in the source order. Chapter 1 retains the original data; Chapter 2 extends it with the original logical restrictions. Most later chapters use explicitly labeled, smaller teaching instances. Problem numbers identify the source theme, not a claim that the numerical data or answer reproduce the textbook.
Every chapter follows the same sequence: Problem Statement → Model Formulation → Pyomo Implementation → Optimal Solution → Brief Discussion. Every reported reference solution was computed with Pyomo and HiGHS, with feasibility and problem-specific checks. Some small combinatorial examples are additionally checked by exhaustive enumeration or dynamic programming.
The pricing chapter uses finite menus rather than continuous nonlinear pricing. The folding chapter uses an eight-residue square lattice and exhaustive conformations rather than the source 50-residue non-lattice problem. These choices make the exercises runnable and inspectable, but their optimality claims apply only to the explicitly stated adapted models.
Reproducibility
Run ./scripts/build.sh from the project root. A Quarto pre-render step re-solves Chapters 2–29, runs checks, regenerates their Python figures, and writes their .qmd chapters. Chapter 1 executes through the optim Jupyter kernel. All figures have editable Python source in figures/ and export to SVG, PDF, and 600 dpi PNG.
For Chapters 2–29, the authored problem statements, formulations, code, and discussions live in models/problemNN.py; generated .qmd files should be edited through those sources. This arrangement keeps the rendered code and numerical tables synchronized. For Chapter 1, edit its .qmd and models/food_manufacture.py directly.
Download the shared solver and validator. It is used by the worked examples and checks optimal termination before loading a solution. Individual chapter pages link to their own model sources and machine-readable results. To run a chapter, preserve the models/ folder structure and run its command from the workbook root.
Download the complete editable source bundle, including all 29 chapters, model scripts, figure scripts, the lab palette, and build instructions. Reference screenshots are not included.