IDEAS home Printed from https://ideas.repec.org/p/ekd/009007/9165.html
   My bibliography  Save this paper

PAMS.py: a GAMS-like Modeling System based on Python and SAGE

Author

Listed:
  • Roberto Roson

Abstract

This paper presents an external module for the Python programming language and for the SAGE open source mathematical software, which allows the realization of models based on constrained optimization or non-linear systems. The module, which is freely available for download, allows describing the structure of a model using a syntax similar to that of popular modeling systems like GAMS, AIMMS or GEMPACK; in particular by allowing the automatic replication of equations, variable and parameter definitions on the basis of some specified sets. Many applied models, especially in economics, are based on non-linear constrained optimization and system solving. Years ago, the standard way to realize simulations for this kind of models involved writing your own code, using a programming language like FORTRAN, possibly making calls to external math library subroutines. Subsequently, the introduction of packages like Matlab, GAUSS, Octave and many others have made this process somewhat simpler, because vectors and matrices could be treated as single variables, and complex numerical tasks could be performed with a single instruction. However, one fundamental problem remained: the model code still looked much different from the more familiar mathematical notation one would have used in a paper. Therefore, checking and modifying the model code written by another researcher was a rather daunting task. To address this issue, GAMS (General Algebraic Modeling System) was developed by Alexander Meeraus and many of his collaborators at the World Bank in Washington D.C., since the late '70s (Meeraus, 1983). The main purpose of GAMS was (and still is) “providing a high-level language for the compact representation of large and complex models” and “permitting model descriptions that are independent of solution algorithms”. This paper presents an external module for the Python programming language and for the SAGE open source mathematical software, based on the same principles underlying GAMS and other similar packages. The purpose is providing a tool that takes the best of both worlds: the simplicity and clarity of GAMS-like systems combined with the flexibility and power of Python and SAGE. The paper is structured as follows. In the next section, some key characteristics of GAMS and other popular Modeling Systems are reviewed in some detail. Section 3 introduces the Python programming language and the closely related SAGE system for symbolic and numerical computation. Section 4 illustrates the basics of the PAMS.py syntax, and in Section 5 a practical example is provided. A discussion follows in Section 6 and a final section concludes. The paper presents an external module for programs written with the Python language and for the SAGE mathematical software. This module allows the definition and solution of non-linear systems and optimization problems, described in a way very similar to GAMS and programs alike. The key common characteristic of PAMS.py and GAMS is the automatic indexing of parameters, equations and variables. Since many elements of this kind can be defined with only one instruction (as one would normally do, for instance when the model is illustrated in a scientific paper), understanding how the model works directly by reading the program code is normally quite straightforward. The latter feature turns out to be particularly critical when the model code needs to be understood and manipulated by others, which may occur either in a team work or when replication and validation of some results is called for.

