Skip to main content
Log in

pyomo.dae: a modeling and automatic discretization framework for optimization with differential and algebraic equations

  • Full Length Paper
  • Published:
Mathematical Programming Computation Aims and scope Submit manuscript

Abstract

We describe pyomo.dae, an open source Python-based modeling framework that enables high-level abstract specification of optimization problems with differential and algebraic equations. The pyomo.dae framework is integrated with the Pyomo open source algebraic modeling language, and is available at http://www.pyomo.org. One key feature of pyomo.dae is that it does not restrict users to standard, predefined forms of differential equations, providing a high degree of modeling flexibility and the ability to express constraints that cannot be easily specified in other modeling frameworks. Other key features of pyomo.dae are the ability to specify optimization problems with high-order differential equations and partial differential equations, defined on restricted domain types, and the ability to automatically transform high-level abstract models into finite-dimensional algebraic problems that can be solved with off-the-shelf solvers. Moreover, pyomo.dae users can leverage existing capabilities of Pyomo to embed differential equation models within stochastic and integer programming models and mathematical programs with equilibrium constraint formulations. Collectively, these features enable the exploration of new modeling concepts, discretization schemes, and the benchmarking of state-of-the-art optimization solvers.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4

Similar content being viewed by others

References

  1. Åkesson, J., Årzén, K.E., Gäfvert, M., Bergdahl, T., Tummescheit, H.: Modeling and optimization with Optimica and JModelica.org languages and tools for solving large-scale dynamic optimization problems. Comput. Chem. Eng. 34(11), 1737–1749 (2010)

    Article  Google Scholar 

  2. Andersson, J.: A General-purpose Software Framework for Dynamic Optimization. PhD thesis, Arenberg Doctoral School, KU Leuven, Department of Electrical Engineering (ESAT/SCD) and Optimization in Engineering Center, Kasteelpark Arenberg 10, 3001-Heverlee, Belgium (2013)

  3. Ascher, U.M., Mattheij, R.M., Russell, R.D.: Numerical Solution of Boundary Value Problems for Ordinary Differential Equations, vol. 13. SIAM, Philadelphia (1994)

    MATH  Google Scholar 

  4. Ascher, U.M., Petzold, L.R.: Computer Methods for Ordinary Differential Equations and Differential-algebraic Equations, vol. 61. SIAM, Philadelphia (1998)

    Book  MATH  Google Scholar 

  5. Betts, J.T.: Sparse Optimization Suite (SOS). Applied Mathematical Analysis, LLC (2013)

  6. Betts, J.T., Huffman, W.P.: Sparse optimal control software SOCS MEA-LR-085, Boeing Information and Support Services, The Boeing Company, PO Box. Math. Eng. Anal. Tech. Doc. 3707, 98, 124–2207 (1997)

    Google Scholar 

  7. Biegler, L.T.: Nonlinear Programming: Concepts, Algorithms, and Applications to Chemical Processes. SIAM, Philadelphia (2010)

    Book  MATH  Google Scholar 

  8. Bock, H.G., Plitt, K.J.: A multiple shooting algorithm for direct solution of optimal control problems. In: Proceedings of the IFAC World Congress (1984)

  9. Brenan, K.E., Campbell, S.L., Petzold, L.R.: Numerical Solution of Initial-value Problems in Differential-Algebraic Equations, vol. 14. SIAM, Philadelphia (1996)

    MATH  Google Scholar 

  10. Butcher, J.: Numerical Methods for Ordinary Differential Equations. Wiley (2003). https://books.google.com/books?id=nYuDWkxhDGUC

  11. Corporation, G.D.: General Algebraic Modeling System (GAMS) Release 24.2.1. Washington, DC, USA (2013). http://www.gams.com/

  12. Fourer, R., Gay, D., Kernighan, B.: AMPL: A Modeling Language for Mathematical Programming. Scientific Press (1993). https://books.google.com/books?id=8vJQAAAAMAAJ

  13. Frasch, J.: Parallel Algorithms for Optimization of Dynamic Systems in Real-Time. Ph.D. thesis, KU Leuven (2014)

  14. Hart, W., Laird, C., Watson, J., Woodruff, D.: Pyomo-optimization Modeling in Python, vol. 67. Springer, Berlin (2012)

    Book  MATH  Google Scholar 

  15. Hart, W., Watson, J., Woodruff, D.: Pyomo: modeling and solving mathematical programs in Python. Math. Program. Comput. 3(3), 219–260 (2011)

    Article  MathSciNet  Google Scholar 

  16. Hendengren, J.: APMonitor Modeling Language (2014). http://APMonitor.com

  17. Hindmarsh, A.C., Brown, P.N., Grant, K.E., Lee, S.L., Serban, R., Shumaker, D.E., Woodward, C.S.: SUNDIALS: suite of nonlinear and differential/algebraic equation solvers. ACM Trans. Math. Softw. 31(3), 363–396 (2005). https://doi.org/10.1145/1089014.1089020

    Article  MathSciNet  MATH  Google Scholar 

  18. Houska, B., Ferreau, H., Diehl, M.: ACADO toolkit—an open source framework for automatic control and dynamic optimization. Opt. Control Appl. Methods 32(3), 298–312 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  19. Hultberg, T.: FlopC++ an algebraic modeling language embedded in C. In: Waldmann, K.-H. (ed.)Operations Research Proceedings 2006, ser. Operations Research Proceedings, pp. 187–190. Springer, Berlin (2006)

  20. Jacobson, D., Lele, M.: A transformation technique for optimal control problems with a state variable inequality constraint. IEEE Trans. Autom. Control 14(5), 457–464 (1969). https://doi.org/10.1109/TAC.1969.1099283

    Article  Google Scholar 

  21. Kraft, D.: On converting optimal control problems into nonlinear programming problems. In: Schittkowski, K. (ed.) Computational Mathematical Programming, pp. 261–280. Springer, Berlin (1985)

  22. Leyffer, S., Kirches, C.: TACO–a toolkit for AMPL control optimization. Math. Program. Comput. 5(3), 227–265 (2013)

    Article  MathSciNet  MATH  Google Scholar 

  23. Lubin, M., Dunning, I.: Computing in operations research using julia. INFORMS J. Comput. 27(2), 238–248 (2015). https://doi.org/10.1287/ijoc.2014.0623

    Article  MathSciNet  MATH  Google Scholar 

  24. MATLAB: MATLAB Function Reference, chap. pdepe, pp. 6386–6397. The MathWorks Incorporated (2015)

  25. Mitchell, S., O’Sullivan, M., Dunning, I.: PuLP: A Linear Programming Toolkit for Python (2011)

  26. Patterson, M.A., Rao, A.V.: GPOPS-II: A MATLAB software for solving multiple-phase optimal control problems using hp-adaptive Gaussian quadrature collocation methods and sparse nonlinear programming. ACM Trans. Math. Softw. 41(1), 1:1–1:37 (2014). https://doi.org/10.1145/2558904

    Article  MathSciNet  MATH  Google Scholar 

  27. Process Systems Enterprise: gPROMS (1997–2014). www.psenterprise.com/gproms

  28. Rutquist, P., Edvall, M.: PROPT—Matlab Optimal Control Software. Tomlab Optimization Inc (2010)

  29. Santamara, F.L., Gmez, J.M.: Framework in PYOMO for the assessment and implementation of (as)nmpc controllers. Comput. Chem. Eng. 92, 93–111 (2016). https://doi.org/10.1016/j.compchemeng.2016.05.005. http://www.sciencedirect.com/science/article/pii/S0098135416301533

  30. Sargent, R., Sullivan, G.: The development of an efficient optimal control package. In: Stoer, J. (ed.) Optimization Techniques, Proceedings of the 8th IFIP Conference on Optimization Techniques Würzburg, September 5–9, 1977 pp. 158–168. Springer, Berlin (1978)

  31. Word, D.P.: Nonlinear Programming Approaches for Efficient Large-Scale Parameter Estimation with Applications in Epidemiology. PhD thesis, Texas A&M University, Department of Chemical Engineering, College Station, TX (2013)

  32. Word, D.P., Kang, J., Akesson, J., Laird, C.D.: Efficient parallel solution of large-scale nonlinear dynamic optimization problems. Comput. Optim. Appl. 59(3), 667–688 (2014)

    Article  MathSciNet  MATH  Google Scholar 

  33. Zavala, V.M.: Stochastic optimal control model for natural gas networks. Comput. Chem. Eng. 64, 103–113 (2014). https://doi.org/10.1016/j.compchemeng.2014.02.002. http://www.sciencedirect.com/science/article/pii/S0098135414000349

  34. Zavala, V.M., Laird, C.D., Biegler, L.T.: Interior-point decomposition approaches for parallel solution of large-scale nonlinear parameter estimation problems. Chem. Eng. Sci. 63(19), 4834–4845 (2008)

    Article  Google Scholar 

