Path: blob/main/notebooks/05/05-refinery-production.ipynb
940 views
Extra material: Refinery production and shadow pricing with CVXPY
This is a simple linear optimization problem in six variables, but with four equality constraints it allows for a graphical explanation of some unusually large shadow prices for manufacturing capacity. The notebook presents also contrasts Pyomo with CVXPY modeling.
Preamble: Install Pyomo and a solver
The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object SOLVER for later use.
This example derived from Example 19.3 from Seborg, Edgar, Mellichamp, and Doyle.
Seborg, Dale E., Thomas F. Edgar, Duncan A. Mellichamp, and Francis J. Doyle III. Process dynamics and control. John Wiley & Sons, 2016.
The changes include updating prices, new solutions using optimization modeling languages, adding constraints, and adjusting parameter values to demonstrate the significance of duals and their interpretation as shadow prices.
Problem data
Pyomo Model
CVXPY Model
The CVXPY library for disciplined convex optimization is tightly integrated with numpy, the standard Python library for the numerical linear algebra. For example, where Pyomo uses explicit indexing in constraints, summations, and other objects, CVXPY uses the implicit indexing implied when doing matrix and vector operations.
Another sharp contrast with Pyomo is that CXVPY has no specific object to describe a set,or to define a objects variables or other modeling objects over arbitrary sets. CVXPY instead uses the zero-based indexing familiar to Python users.
The following cell demonstrates these differences by presenting a CVXPY model for the small refinery example.
Crude oil feed results
Refinery production results
Why is the shadow price of kerosine so high?
Suggested Exercises
Suppose the refinery makes a substantial investment to double kerosene production in order to increase profits. What becomes the limiting constraint?
How do prices of crude oil and refinery products change the location of the optimum operating point?
A refinery is a financial asset for the conversion of commodity crude oils into commodity hydrocarbons. What economic value can be assigned to owning the option to convert crude oils into other commodities?