unload15.gms : Test $gdxUnload

Description

GAMS 35 introduced $gdxUnload as alternative to $gdxOut ... $unLoad ... $gdxOut.
It is a single statement to open a GDX file and unload symbols to it and does not
interfere with other $unLoad operations to another file opened via $gdxOut before.

Contributor: Lutz Westermann, February 2021


Small Model of Type : GAMS


Category : GAMS Test library


Main file : unload15.gms

$title 'Test $gdxUnload' (UNLOAD15,SEQ=850)

$onText
GAMS 35 introduced $gdxUnload as alternative to $gdxOut ... $unLoad ... $gdxOut.
It is a single statement to open a GDX file and unload symbols to it and does not
interfere with other $unLoad operations to another file opened via $gdxOut before.

Contributor: Lutz Westermann, February 2021
$offText

Set i / i1*i3 /
    j / j1*j3 /;
    
Parameter a(i) / #i 1 /
          b(j) / #j 2 /;
          
* Make sure that in general $gdxUnload does the same as $gdxOut .. $unLoad .. $gdxOut
$gdxUnload ia1.gdx i a

$gdxOut ia2.gdx
$unLoad i a
$gdxOut

$call.checkErrorLevel gdxdiff ia1.gdx ia2.gdx > %system.nullfile%


$gdxUnload all1.gdx

$gdxOut all2.gdx
$unLoad
$gdxOut

$call.checkErrorLevel gdxdiff all1.gdx all2.gdx > %system.nullfile%


* Make sure that $gdxUnload can be called between two $unLoad calls w/o interfering with the operations for the file opened with $gdxOut

$gdxOut ia3.gdx
$unLoad i

$gdxUnload jb1.gdx j b

$unLoad a

$gdxOut jb2
$unLoad j b
$gdxOut

$call.checkErrorLevel gdxdiff ia1.gdx ia3.gdx > %system.nullfile%
$call.checkErrorLevel gdxdiff jb1.gdx jb2.gdx > %system.nullfile%