Pex1.gms : Test expert level Python API to read and write GDX

Description

Contributor: Lutz Westermann, October 2012


Small Model of Type : Python


Category : GAMS API library


Main file : Pex1.gms

$TITLE 'Test expert level Python API to read and write GDX' (PEX1,SEQ=11)

$ontext
Contributor: Lutz Westermann, October 2012
$offtext


$set srcRoot %gams.sysdir%apifiles%system.dirsep%Python%system.dirsep%

$                             set SET set
$if %system.filesys% == UNIX $set SET export

$call rm -rf demanddata.gdx com

* The C extension comes with the system, this is only required when doing manual changes there
$if not set rebuildCExtension $goto haveCExtension

$call cd "%srcRoot%api" && %sysenv.PYTHON27% gdxsetup.py build --build-lib .
$if errorlevel 1 $abort 'Problem running dist utils'

$label haveCExtension

$call %SET% PYTHONPATH=%srcRoot%api && %sysenv.PYTHON27% "%srcRoot%xp_example1.py" "%gams.sysdir%."
$if errorlevel 1 $abort 'Problem executing xp_example1 writing GDX file'
$call gdxdiff demanddata.gdx demandwant.gdx
$if errorlevel 1 $abort 'Demanddata not as expected'
$call %SET% PYTHONPATH=%srcRoot%api && %sysenv.PYTHON27% "%srcRoot%xp_example1.py" "%gams.sysdir%." trnsport.gdx
$if errorlevel 1 $abort 'Problem executing xp_example1 reading GDX file'

$escape &
$ifThen not %sysenv.PYTHON26% == %&sysenv.PYTHON26%&
$call %SET% PYTHONPATH=%srcRoot%api_26 && %sysenv.PYTHON26% "%srcRoot%xp_example1.py" "%gams.sysdir%."
$if errorlevel 1 $abort 'Problem executing xp_example1 writing GDX file with Python 2.6'
$call gdxdiff demanddata.gdx demandwant.gdx
$if errorlevel 1 $abort 'Demanddata not as expected'
$call %SET% PYTHONPATH=%srcRoot%api_26 && %sysenv.PYTHON26% "%srcRoot%xp_example1.py" "%gams.sysdir%." trnsport.gdx
$if errorlevel 1 $abort 'Problem executing xp_example1 reading GDX file with Python 2.6'
$endif

$ifThen not %sysenv.PYTHON34% == %&sysenv.PYTHON34%&
$call %SET% PYTHONPATH=%srcRoot%api_34 && %sysenv.PYTHON34% "%srcRoot%xp_example1.py" "%gams.sysdir%."
$if errorlevel 1 $abort 'Problem executing xp_example1 writing GDX file with Python 3.4'
$call gdxdiff demanddata.gdx demandwant.gdx
$if errorlevel 1 $abort 'Demanddata not as expected'
$call %SET% PYTHONPATH=%srcRoot%api_34 && %sysenv.PYTHON34% "%srcRoot%xp_example1.py" "%gams.sysdir%." trnsport.gdx
$if errorlevel 1 $abort 'Problem executing xp_example1 reading GDX file with Python 3.4'
$endif

$ifThen not %sysenv.PYTHON36% == %&sysenv.PYTHON36%&
$call %SET% PYTHONPATH=%srcRoot%api_36 && %sysenv.PYTHON36% "%srcRoot%xp_example1.py" "%gams.sysdir%."
$if errorlevel 1 $abort 'Problem executing xp_example1 writing GDX file with Python 3.6'
$call gdxdiff demanddata.gdx demandwant.gdx
$if errorlevel 1 $abort 'Demanddata not as expected'
$call %SET% PYTHONPATH=%srcRoot%api_36 && %sysenv.PYTHON36% "%srcRoot%xp_example1.py" "%gams.sysdir%." trnsport.gdx
$if errorlevel 1 $abort 'Problem executing xp_example1 reading GDX file with Python 3.6'
$endif