Download references

Acknowledgements

We thank Carl D. Laird for useful technical discussions and for providing the disease transmission model. Victor M. Zavala acknowledges funding from the U.S. Department of Energy Early Career program. The research was supported in part by the U.S. Department of Energy, Office of Science, Office of Advanced Scientific Computing Research, Applied Mathematics program under contract number KJ0401000 through the Project “Multifaceted Mathematics for Complex Energy Systems”. Sandia is a multi-program laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear Security Administration under Contract DE-AC04-94-AL85000.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Bethany Nicholson.

Appendix A: Code structure overview

Appendix A: Code structure overview

pyomo.dae introduces only a handful of new files and roughly 2,200 lines of code to the Pyomo code base. The pyomo.dae code can be broken into three categories:

  • Class definitions for new modeling components

  • Class definitions for discretization transformations

  • Miscellaneous utility functions

The files belonging to each category are described below.

1.1 A.1 New modeling components

The new modeling components introduced in pyomo.dae are derived from standard Pyomo components. This simplifies the implementation, enables code reuse, and ensures that these components are compatible with the downstream Pyomo infrastructure for writing out problems and reading in solutions.

1.1.1 contset.py

This file contains the ContinuousSet class which is derived from the Pyomo OrderedSimpleSet component. This class performs several checks during object construction to ensure a bounded continuous domain is being represented. It also includes access methods for querying the discretization points contained in the ContinuousSet. The rest of this component’s functionality is inherited.

