Toggle navigation
JUPYTER
FAQ
View as Code
View on GitHub
Execute on Binder
Download Notebook
CBE40455
notebooks
Notebook
CBE40455
¶
Chapter 1.0 Getting Started Guides
¶
1.1 Getting Started with CVXPY
¶
Installation
Solving linear equations
Using Matrix Parameters and Vector Variables
Regression: Evidence of Climate Change
Integer Program
Markdown Links
Jupyter notebook
CVXPY
here (.pdf)
here
Climatology office of the Minnesota Department of Natural Resources
1.2 Getting Started with Gurobi
¶
Simple Two-Variable LP
Assignment Problem
Problem Data
Model and Optimization
Solution
Markdown Links
Gurobi
1.3 Getting Started with GNU MathProg in Jupyter Notebooks
¶
GNU MathProg is a Mathematical Programming Language
Installing GLPK/MathProg to Run from a Jupyter Notebook
In the Cloud
Google Colaboratory
On your Laptop
Testing
Running GLPK/MathProg from Code Cells
Specifying Input Files for MathProg
Redirecting MathProg Output
Working with MathProg Tables
Reading and Writing Data from .csv Files
MathProg implementation of Geometric Brownian Motion
Markdown Links
Jupyter notebook
GAMS
AIMMS
AMPL
LINDO/LINGO
MPL
XPRESS-MOSEL
[GNU MathProg](
http://en.wikibooks.org/wiki/GLPK/GMPL_(MathProg
)
AMPL book
GNU GLPK project
lpsolve
CBE40455
mybinder.org
mybinder.org
Anaconda
Enthought Canopy
Windows for GLPK web site
Homebrew package manager
'magic' commands
glpsol -m
http://www.neos-guide.org/content/diet-problem
1.4 Getting Started with Pandas
¶
Example: Relationship between Crude Oil Futures and Petroleum Stocks
Importing the Pandas Library
Reading Inventory Data from a Spreadsheet
Reading Futures Data with a Web API
Term Structure of Oil Futures
Markdown Figures
Screen%20Shot%202017-09-27%20at%2011.06.18%20AM.png
Markdown Links
Pandas
pandas-dev Cheat Sheet
Datacamp Cheat Sheet
Dataquest Cheat Sheet
tutorial
EIA
crude oil futures
Quandl
Python code
Chapter 2.0 Simulation of Discrete Event Systems
¶
2.1 Getting Started with SimPy
¶
Introduction to Modeling with SimPy
A Minimal SimPy Model
Adding a Process
Add Mutliple Instances of a Process
Processes that Manage their own State
Creating Simulation Objects
Adding a Reporter
Application Examples
Multiple Roombas
Markdown Links
SimPy
Introduction to Modeling with SimPy
2.2 Queuing Systems
¶
Poisson Processes and Exponential Distributions
Example: Simulate Customers Arriving at a Known Rate
Let's Provide Some Service to the Customers
Little's Law
Some analogies
Why is this important?
Lognormal Distributions of Service Time
Normal Distributions
Lognormal Distribution
Random Service Time
Let's add multiple Queues
Markdown Links
Poisson distribution
Little's law
2.3 Emergency Room Simulation
¶
Initializations
Poisson processes
Modeling patient arrivals as a Poisson process
Version 1. Basic simulation
Version 2. Adding an event log
Version 3. Converting the log to a Pandas DataFrame
Version 4. Plotting the DataFrame
Version 5. Modeling the emergency room queue and service providers
Version 6. How many service providers are required?
Calculating and plotting wait times
Histogram of wait times
Exercise: Further model development
Markdown Links
Poisson Process
simpy.Stores
2.4 Model Development in SimPy
¶
Processing the Simulation Log
Encapsulating a Process as a Python Class
References
Markdown Links
SimPy
create generators
Store
2.5 Extracting Information from Discrete-Event Simulations
¶
Installations
Gathering Data
Why do we need to gather data?
What data to log?
What should the historian do?
Implementation of an Historian Class
Using the Historian Class
Adding
write_log
statements to the simulation
Accessing simulation data
Accessing data using
data
method
Working with the dataframe
Plotting results
Using
plot
method
Plotting one variable
Distribution of waiting times for storage following reaction
2.6 Spankys Pizzeria
¶
Menu
Model
Simulation of Existing Operations
Should Spanky's add additional ovens?
Should Spanky's add additional servers?
2.7 Warehouse Fulfullment Operations
¶
Order Fulfillment Model
Order Processing
Order Generator
Event Logging
Fulfillment Class
Simulation
Analyzing Results
Total Processing Time
Time to Assign Picker
Time to Pick Order
Time to Assign Reviewer
Time to Review Order
Time to Ship
Markdown Links
SimPy
2.8 Geometric Brownian Price Process
¶
Multiple Simulations
2.9 Continuous Time Simulation in SimPy
¶
2.10 Decentralized Control in a Supply Chain
¶
Model
Inventory Model
Deviation Variables
Inventory Model in Deviation Variables
Ordering Policies
Feed-forward Ordering based on Customer Demand
Ordering based on Feedback Control of Inventory
Ordering based on 2DOF Feedback Control of Inventory
A 3 DOF Feed-forward plus Feedback Ordering Policy
Closed-Loop Model
Chapter 3.0 Linear Optimization
¶
3.1 Production Models with Constraints
¶
Initializations
Example: Production Plan for a Single Product Plant
Pyomo Model
Exercises
Production Plan: Product Y
Exercises
Production Plan: Mixed Product Strategy
What are the active constraints?
What is the incremental value of labor?
Theory of Constraints
Markdown Figures
LP_ProductX
LP_ProductY
LP_ProductXY
Markdown Links
Pyomo
glpk
3.2 Transportation Networks
¶
Background
Table of Transportation Costs, Customer Demand, and Available Supplies
Pyomo Model
Data File
Model File
Solution
Sensitivity Analysis
Analysis by Source
Analysis by Customer
Exercises
Markdown Figures
TransportationNetworksMap.png
TransportNet
TransportNet_soln
TransportNet_sens
Markdown Links
pdf available
3.3 Data Reconciliation
¶
Data Reconciliation and Gross Error Detection
Heat Exchanger with Bypass
Visualization
Chapter 4.0 Scheduling
¶
4.1 Critical Path Method
¶
Background
MathProg Model
Example: Stadium Construction
Visualization
Markdown Links
Example 7.1.1
Christelle Gueret, Christian Prins, Marc Sevaux, "Applications of Optimization with Xpress-MP," Chapter 7, Dash Optimization, 2000
4.2 Machine Bottleneck
¶
Example
Modeling
Data
Decision Variables
Pyomo Model
Visualization
Multiple Machines
4.3 Job Shop Scheduling
¶
Background
Job Shop Example
Task Decomposition
Model Formulation
Pyomo Implementation
Displaying a Solution
Visualizing Results with Gantt Charts
Benchmark Problem LA19
Application to Scheduling of Batch Processes
Single Product Strategies
Overlapping Tasks
Unit Cleanout
Zero Wait Policy
Markdown Figures
jobshopdiagram.jpg
Screen%20Shot%202017-09-14%20at%209.09.57%20AM.png
4.4 Jesuit Volunteer Corps
¶
Background
Solution
4.5 Unit Commitment
¶
Install Pyomo and Solvers for Google Colaboratory
Install and Import Pyomo
Install COIN-OR BONMIN and Create Solver
Unit Specifications
Unit Commitment Model 1. Constant Demand without Uptime or Downtime Constraints
Cost
Unit Commitment Strategy
Unit Commitment Model 2. Variable Demand without Uptime or Downtime Constraints
Unit Commitment Model 3. Variable Demand with Uptime and Downtime Constraints
Markdown Links
Unit Commitment
Dispa-Set
4.6 Scheduling Multipurpose Batch Processes using State-Task Networks
¶
References
Example (Kondili, et al., 1993)
Exercise
Encoding the STN data
Setting a Time Grid
Creating a Pyomo Model
Characterization of Tasks
Characterization of States
Characterization of Units
Pyomo Model
Analysis
Profitability
State Inventories
Unit Assignment
Unit Batch Inventories
Gannt Chart
Trace of Events and States
Markdown Figures
Screen%20Shot%202017-09-16%20at%209.45.36%20PM.png
Chapter 5.0 Logistics
¶
5.1 Economic Order Quantity
¶
Initializations
Economic Order Quantity (EOQ)
Markdown Links
Jupyter notebook
5.2 Assignment Problems
¶
Example Problem
Combinatorial Complexity
Types of Complexity
Formulation of a Basic Assignment Problem
Solution
Solution using CVXPY
Example
What is the minimum time solution if one worker is assigned to each job?
What is the minimum time solution if workers can be assigned multiple times?
Exercise
Knapsack Problems
Typical Applications
Example
Exercise
5.3 Vehicle Routing
¶
5.4 Vehicle Routing with Time Windows
¶
5.5 Traveling Salesman Problem with Time Windows
¶
Problem Description
5.6 Pickup and Delivery
¶
Problem Description
Data Set
MathProg Model
5.7 Stock Cutting
¶
Background
Markdown Links
IPython notebook
Chapter 6.0 Optimization under Uncertainty
¶
6.1 Newsvendor Problem
¶
Background
Solution
Expected Value for the Mean Scenario (EVM)
Expected Value with Perfect Information (EVPI)
Expected Value by Stochastic Programming
Value of Perfect Information
Value of the Stochastic Solution
6.2 Scenario Analysis for a Plant Expansion
¶
6.3 Risk Neutral Gambler
¶
Problem Statement
Formulation
Solution by Linear Programming
MathProg Model
Markdown Links
Reinforcement Learning
(MIT Press, 1998)
Introduction to Stochastic Dynamic Programming
(Academic Press, 1983)
6.4 Risk Averse Gambler
¶
Problem Statement
Solution by Stochastic Dynamic Programming
Solution by Linear Programming
MathProg Model
6.5 Points after Touchdown Decision
¶
Initializations
Multi-Stage Model of the Decision Process
Transition Probabilities
Opponent's Decisions After the Last Possession
Visualization
Decision Prior to the Opponent's Last Possession
Visualization
Decision Chart
Odds of Winning
Analysis of Three Cases (To be completed)
Northwestern at Notre Dame, 2014
Notre Dame at Clemson, 2015
Georgia Tech at Notre Dame, 2015
Chapter 7.0 Risk and Diversification
¶
7.1 Measuring Return
¶
Imports
Where to get Price Data
Yahoo Finance
Google Finance
Quandl
Returns
Linear fractional or Arithmetic Returns
Linear returns don't tell the whole story.
Compounded Log Returns
Volatility Drag and the Relationship between Linear and Log Returns
Markdown Links
Yahoo Finance
Google Finance
Quandl
Yahoo Finance
Adjusted Close
Google Finance
Quandl
Quandl API
Quandl Python package
7.2 Geometric Brownian Motion
¶
Python Imports and Utility Functions
Statistical Properties of Returns
Distribution of Returns
Distribution of First Half versus Second Half of the Data Set
Lag Plot of $r^{log}_{t+1}$ versus $r^{log}_t$
Autocorrelation
Fitting Returns to a Distribution
Normal Distribution
Geometric Brownian Motion
Linear Returns
Log Returns
Forecasting
Simulation using Generators
Markdown Links
pandas-datareader
7.3 Binomial Model for Pricing Options
¶
Historical Data
Binomial Model
European Call Option
Implementing a Replicating Portfolio with Pyomo
European Put Option
Early Exercise
American Put Option
Markdown Figures
BinomialModel
BinomialModel_Options
Markdown Links
Luenberger (2013)
7.4 Real Options
¶
Implementing a Replicating Portfolio in Pyomo
Example 1. Value of a fixed cash flow
Example 2. Simplico Gold Mine
Solution
Example 3. Simplico Gold Mine Capital Investment
Price Model
Growth Model
Markdown Figures
../img/TimelineRealOption.png
../img/BinomialRealOption.png
Markdown Links
analysis of Martin Haugh
7.5 Portfolio Optimization
¶
Import libraries
Load Price Data
Plot Price and Returns Data
Linear and Log Returns
Covariance and Correlation Matrices
Visualizing the correlation coefficients
Creating Portfolios
Mean Return and Variance of a Portfolio
Examples of Portfolios with Two Assets
Minimum Risk Portfolio
Pyomo Model and Solution
Out-of-Sample Simulation
Markowitz Portfolio
Out of Sample Simulation
Risk-Free Asset
Maximum Log Return (to be developed).
Exercises
Markdown Links
Jupyter notebook
7.6 Portfolio Optimization using Mean Absolute Deviation
¶
Background
Mean Absolute Deviation
Reformulation of the MAD Objective
Seeding the GLPK Pseudo-Random Number Generator
Simulation of the Historical Returns
MathProg Model
Markdown Links
IPython notebook
GLPK Wikibook tutorial on the subject
A complete tutorial
GLPK wikibook
7.7 Portfolio Optimization
¶
Investment Objectives
Why Diversify?
Reduce Risk through Law of Large Numbers
Select a Portfolio from a Set of Candidate Portfolios
Download Historical Data
Equally Weighted Portfolio
Compute Component Returns
MAD Porfolio
Problem 1: Solve for Dominating MAD Portfolio
Markdown Links
IPython notebook
GLPK Wikibook tutorial on the subject
http://github.com/jckantor/CBE20255
Creative Commons Attribution Noncommericial ShareAlike License
7.8 Log-Optimal Growth and the Kelly Criterion
¶
Initializations
What are the Issues in Managing for Optimal Growth?
Why Maximizing Expected Wealth is a Bad Idea
Exercise
Utility Functions
Maximizing Growth
Kelly's Criterion: Maximizing Growth for a Game with Arbitrary Odds
Volatility Pumping
Markdown Figures
Kelly_Criterion_Fig1
Kelly_Criterion_Fig2
Kelly_Criterion_Volatility_Pumping
Markdown Links
IPython notebook
7.9 Log-Optimal Portfolios
¶
Initializations
Kelly's Criterion
Example 1. Maximizing Return for a Game with Arbitrary Odds
Example 2. Betting Wheel
Example 3. Stock/Bond Portfolio in Continuous Time
Volatility Pumping
Markdown Figures
Kelly_Criterion_Fig2
Kelly_Criterion_Volatility_Pumping
Chapter 8.0 Optimization in Google Sheets
¶
Markdown Links
Production Planning with Constraints (Google Sheet)
SEMD Refinery (Google Sheet)
Transportation Network Optimization (Google Sheet)
Project Management with the Critical Path (Google Sheet)
Machine Bottleneck Scheduling (Google Sheet)
Stochastic Programming: Two Stage Solution for the Newsvendor Problem (Google Sheet)
Knapsack Problem (Google Sheet)
Stock Cutting (Google Sheet)
Soduko Solver 4x4 (Google Sheet)
Chapter 9.0 Student Projects
¶