decla2.gms : Test declarations which were handled incorrectly in the past

Description

This model tests several declarations and data statements which were
handled incorrectly in the past:
1. tests cmex bug AB00751, P3 exception
2. records of variables and equations whose values all match the default
   record of the symbol were only removed if some value in the same data
   statement was 0. Now, such default records are always removed.


Small Model of Type : GAMS


Category : GAMS Test library


Main file : decla2.gms

$title 'Test declarations which were handled incorrectly in the past'  (DECLA2,SEQ=222)

* This model tests several declarations and data statements which were
* handled incorrectly in the past:
* 1. tests cmex bug AB00751, P3 exception
* 2. records of variables and equations whose values all match the default
*    record of the symbol were only removed if some value in the same data
*    statement was 0. Now, such default records are always removed.

set i / i1*i3 /
    j / j1*j3 /;
parameter data(i,i,j,j) /
i1.i1.j1.j2 4
i1.i2.j1.j2 4
i1.  .j2.j2 5
i2.i2.j2.j1 6 /;

$if errorfree $abort There should be a compilation error
$clearError

* 2. default records in data statements of variables and equations:
*    r2 has the default values of an equation without definition and of
*    a free variable, so it should always be removed
Equation eZero(*) 'with a 0 in the data statement'
/ r1.lo 0,    r1.up 0
  r2.lo -inf, r2.up inf /;

Equation eNoZero(*) 'without a 0 in the data statement'
/ r1.lo 1,    r1.up 2
  r2.lo -inf, r2.up inf /;

Variable xZero(*) 'with a 0 in the data statement'
/ r1.lo 0,    r1.up 0
  r2.lo -inf, r2.up inf /;

Variable xNoZero(*) 'without a 0 in the data statement'
/ r1.lo 1,    r1.up 2
  r2.lo -inf, r2.up inf /;

Equation Table eTabZero(*) 'with a 0 in the table'
        lo     up
   r1    0      0
   r2 -inf    inf;

Equation Table eTabNoZero(*) 'without a 0 in the table'
        lo     up
   r1    1      2
   r2 -inf    inf;

Variable Table xTabZero(*) 'with a 0 in the table'
        lo     up
   r1    0      0
   r2 -inf    inf;

Variable Table xTabNoZero(*) 'without a 0 in the table'
        lo     up
   r1    1      2
   r2 -inf    inf;

abort$(card(eZero)      <> 1) 'eZero should have one record'     , eZero.lo,      eZero.up;
abort$(card(eNoZero)    <> 1) 'eNoZero should have one record'   , eNoZero.lo,    eNoZero.up;
abort$(card(xZero)      <> 1) 'xZero should have one record'     , xZero.lo,      xZero.up;
abort$(card(xNoZero)    <> 1) 'xNoZero should have one record'   , xNoZero.lo,    xNoZero.up;
abort$(card(eTabZero)   <> 1) 'eTabZero should have one record'  , eTabZero.lo,   eTabZero.up;
abort$(card(eTabNoZero) <> 1) 'eTabNoZero should have one record', eTabNoZero.lo, eTabNoZero.up;
abort$(card(xTabZero)   <> 1) 'xTabZero should have one record'  , xTabZero.lo,   xTabZero.up;
abort$(card(xTabNoZero) <> 1) 'xTabNoZero should have one record', xTabNoZero.lo, xTabNoZero.up;

abort$(eNoZero.lo('r1')    <> 1 or eNoZero.up('r1')    <> 2) 'wrong data for eNoZero';
abort$(xNoZero.lo('r1')    <> 1 or xNoZero.up('r1')    <> 2) 'wrong data for xNoZero';
abort$(eTabNoZero.lo('r1') <> 1 or eTabNoZero.up('r1') <> 2) 'wrong data for eTabNoZero';
abort$(xTabNoZero.lo('r1') <> 1 or xTabNoZero.up('r1') <> 2) 'wrong data for xTabNoZero';