Pyomo — Optimization Modeling in Python Second Edition Springer Optimization and Its Applications
Total Page:16
File Type:pdf, Size:1020Kb
Springer Optimization and Its Applications 67 William E. Hart Carl D. Laird Jean-Paul Watson David L. Woodruff Gabriel A. Hackebeil Bethany L. Nicholson John D. Siirola Pyomo — Optimization Modeling in Python Second Edition Springer Optimization and Its Applications VOLUME 67 Managing Editor Panos M. Pardalos (University of Florida) Editor–Combinatorial Optimization Ding-Zhu Du (University of Texas at Dallas) AdvisoryBoard J.Birge(UniversityofChicago) S. Butenko (Texas A&M University) F.Giannessi(UniversityofPisa) H.D.Sherali(VirginiaPolytechnicandStateUniversity) T.Terlaky(LehighUniversity) Y. Ye(StanfordUniversity) Aims and Scope Optimization has been expanding in all directions at an astonishing rate during the last few decades. New algorithmic and theoretical techniques have been developed, the diffusion into other disciplines has proceeded at a rapid pace, and our knowledge of all aspects of the field has grown even more profound. At the same time, one of the most striking trends in optimization is the constantly increasing emphasis on the interdisciplinary nature of the field. Optimization has been a basic tool in all areas of applied mathematics, engineering, medicine, economics, and other sciences. The series Springer Optimization and Its Applications publishes under- graduate and graduate textbooks, monographs and state-of-the-art exposi- tory work that focus on algorithms for solving optimization problems and also study applications involving such problems. Some of the topics covered include nonlinear optimization (convex and nonconvex), network flow problems, stochastic optimization, optimal control, discrete optimization, multi-objective programming, description of software packages, approxima- tion techniques and heuristic approaches. More information about this series at http://www.springer.com/series/7393 William E. Hart • Carl D. Laird Jean-Paul Watson • David L. Woodruff Gabriel A. Hackebeil • Bethany L. Nicholson John D. Siirola Pyomo — Optimization Modeling in Python Second Edition William E. Hart Carl D. Laird Sandia National Laboratories Sandia National Laboratories Albuquerque, New Mexico, USA Albuquerque, New Mexico, USA Jean-Paul Watson David L. Woodruff Sandia National Laboratories Graduate School of Management Albuquerque, New Mexico, USA University of California, Davis Davis, California, USA Gabriel A. Hackebeil Department of Industrial Bethany L. Nicholson and Operations Engineering Sandia National Laboratories University of Michigan Albuq uerq ue, New Mexic o, USA Ann Arbor, Michigan, USA John D. Siirola Sandia National Laboratories Albuquerque, New Mexico, USA ISSN 1931-6828 ISSN 1931-6836 (electronic) Springer Optimization and its Applications ISBN 978-3-319-58819-3 ISBN 978-3-319-58821-6 (eBook) DOI 10.1007/978-3-319-58821-6 Library of Congress Control Number: 2017940404 © Springer International Publishing AG 2012, 2017 This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Printed on acid-free paper This Springer imprint is published by Springer Nature The registered company is Springer International Publishing AG The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland This book is dedicated to future contributors to the Pyomo project. Preface This book describes a tool for mathematical modeling: the Python Optimization Modeling Objects (Pyomo) software. Pyomo supports the formulation and analysis of mathematical models for complex optimization applications. This capability is commonly associated with algebraic modeling languages (AMLs), which support the description and analysis of mathematical models with a high-level language. Although most AMLs are implemented in custom modeling languages, Pyomo’s modeling objects are embedded within Python, a full-featured high-level program- ming language that contains a rich set of supporting libraries. Modeling is a fundamental process in many aspects of scientific research, engi- neering and business, and the widespread availability of computing has made the numerical analysis of mathematical models a commonplace activity. Furthermore, AMLs have emerged as a key capability for robustly formulating large models for complex, real-world applications [53]. AMLs streamline the process of formulating models by simplifying the management of sparse data and supporting the natural ex- pression of model components. Additionally, AMLs like Pyomo support scripting with model objects, which facilitates the custom analysis of complex problems. The core of Pyomo is an object-oriented capability for representing optimization models. Pyomo also contains packages that define modeling extensions and model reformulations. For example, the pyomo.pysp package defines modeling exten- sions for stochastic programs as well as solvers that can analyze these problems. Pyomo also includes packages that define interfaces to solvers like CPLEX and Gurobi, as well as solver services like NEOS. Goals of the Book This second edition provides an updated description of Pyomo’s modeling capabil- ities. A key goal of this book is to provide a broad description of Pyomo that will enable the user to develop and optimize models with Pyomo. The book uses many examples to illustrate different techniques that can be used to formulate models. vii viii Preface Another goal of this book is to illustrate the breadth of Pyomo’s capabilities. Py- omo supports the formulation and analysis of common optimization models, includ- ing linear programs, mixed-integer linear programs, nonlinear programs, mixed- integer nonlinear programs, mathematical programs with equilibrium constraints, generalized disjunctive programs, bilevel programs, and stochastic programs. Addi- tionally, Pyomo includes solver interfaces for a variety of widely used optimization software packages, including CBC, CPLEX, GLPK, and Gurobi. Additionally, Py- omo models can be optimized with optimizers like IPOPT that employ the AMPL Solver Library interface. Finally, a goal of this book is to help users get started with Pyomo even if they have little knowledge of Python. Appendix A provides a quick introduction to Python, but we have been impressed with how well Python reference texts sup- port new Pyomo users. Although Pyomo introduces Python objects and a process for applying them, the expression of models with Pyomo strongly reflects Python’s clean, concise syntax. However, our discussion of Pyomo’s advanced modeling capabilities assumes some background in object-oriented design and features of the Python program- ming language. For example, our discussion of modeling components distinguishes between class definitions and class instances. We have not attempted to describe these advanced features of Python in the book. Thus, a user should expect to develop some familiarity with Python in order to effectively understand and use advanced modeling features. Who Should Read This Book This book provides a reference for students, academic researchers and practitioners. The design of Pyomo is simple enough that it has been effectively used in the class- room with undergraduate and graduate students. However, we assume that the reader is generally familiar with optimization and mathematical modeling. Although this book does not contain a glossary, we recommend the Mathematical Programming Glossary [45] as a reference for the reader. Pyomo is also a valuable tool for academic researchers and practitioners. A key focus of Pyomo development has been on the ability to support the formulation and analysis of real-world applications. Consequently, issues like run-time performance and robust solver interfaces are a priority. Additionally, we believe that researchers will find that Pyomo provides an ef- fective framework for developing high-level optimization and analysis tools. For example, Pyomo provides generic solvers for stochastic programming, and it lever- ages the fact that Pyomo’s modeling objects are embedded within a full-featured high-level programming language. This allows for transparent parallelization of sub-problems using Python parallel communication libraries. This ability to sup- port generic solvers for complex models is very powerful, and we believe that it can be used with many other optimization analysis techniques. Preface ix Revisions for the Second Edition We have made several major changes while preparing the second edition of this book. The book was divided