What an optimal plan is worth to change: what one more hour of a scarce resource adds, how far that value holds, how far a price can move before the plan changes, and how to value a set of offers by re-solving the model.
Slides¶
Present full screen Download the PDF
Click or tap the slide to move forward, its left edge to go back; the arrow keys work too.
Reading¶
Sensitivity Analysis: What Is One More Hour Worth? takes last week’s kitchen plan (53,900 SAR a week) and asks what it is worth to change it. It finds the shadow prices of the roaster (390 SAR an hour) and the staff (175 SAR), sweeps the hours to see where those prices stop holding, prices out the four products, solves the dual, and values four offers on the manager’s desk, alone and in all 16 combinations.
Lab 10: What-if app over a linear program¶
Four offers are on the kitchen manager’s desk for next month: a second roaster shift, staff overtime, hours on a neighbour’s oven and a House Blend campaign. Valued with the shadow prices, the overtime looks like the best deal. You check every shadow price by re-solving, sweep the staff hours to find where the overtime stops paying, test the branches’ proposal to cut the price of Saffron Cake, then write a Streamlit app in which the manager sets the hours, ticks the offers and reads the net gain.
Open the lab, then use its Open in Colab button. Its first cells install PuLP in Colab.
Data: qahwa
_roastery _mix .csv (week 9’s model) and qahwa _roastery _options .csv (the four offers: what each adds and what it costs a week). The notebook downloads both by itself. Submit the notebook and your
whatif_app.pybefore the next lab session. The solutions are for checking your work afterwards.
Running the app¶
Colab cannot display a Streamlit page, so the lab tests the app with Streamlit’s AppTest. To see it in a browser:
GitHub Codespaces (free with GitHub Education) or your own computer: open a terminal in the folder with the app, run
pip install streamlit pandas "pulp[highs]>=4.3,<5", thenstreamlit run whatif_app.py. A browser tab opens athttp://localhost:8501.Share it: push the app and a
requirements.txtto a GitHub repository and deploy it on Streamlit Community Cloud, choosing the repository and the file. You get a public link.
The finished course version, with the hours, the contributions and demand limits, the offers, the plan with its reduced costs, the shadow prices, each offer valued alone and a sweep chart of any resource: app.py and its requirements.txt. In a clone of the course repository, run it with streamlit run week10/app/app.py.
Next week¶
Modeling patterns: multiperiod planning, blending, transportation and network flow models in PuLP.