Accessing Model Libraries

Professor Paul Samuelson is fond of saying that he hopes each generation 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 organzied 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.

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

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 (Windows only) to access the model library is from within the GAMS IDE by going through : Model Libraries.


Invoking the GAMS Model Library menu will pop up the window in following screen.


The grid filled with model names is a scrollable list of files with column entries describing file attributes. At the bottom is a more lengthy description of the file highlighted. In turn double clicking in a row causes the file to be loaded in the IDE for editing and into your project directory. Simultaneously all files it includes and other files the library creator nominated are placed in the project directory.

There are several features of this manager that merit description

  • The window contains a search box as in the blue box below. When one types an entry into that box the window automatically scrolls forward to a file that contains the typed text somewhere in it. For example typing in the string "chem" causes the screen below to appear
    where the ALYKL command is the first one that contains the string "chem". If one wants to find the next occurrence of the string one can press the down arrow key while the up arrow reveals the previous one.
  • The gray bar at the top of the grid allows one to alter the tabular sort order. By clicking the mouse on the gray bar one changes that order. For example touching the word Type causes the files to be sorted by model type as illustrated below.
    The column sorted on is marked with a + if in forward order and a minus if in reverse order.
    The sort order also uses a secondary sort key where it remembers the previous columns you have sorted on. Consequently if you first click on Name then Type you the files will be arranged by alphabetical order of their names under a problem type. But if you sorted first on Application Area then most recently on Type they would be organized by Application Area under each problem type.
  • A left click with the mouse on a file name causes its description to be placed in the text box at the bottom. A double click loads the file into the IDE.
  • A right click with the mouse brings up a menu box.
    If one chooses the view model choice the GAMS code is placed in the box where the description appeared with a gray background.
    Another right click will bring up the box again and the view model choice can be unclicked.
  • You may change column widths, allocation of top and bottom screen parts and window size just as in other programs through use of the mouse. The IDE will remember some but not all of your choices.
  • Users may define their own library by using a GLB file, see Creating a User Library for use in the IDE and Example by Bruce A. McCarl.