InterPSS-GAMS Integration

1.1 GAMS 24.0

(1) Overview of GAMS new API

The object-oriented GAMS API allows the seamless integration of GAMS into an application by providing appropriate classes for the interaction with GAMS. The GAMSDatabase class for in-memory representation of data can be used for convenient exchange of input data and model results. Models written in GAMS can be run with the GAMSJob class and by using the GAMSModelInstance class a sequence of closely related model instances can be solved in the most efficient way. There are three versions of the object-oriented GAMS API: Java, Python and .NET. These APIs work with Java SE 5 and up, Python 2.7, and .NET framework 4 (Visual Studio 2010) and up.

For details: see

(2) Installation

1. Download from GAMS download webside, V24.0.2 or upper should be consistent with this document.

2. When installing the GAMS, make sure choose "add the install dir to the system environment".

1.2. Call GAMS from Java

Since v24.0, new GAMS Java APIs introduce the following concepts/classes, allowing better integration with Java-based projects.

    • GAMSWorkspace : Workspace in Java environment which has most of the functions in the native GAMS workspace. To Integrate GAMS in any Java project, first we need to create an GAMSWork space, as follows:

GAMSWorkspace ws = new GAMSWorkspace();

Then we can use ws to create database

GAMSDatabase db = ws.addDatabase();

and create GAMSJob:

GAMSJob ieee14ED = ws.addJobFromString(modelStr);

    • GAMSDatabase: storing and processing the modeling data in in-momory database
    • GAMSSet and GAMSParameter: Base data set for storing the indices and modeling data, respectively.


GAMSSet loadBus = db.addSet("j", 1, "load buses");

GAMSParameter genPLow = db.addParameter("genPLow", 1,"lower bound of each generating unit");

    • GAMSVariableRecord: Get the optimization results directly from the database


for (GAMSVariableRecord rec : ieee14ED.OutDB().getVariable("genp")){

System.out.println("genP @ Bus-" + rec.getKeys()[0]+" : Level=" + rec.getLevel() );


    • GAMSJob: Now we can create GAMSJob from modeling String, no independent “*.gms” modeling file is needed.


GAMSJob ieee14ED = ws.addJobFromString(modelStr);

The GAMS Java Library GAMSJavaAPI.jar can be found under the folder:

<Path to GAMS>\apifiles\Java\api

(Corresponding DLLs can also be found under this folder). This has been add to the ipss.lib.3rdPty/gams


1. The order of library (seems) matters

The GAMSJAVAAPI.jar should put at the top order of the project(It was found GAMS issued compile error when this jar was put at the last), therefore the following order is recommended for the path configuation.

2. GAMS Related class run configuration setting within Eclipse

Run the class by "run configuration->setting the VM arguments as follows:

-Djava.library.path="<GAMS Install Dir>\\apifiles\\Java\\api"

Which guarantees that the required DLLs are accessible/visible from the class.

1.3 ED Sample

IEEE14Bus Economic dispatch:

To run the sample, three InterPSS projects are required , they are :

Make sure you have checked out at least these three projects from InterPSS Google Repo( to run the sampe testcase, which is under the “test.ed“ package.



genP @ Bus-Bus1 : level=1.91 , marginal=0.0

genP @ Bus-Bus2 : level=0.5 , marginal=-20.033200000000004

genP @ Bus-Bus3 : level=0.05 , marginal=39.96479999999998

genP @ Bus-Bus4 : level=0.0 , marginal=-30.038200000000003

genP @ Bus-Bus5 : level=0.0 , marginal=-30.038200000000003

genP @ Bus-Bus6 : level=0.06 , marginal=19.968999999999994

genP @ Bus-Bus7 : level=0.0 , marginal=-30.038200000000003

genP @ Bus-Bus8 : level=0.07 , marginal=9.974400000000003

genP @ Bus-Bus9 : level=0.0 , marginal=-30.038200000000003

genP @ Bus-Bus10 : level=0.0 , marginal=-30.038200000000003

genP @ Bus-Bus11 : level=0.0 , marginal=-30.038200000000003

genP @ Bus-Bus12 : level=0.0 , marginal=-30.038200000000003

genP @ Bus-Bus13 : level=0.0 , marginal=-30.038200000000003

genP @ Bus-Bus14 : level=0.0 , marginal=-30.038200000000003