LCCC Workshop: System Design Meets Equation-based Languages Sep 20, 2012 Carl D. Laird, Assistant Professor Chemical Engineering, Texas A&M University William E. Hart, Jean-Paul Watson, John D. Siirola Sandia National Laboratories, Albuquerque, NM David L. Woodruff, Professor Business Management, University of California, Davis Thursday, September 20, 12
Pyomo - Python Optimization Modeling Objects • Algebraic equation-based modeling language for optimization - e.g AMPL, GAMS, AIMMS - acausal, equation-based modeling - currently no support for differential equations - initially driven by large-scale MILP • Designed by Math Programmers for Math Programmers - open-source, extensible alternative to existing tools - used to enable research and engineering solutions • I work on algorithms and applications - I am a user of modeling languages, ... right? 2 Thursday, September 20, 12
Typical Algebraic Modeling Language Model Solver Definition Interface File Data Solution File 3 Thursday, September 20, 12
Typical Algebraic Modeling Language Model Solver Definition Interface File Data Solution File • Provide powerful, high-level problem specification • Familiar math programming constructs (Sets, expressions) • Very limited programming / scripting capability - model transformations? language extensions? - plotting? functions? numerical libraries? 3 Thursday, September 20, 12
Seasonal Drivers in Infectious Disease Spread 10000 Seasonal Nonlinear Discrete- 5000 Drivers? Time Disease Model 0 1944 1949 1954 4 Thursday, September 20, 12
Seasonal Drivers in Infectious Disease Spread 10000 1$ 0.8$ Seasonal Nonlinear Discrete- 5000 Drivers? Time Disease Model 0.6$ 0.4$ 0$ 2$ 4$ 6$ 8$ 10$ 12$ 0 1944 1949 1954 4 Thursday, September 20, 12
Seasonal Drivers in Infectious Disease Spread 10000 1$ 0.8$ Seasonal Nonlinear Discrete- 5000 Drivers? Time Disease Model 0.6$ 0.4$ 0$ 2$ 4$ 6$ 8$ 10$ 12$ 0 1944 1949 1954 Large Mixed Integer Non-Linear Programming Problem 4 Thursday, September 20, 12
Seasonal Drivers in Infectious Disease Spread 10000 1$ 0.8$ Seasonal Nonlinear Discrete- 5000 Drivers? Time Disease Model 0.6$ 0.4$ 0$ 2$ 4$ 6$ 8$ 10$ 12$ 0 1944 1949 1954 Large Mixed Integer Non-Linear Programming Problem 4 Thursday, September 20, 12
Parallel Decomposition in Interior-Point Methods 5 Thursday, September 20, 12
Parallel Decomposition in Interior-Point Methods 5 Thursday, September 20, 12
Parallel Decomposition in Interior-Point Methods X • Nonlinear Stochastic Optimization min f q ( x q ) x q ,y • Large-scale Parameter Estimation q ∈ Q s . t . c q ( x q ) = 0 • Design Under Uncertainty x L q ≤ x q ≤ x U ∀ q ∈ Q • Spatially Decomposable Problems q L x q x q − L y q y = 0 , • Very large-scale NLP Problems - Highly Structured 6 Thursday, September 20, 12
Parallel Decomposition in Interior-Point Methods X • Nonlinear Stochastic Optimization min f q ( x q ) x q ,y • Large-scale Parameter Estimation q ∈ Q s . t . c q ( x q ) = 0 • Design Under Uncertainty x L q ≤ x q ≤ x U ∀ q ∈ Q • Spatially Decomposable Problems q L x q x q − L y q y = 0 , • Very large-scale NLP Problems - Highly Structured 6 Thursday, September 20, 12
Parallel Decomposition in Interior-Point Methods X min f q ( x q ) x q ,y q ∈ Q s . t . c q ( x q ) = 0 x L q ≤ x q ≤ x U ∀ q ∈ Q q L x q x q − L y q y = 0 , Parallel solution of structured linear system 7 Thursday, September 20, 12
Parallel Decomposition in Interior-Point Methods X min f q ( x q ) x q ,y Parallel construction/evaluation q ∈ Q of equations, J, H s . t . c q ( x q ) = 0 x L q ≤ x q ≤ x U ∀ q ∈ Q q L x q x q − L y q y = 0 , Parallel solution of structured linear system 7 Thursday, September 20, 12
Other Examples of Applications Parallel Parameter Estimation for Spatial Transportation Affecting Disease Spread Optimal Response to Water Contamination Events 8 Thursday, September 20, 12
Model Solver Definition Interface File Data Solution Optimization File File Package Write Input Files Parse Output Files Compiled C++ Matlab Python Fragile tool chain 9 Thursday, September 20, 12
Two Choices 2. Use programming language 1. Design new language - develop components - modeling, scripting in another language syntax - import types/functionality - compiler tools 10 Thursday, September 20, 12
Two Choices 2. Use programming language 1. Design new language - develop components - modeling, scripting in another language syntax - import types/functionality - compiler tools • Selected to develop in Python (Choice 2) - tired of writing parsers - not language experts - existing tools are not actively updated - not responsible for full language functionality and packages - want full-featured language and user-extensibility (for “free”) 10 Thursday, September 20, 12
Requirements • Powerful - full support for standard math programming constructs (LP, MILP, NLP, MINLP, ...) - full-featured programming environment (model interrogation, scripting, functions, classes, standard & numerical libraries) - extensive solver integration - “out-of-the-box” • Open - licensed under BSD (i.e. really open-source) - reduce barriers to adoption, ease of collaboration - transparency • Flexible - extensible by users, contributors, not only by us - portable (Windows, Linux, OS X) • Easy - language constructs familiar to math programmers - Abstract Models - scripting / programming capability well-defined - substantial documentation 11 Thursday, September 20, 12
Why Python? • License - open-source • Language Features - familiar, lean syntax, rich set of existing data types, object- oriented, exceptions, dynamic loading, ... • Support and stability - highly stable, well-supported • Documentation - extensive online documentation, several books • Libraries - significant external libraries, numerical & scientific packages • Portability - widely available on many platforms 12 Thursday, September 20, 12
Simple Modeling Example: Knapsack : set of items (set) S : value of item i (param) v i : weight of item i (param) w i : maximum weight (param) W max : binary indicator (var) x i X v i · x i max i ∈ S X w i · x i ≤ W max s.t. i ∈ S x i ∈ { 0 , 1 } ∀ i ∈ S 13 Thursday, September 20, 12
S : set of items from coopr.pyomo import * v i : value of items model = AbstractModel() w i : weight of items model.ITEMS = Set() model.v = Param( model.ITEMS, within=PositiveReals ) W m : maximum weight model.w = Param( model.ITEMS, within=PositiveReals ) x i : binary indicator model.W_max = Param( within=PositiveReals ) model.x = Var( model.ITEMS, within=Binary ) X def value_rule(model): v i · x i max return sum( model.v[i]*model.x[i] for i in model.ITEMS ) i ∈ S model.value = Objective( sense=maximize ) X w i · x i ≤ W m s.t. def weight_rule(model): return sum(model.w[i]*model.x[i] for i in model.ITEMS) \ i ∈ S <= model.W_max x i ∈ { 0 , 1 } model.weight = Constraint( ) Knapsack Problem: Abstract Model 14 Thursday, September 20, 12
S : set of items from coopr.pyomo import * v i : value of items model = AbstractModel() w i : weight of items model.ITEMS = Set() model.v = Param( model.ITEMS, within=PositiveReals ) W m : maximum weight model.w = Param( model.ITEMS, within=PositiveReals ) x i : binary indicator model.W_max = Param( within=PositiveReals ) model.x = Var( model.ITEMS, within=Binary ) X def value_rule(model): v i · x i max return sum( model.v[i]*model.x[i] for i in model.ITEMS ) i ∈ S model.value = Objective( sense=maximize ) X w i · x i ≤ W m s.t. def weight_rule(model): return sum(model.w[i]*model.x[i] for i in model.ITEMS) \ i ∈ S <= model.W_max x i ∈ { 0 , 1 } model.weight = Constraint( ) Knapsack Problem: Abstract Model 15 Thursday, September 20, 12
S : set of items from coopr.pyomo import * v i : value of items model = AbstractModel() w i : weight of items model.ITEMS = Set() model.v = Param( model.ITEMS, within=PositiveReals ) W m : maximum weight model.w = Param( model.ITEMS, within=PositiveReals ) x i : binary indicator model.W_max = Param( within=PositiveReals ) model.x = Var( model.ITEMS, within=Binary ) X def value_rule(model): v i · x i max return sum( model.v[i]*model.x[i] for i in model.ITEMS ) i ∈ S model.value = Objective( sense=maximize ) X w i · x i ≤ W m s.t. def weight_rule(model): return sum(model.w[i]*model.x[i] for i in model.ITEMS) \ i ∈ S <= model.W_max x i ∈ { 0 , 1 } model.weight = Constraint( ) Knapsack Problem: Abstract Model 16 Thursday, September 20, 12
Recommend
More recommend