Suggested Citation

  • Roberto Roson, 2016. "PAMS.py: a GAMS-like Modeling System based on Python and SAGE," EcoMod2016 9165, EcoMod.
  • Handle: RePEc:ekd:009007:9165
    as

    Download full text from publisher

    File URL: http://ecomod.net/system/files/PAMSpy.pdf
    Download Restriction: no
    ---><---

    Other versions of this item:

    References listed on IDEAS

    as
    1. Pearson, K. R., 1988. "Automating the computation of solutions of large economic models," Economic Modelling, Elsevier, vol. 5(4), pages 385-395, October.
    2. Mark Horridge & Ken Pearson, 2011. "Solution Software for CGE Modeling," Centre of Policy Studies/IMPACT Centre Working Papers g-214, Victoria University, Centre of Policy Studies/IMPACT Centre.
    3. Meeraus, Alexander, 1983. "An algebraic approach to modeling," Journal of Economic Dynamics and Control, Elsevier, vol. 5(1), pages 81-108, February.
    Full references (including those not matched with items on IDEAS)

    Most related items

    These are the items that most often cite the same works as this one and are cited by the same works as this one.
    1. G. Codsi & K.R. Pearson, 1994. "Developing and Implementing Large Economic Models Using GEMPACK, A General Purpose Software Suite," Centre of Policy Studies/IMPACT Centre Working Papers ip-39, Victoria University, Centre of Policy Studies/IMPACT Centre.
    2. Horridge, Mark & Meeraus, Alex & Pearson, Ken & Rutherford, Thomas F., 2013. "Solution Software for Computable General Equilibrium Modeling," Handbook of Computable General Equilibrium Modeling, in: Peter B. Dixon & Dale Jorgenson (ed.), Handbook of Computable General Equilibrium Modeling, edition 1, volume 1, chapter 0, pages 1331-1381, Elsevier.
    3. Peter B. Dixon, 2006. "Evidence-based Trade Policy Decision Making in Australia and the Development of Computable General Equilibrium Modelling," Centre of Policy Studies/IMPACT Centre Working Papers g-163, Victoria University, Centre of Policy Studies/IMPACT Centre.
    4. Thomas Rutherford, 1987. "Implementational Issues and Computational Performance Solving Applied General Equilibrium Models with SLCP," Cowles Foundation Discussion Papers 837, Cowles Foundation for Research in Economics, Yale University.
    5. Thomas Rutherford, 1987. "A Modeling System for Applied General Equilibrium Analysis," Cowles Foundation Discussion Papers 836, Cowles Foundation for Research in Economics, Yale University.
    6. Bandara, Jayatilleke S. & Coxhead, Ian, 1999. "Can Trade Liberalization Have Environmental Benefits in Developing Country Agriculture? A Sri Lankan Case Study," Journal of Policy Modeling, Elsevier, vol. 21(3), pages 349-374, May.
    7. Horridge, Mark & Madden, John & Wittwer, Glyn, 2005. "The impact of the 2002-2003 drought on Australia," Journal of Policy Modeling, Elsevier, vol. 27(3), pages 285-308, April.
    8. Zhai, Fan, 2008. "Armington Meets Melitz: Introducing Firm Heterogeneity in a Global CGE Model of Trade," Journal of Economic Integration, Center for Economic Integration, Sejong University, vol. 23, pages 575-604.
    9. IAN COXHEAD & Sisira Jayasuriya, "undated". "Economic Growth, Development Policy and the Environment in the Philippines," Wisconsin-Madison Agricultural and Applied Economics Staff Papers 430, Wisconsin-Madison Agricultural and Applied Economics Department.
    10. Philip D. Adams & J. Mark Horridge & Brian R. Parmenter, 2000. "MMRF-GREEN: A Dynamic, Multi-Sectoral, Multi-Regional Model of Australia," Centre of Policy Studies/IMPACT Centre Working Papers op-94, Victoria University, Centre of Policy Studies/IMPACT Centre.
    11. JAMES H. BREECE & KEITH R. McLAREN & CHRISTOPHER W. MURPHY & ALAN A. POWELL, 1994. "Using the Murphy Model to Provide Short‐run Macroeconomic Closure for ORANI," The Economic Record, The Economic Society of Australia, vol. 70(210), pages 292-314, September.
    12. Kym Anderson, 2020. "Trade Protectionism In Australia: Its Growth And Dismantling," Journal of Economic Surveys, Wiley Blackwell, vol. 34(5), pages 1044-1067, December.
    13. Peter B. Dixon & Maureen T. Rimmer, 2004. "Disaggregation of results from a detailed general equilibrium model of the US to the State level," Centre of Policy Studies/IMPACT Centre Working Papers g-145, Victoria University, Centre of Policy Studies/IMPACT Centre.
    14. K.R. Pearson, 1991. "Solving Nonlinear Economic Models Accurately Via a Linear Representation," Centre of Policy Studies/IMPACT Centre Working Papers ip-55, Victoria University, Centre of Policy Studies/IMPACT Centre.
    15. Zhang, Qiang & Tong, Qiong, 2021. "The economic impacts of traffic consumption during the COVID-19 pandemic in China: A CGE analysis," Transport Policy, Elsevier, vol. 114(C), pages 330-337.
    16. Prema-chandra Athukorala & Peter B. Dixon & Maureen T. Rimmer, 2017. "Global Supply Chains: towards a CGE analysis," Centre of Policy Studies/IMPACT Centre Working Papers g-281, Victoria University, Centre of Policy Studies/IMPACT Centre.
    17. Philippa Dee, 1989. "The Effects of Government size on Economic Performance: a Quantitative Assessment of a Budget Reduction," Australian Economic Review, The University of Melbourne, Melbourne Institute of Applied Economic and Social Research, vol. 22(1), pages 24-38, March.
    18. Peter Dixon & Michael Jerie & Maureen Rimmer, 2016. "Modern Trade Theory for CGE Modelling: The Armington, Krugman and Melitz Models," Journal of Global Economic Analysis, Center for Global Trade Analysis, Department of Agricultural Economics, Purdue University, vol. 1(1), pages 1-110, June.
    19. Charles G. Renfro, 2009. "The Practice of Econometric Theory," Advanced Studies in Theoretical and Applied Econometrics, Springer, number 978-3-540-75571-5, July-Dece.
    20. Peter B. Dixon & Maureen T. Rimmer, 2003. "The US economy from 1992 to 1998: historical and decomposition simulations with the USAGE model," Centre of Policy Studies/IMPACT Centre Working Papers g-143, Victoria University, Centre of Policy Studies/IMPACT Centre.

    More about this item

    Keywords

    None; Modeling: new developments; Miscellaneous;
    All these keywords.

    JEL classification:

    • C63 - Mathematical and Quantitative Methods - - Mathematical Methods; Programming Models; Mathematical and Simulation Modeling - - - Computational Techniques
    • C65 - Mathematical and Quantitative Methods - - Mathematical Methods; Programming Models; Mathematical and Simulation Modeling - - - Miscellaneous Mathematical Tools
    • C68 - Mathematical and Quantitative Methods - - Mathematical Methods; Programming Models; Mathematical and Simulation Modeling - - - Computable General Equilibrium Models
    • C8 - Mathematical and Quantitative Methods - - Data Collection and Data Estimation Methodology; Computer Programs

    NEP fields

    This paper has been announced in the following NEP Reports:

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:ekd:009007:9165. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    If CitEc recognized a bibliographic reference but did not link an item in RePEc to it, you can help with this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Theresa Leary (email available below). General contact details of provider: https://edirc.repec.org/data/ecomoea.html .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.