What is GAMSPy?#
GAMSPy combines the high-performance GAMS execution system with the flexible Python language, creating a powerful mathematical optimization package. It acts as a bridge between the expressive Python language and the robust GAMS system, allowing you to create complex mathematical models effortlessly.
In this section, we offer an overview of GAMSPy’s distinctive features and benefits to assist you in finding the ideal modeling language and environment for your needs.
Model Instances vs. Mathematical Models#
Creating robust, readable, and maintainable models is an art rooted in algebraic formulation. The ability to express mathematical models in a language that retains the essence of algebraic notation and is machine-processable is paramount.
With this goal in mind GAMSPy has been developed to be able to generate mathematical models instead of model instances. Think of a mathematical model as a pure representation of mathematical symbols, devoid of specific data. In contrast, a model instance is the unrolled and constant folded representation of a model with its actual data. In a model instance sum expressions are resolved into its individual components and equation domains are resolved to individual scalar equations.
Especially for complex models with many variables and equations, a model instance can become hard to manage. Therefore, GAMSPy leverages the idea of a standalone, data independent, and indexed representation of a mathematical model which is very close to the original mathematical algebraic formulation.
One key aspect of any modeling language is how it handles sparse multidimensional data structures. Many optimization problems are subject to a particular structure in which the data cube has a lot of zeros and only a few non-zeros, a characteristic referred to as sparse. In optimization problems, it is often necessary to account for complex mappings of indices to subsets.
While you might be used to taking on the full responsibility to make sure only the relevant combinations of indices go into your variable definition in the Python modeling world, we especially focused on transferring the convenience and mindset of GAMS into Python by designing GAMSPy. Thus, GAMSPy automatically takes care of generating variables only for the relevant combinations of indices based on the algebraic formulation. This feature is particularly useful when working with a large multidimensional index space, where generating all possible combinations of indices would be computationally expensive and unnecessary. GAMSPy quietly handles this task in the background, allowing us to focus on the formulation of the model.
GAMSPy leverages the GAMS backend to execute assignment operations, generate and solve models. Since GAMS has been optimized over decades for exactly these tasks and comes with a broad set of state-of-the-art optimization solvers, it provides outstanding performance for model generation and solving models. This is the main source of the speed of GAMSPy.
Optimization Pipeline Management#
Working on an optimization problem does not solely include the mathematical model but also includes tasks regarding data pre- and postprocessing as well as visualization. At GAMS, we prioritize making these tasks as comfortable and efficient as possible. With GAMSPy we provide a unique way to streamline the complete optimization pipeline starting with data input and preprocessing followed by the implementation of the mathematical model and data postprocessing and visualization, in a single, intuitive Python environment. GAMSPy allows you to leverage your favorite Python libraries (e.g. Numpy, Pandas, Networkx) to comfortably manipulate and visualize data. And it allows to import and export data and optimization results to many data formats.
On top, GAMSPy seamlessly works with GAMS MIRO and GAMS Engine which allows you to run your GAMSPy optimization either on your local machine or on your own server hardware (GAMS Engine One) as well as on GAMS Engine SaaS, hosted on the AWS cloud infrastructure. We make sure you have access to the right resources, any time.
How is GAMSPy different from GAMS?#
GAMS is a domain-specific declarative language that incorporates procedural elements from a general-purpose programming language, such as loops and conditional statements. In contrast, Python is a general-purpose programming language where these elements are already inherent. With the integration of the GAMSPy library, features like indexed assignment statements or the concise equation definition of domain-specific GAMS language are now made available in Python. This facilitates a seamless connection between the specialized modeling capabilities of GAMS and the flexibility and versatility of Python.
Summarizing the Benefits#
Generation of mathematical models in Python
Abstract algebraic data independent modeling in Python
Convenient handling of sparse data structures in Python
Streamlined optimization pipeline management in Python