1.1.2 diffvar.py

This file contains the DerivativeVar class which is derived from the Pyomo Var component. Much of this class consists of checks in the constructor around the state variable that the DerivativeVar is differentiating. The rest of the class includes several methods for returning information about the derivative, building up the discretization equations for the derivative, and checking if the DerivativeVar is fully discretized.

1.2 A.2 Discretization transformations

The discretization transformations included in pyomo.dae are subclasses of the Pyomo Transformation class and utilize the existing Pyomo plugin system for standardizing transformations across the Pyomo code base. The finite difference and collocation discretizations are implemented in separate files but are very similar in terms of class and method structure. It is important to note that the discretization transformations are performed ”in-place” and not on a copy of the model.

1.2.1 finitedifference.py

This file contains the implementations of several types of finite difference schemes. There are functions at the top of the file that contain the code specific to a particular discretization scheme. For example,

_forward_transform implements the forward difference equation for first-order derivatives. The discretization transformation is managed by the _apply_to and _transformBlock methods of the

Finite_Difference_Transformation class. The _apply_to method checks the user specified options for the discretization and loops through every active Block in the model, passing it to the _transformBlock method. The _transformBlock method calls functions for adding discretization points, builds discretization expressions for every DerivativeVar in the Block, and checks if the DerivativeVar is fully discretized. Fully discretized DerivativeVar components are reclassified as regular Pyomo Var components. This reclassification step ensures that the Pyomo problem writers throw an error when they encounter un-discretized derivative components but support discretized models.

1.2.2 colloc.py

This file containts the implementations of two types of collocation schemes. Similar to the previous file for finite difference discretizations, this file has functions at the top that implement the specific discretization equations for a particular scheme such as _lagrange_radau_transform. The Collocation_Discretization_Transformation class is nearly identical in structure to the

Finite_Difference_Transformation class with the addition of extra methods for gathering or computing the collocation constants required in the discretization equations. If the user has Numpy installed then these constants will be computed using several functions included in this file. Finally, the

Collocation_Discretization_Transformation class contains a method called

reduce_collocation_points for reducing the degrees of freedom for a particular variable. This method does a series of checks on the user specified options and then builds the interpolation equations described in the paper.

1.3 A. 3 Utility functions

The last two files included in pyomo.dae contain utility functions and data that are used by the discretization transformations.

1.3.1 misc.py

This file contains miscellaneous functions that are used by every discretization transformation. It includes functions like generate_finite_elements and generate_colloc_points for adding discretization points to a ContinuousSet. In addition it contains the function update_contset_indexed_component which will expand any ContinuousSet indexed components to include indices for any discretization points added. There are private functions for updating each type of component such as _update_var and _update_constraint. Finally, this file contains several utility functions for generating and adding discretization equations to a model such as add_discretization_equations and add_continuity_equations which add discretization and continuity constraints to the model.

1.3.2 utilities.py

This file includes Python dictionaries containing pre-computed constants required for the collocation discretization. They are used when a user does not have the Python package Numpy installed, as Numpy is not a required dependency of Pyomo.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Nicholson, B., Siirola, J.D., Watson, JP. et al. pyomo.dae: a modeling and automatic discretization framework for optimization with differential and algebraic equations. Math. Prog. Comp. 10, 187–223 (2018). https://doi.org/10.1007/s12532-017-0127-0

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s12532-017-0127-0

Keywords

Mathematics Subject Classification

Navigation