idxperm2.gms : Check correct behavior when permuting indices in loop etc

Description

With GAMS 24.5 we improved the execution time for cases were the index order of
symbols was not sorted, meaning not in the order of the controlling sets. This
is done by changing the internal sparsity trees on the fly.
While testing there was an error that could be reproduced with this example.
There were actually two problems with the same "symptom", one in an if statement
and the other in loop like structures (loop, repeat, while).

Before this error was fixed we got an execution error:

    Error at line ??: division by zero (0)

Keyword: Sys17

Contributor: Lutz Westermann, September 2015


Small Model of Type : GAMS


Category : GAMS Test library


Main file : idxperm2.gms

$title 'Check correct behavior when permuting indices in loop etc' (IDXPERM2,SEQ=685)

$ontext
With GAMS 24.5 we improved the execution time for cases were the index order of
symbols was not sorted, meaning not in the order of the controlling sets. This
is done by changing the internal sparsity trees on the fly.
While testing there was an error that could be reproduced with this example.
There were actually two problems with the same "symptom", one in an if statement
and the other in loop like structures (loop, repeat, while).

Before this error was fixed we got an execution error:

*** Error at line ??: division by zero (0)

Keyword: Sys17

Contributor: Lutz Westermann, September 2015
$offtext


$onEcho > test.gms
set t /t0*t1/, r /r1*r15 /, s /s1*s15 /;
parameter a(r,s);
scalar w,x,y,z;

if(1,
  a(r,s)=1;
  w=1/sum((s,r)$(a(r,s)), 1);
  a(r,s)=1;
  w=1/sum((s,r)$(a(r,s)), 1);
);

loop(t,
  a(r,s)=1;
  x=1/sum((s,r)$(a(r,s)), 1);
);

scalar c/0/
repeat(
  a(r,s)=1;
  y=1/sum((s,r)$(a(r,s)), 1);
  c=c+1;
until c=2);

c=0;
while(c<2,
  a(r,s)=1;
  z=1/sum((s,r)$(a(r,s)), 1);
  c=c+1
);
$offEcho

$call gams test.gms lo=%GAMS.lo% sys17=1 gdx=old.gdx
$if errorlevel 1 $abort problem running with sys17=1

$call gams test.gms lo=%GAMS.lo% sys17=0 gdx=new.gdx
$if errorlevel 1 $abort problem running with sys17=0

$call gdxdiff old.gdx new.gdx > %system.nullfile%
$if errorlevel 1 $abort "GDX files differ"