Accessing Model Libraries

Professor Paul Samuelson is fond of saying that he hopes each generation of economists will be able to "stand on the shoulders" of the previous generation. The library of models included with the GAMS system is a reflection of this desire. We believe that the quality of modeling will be greatly improved and the productivity of modelers enhanced if each generation can stand on the shoulders of the previous generation by beginning with the previous models and enhancing and improving them. The Model Libraries includes a large number of models, collectively organized as

  • GAMS Model Library - includes GAMS models representing interesting and sometimes classic problems, ranged from production and shipment by firms, investment planning, cropping patterns in agriculture, operation of oil refineries and petrochemical plants, macroeconomics stabilization, applied general equilibrium, international trade in aluminum and in copper, water distribution networks, and many more.
  • GAMS Test Library - includes GAMS models developed for testing and quality control, both for the GAMS base module and the many solvers distributed with the GAMS system.
  • GAMS Data Utilities Library - includes GAMS models demonstrating various utilities to interface GAMS with other tools and applications such as spreadsheets and database interface.
  • GAMS EMP Library - includes GAMS Extended Mathematical Programming (EMP) models that illustrate and test the capabilities of GAMS/EMP.
  • GAMS API Library - includes GAMS Models used as scripts to compile and execute application programs in various programming languages interfacing to GAMS.
  • FIN Library - includes GAMS practical financial optimization models described in the book Practical Financial Optimization: Decision Making for Financial Engineers by Consiglio, Nielsen and Zenios,
  • NOA Library - includes GAMS nonlinear optimization applications models based on the book Nonlinear Optimization Applications Using the GAMS Technology by Neculai Andrei.
  • PSOPT Library - includes GAMS optimization models based on the book Power System Optimization Modelling in GAMS by Alireza Soroudi.

The models included have been selected not only because they collectively provide strong shoulders for new users to stand on, but also because they represent interesting and sometimes classic problems. For example the trade-off between consumption and investment is richly illustrated in the Ramsey problem, which can be solved using nonlinear programming methods. Examples of other problems included in the library are production and shipment by firms, investment planning in time and space, cropping patterns in agriculture, operation of oil refineries and petrochemical plants, macroeconomics stabilization, applied general equilibrium, international trade in aluminum and in copper, water distribution networks, and relational databases.

Another criterion for including models in the library is that they illustrate the modeling capabilities GAMS offers. For example, the mathematical specification of cropping patterns can be represented handily in GAMS. Another example of the system's capability is the style for specifying initial solutions as staring points in the search for the optimal solution of dynamic nonlinear optimization problems.

Finally, some models have been selected for inclusion because they have been used in other modeling systems. Examples are network problems and production planning models. These models permit the user to compare how problems are set up and solved in different modeling systems.

Most of the models have been contributed by GAMS users. The submission of new models is encouraged. If you would like to see your model in a future release of the library, please send the model and associated documents and reports to GAMS Development Corporation.


Command Line Approach

One way to access the library is through command line. The following commands copy a model from the library directory into the current directory.

Command Library to access
gamslib GAMS Model Library
testlib GAMS Test Library
datalib GAMS Data Library
emplib GAMS EMP Library
apilib GAMS API Library
finlib FIN Library
noalib NOA Library
psoptlib PSOPT Library

Take the command gamslib for an example, if you enter gamslib without any parameters, the command syntax will be displayed as shown below:

> gamslib modelname [target]


> gamslib modelnum [target]


  • modelname is the modelname
  • modelnum is the model sequence number, and
  • target is the target file name.

If the target file name is not provided, the default is modelname.gms. The file will be automatically copied into the current working directory. For example, the [TRNSPORT] model from the GAMS Model library has sequence number 1 and could be copied in any of the following ways.

To copy [TRNSPORT] model file to target file trnsport.gms under the current directory:

> gamslib trnsport
> gamslib 1 

To copy [TRNSPORT] model file to target file myname.gms under the current directory:

> gamslib trnsport myname
> gamslib 1 myname

The other commands have similar usage to gamslib command.

IDE Approach

A convenient way to access the model library on the major platforms is the "Model Library Explorer" from GAMS Studio. It is described in detail in the GAMS Studio documentation.

Users may define their own library by using a GLB file. These libraries can also be accessed through Studio.