The tutorials provided in the
tutorial directory of the ixmp repository walk through the first steps of working with
You will learn how to create a
ixmp.Scenario as a structured data collection for sets, parameters and the numerical solution to the associated optimization problem.
Dantzig’s transportation problem¶
We use Dantzig’s transport problem , which is also used as the standard GAMS tutorial . This problem finds a least cost shipping schedule that meets demand requirements at markets and supply capacity constraints at multiple factories.
The tutorials are provided as Jupyter notebooks for both Python and R, and are identical as far as possible.
This tutorial walks through the following steps:
Define the sets and parameters in the scenario, and commit the data to the platform.
Check out the scenario and initialize variables and equations (necessary for ixmp to import the solution).
Solve the scenario (export to GAMS input gdx, execute, read solution from output gdx).
Display the solution (variables and equation).
This tutorial creates an alternate or ‘counterfactual’ scenario of the transport problem; solves it; and compares the results to the original or reference scenario.
Adapting GAMS models for
The common example optimization from Dantzig  is available in a GAMS implementation from the GAMS website.
tutorial/transport/transport_ixmp.gms illustrates how an existing GAMS model can be adapted to work with the ix modeling platform.
The same, simple procedure can be applied to any GAMS code.
The steps are:
Modify the definitions of GAMS sets (
j) and parameters (
f) to remove explicit values.
Add lines to read the model input data passed by ixmp.
The following lines are added before the code that defines and solves the model:
* These two lines let the model code be run outside of ixmp, if needed $if not set in $setglobal in 'ix_transport_data.gdx' $if not set out $setglobal out 'ix_transport_results.gdx' $gdxin '%in%' $load i, j, a, b, d, f $gdxin
Add a line to write the model output data.
The following line is added after the model’s
GAMSModel class uses command-line options to pass the values of the variables
This causes the model to read its input data from a GDX-format file created by ixmp, and write its output data to a GDX file specified by ixmp.
ixmp then automatically retrieves the model solution and other information from the output file, updating the
Scenario and storage