mpsge01.gms : Illustrate correct naming in MPSGE - new rules

Description

This model illustrates the NEW naming rules for labels and identifiers
in MPSGE.  The new rules are those imposed by the MPSGE engine that
uses the external equation interface to communicate with the MCP
solver - this was introduced in GAMS Distribution 20.1 on 31 October,
2001.  To use these new rules, you must be running from GAMS
Distribution 21.3 (due early January 2004) or newer - this was when
the "oldnames" check made by GAMS/Base was taken out and the checks
were moved to the MPSGE engines.

Of course, just because something is allowed doesn't make it a good
idea - this is not an illustration of good style.

New rules for names in MPSGE models
-----------------------------------

  Labels must:
    not contain the following characters:  set i / ' !.:"', "'" /
      or in English space, bang, dot, colon, double-quote, single-quote
    not be empty: set i / '' /;
    N.B. There is no MPSGE-specific limit on the label length.

  Model name: currently (Dec 2016) can only be 31 chars long

  Other identifiers (e.g. parameters, variables):
    no MPSGE-specific limits


Small Model of Type : MPSGE


Category : GAMS Test library


Main file : mpsge01.gms

$title Illustrate correct naming in MPSGE - new rules (MPSGE01,SEQ=78)

$onText

This model illustrates the NEW naming rules for labels and identifiers
in MPSGE.  The new rules are those imposed by the MPSGE engine that
uses the external equation interface to communicate with the MCP
solver - this was introduced in GAMS Distribution 20.1 on 31 October,
2001.  To use these new rules, you must be running from GAMS
Distribution 21.3 (due early January 2004) or newer - this was when
the "oldnames" check made by GAMS/Base was taken out and the checks
were moved to the MPSGE engines.

Of course, just because something is allowed doesn't make it a good
idea - this is not an illustration of good style.

New rules for names in MPSGE models
-----------------------------------

  Labels must:
    not contain the following characters:  set i / ' !.:"', "'" /
      or in English space, bang, dot, colon, double-quote, single-quote
    not be empty: set i / '' /;
    N.B. There is no MPSGE-specific limit on the label length.

  Model name: currently (Dec 2016) can only be 31 chars long

  Other identifiers (e.g. parameters, variables):
    no MPSGE-specific limits


Last update Dec 2016 - Steve Dirkse

$offText

$eolCom //

$version 137
$if errorfree $goTo GAMSBASE_OK
$clearError
display 'GAMS Rev 137 (CD 21.3) or higher required to test the new rules'
$exit

$label GAMSBASE_OK


SETS
  i0 'long or spacy labels: max of 63 is accepted' /
*            1         2         3
*   1234567890123456789012345678901
*            1         2         3         4         5         6         7
*   12345678901234567890123456789012345678901234567890123456789012345678901
    veryLongLabelNameWithLengthOf31
    big_33super____________________33
    big_43super______________________________43
    big_53super________________________________________53
    big_63super__________________________________________________63
    i-+-+-____                         // -, +, or _ OK
    'i4         '                      // can end with spaces: GAMS/Base trims
                                       // trailing whitespace before MPSGE
                                       // gets a chance to see it
  /

*   this next block was created by taking all the legal UEL characters
*   as of GAMS CD 21.3 (GAMS Rev 137) and removing those known to cause
*   trouble for MPSGE.  The chars legal in GAMS UELs but not in MPSGE
*   are tested in mpsge03 * mpsge09.
  i1 'unusual UEL chars' /
    '#OK#'
    '$OK$'
    '%OK%'
    '&OK&'
    '(OK('
    ')OK)'
    '*OK*'
    '+OK+'
    ',OK,'
    '-OK-'
    '/OK/'
    '0OK9'
    ';OK;'
    '<OK<'
    '=OK='
    '>OK>'
    '?OK?'
    '@OK@'
    'aOKA'
    '[OK['
    '\OK\'
    ']OK]'
    '^OK^'
    '_OK_'
    '`OK`'
    '{OK{'
    '|OK|'
    '}OK}'
    '~OK~'
    '#'
  /
  i2 'unusual UEL chars' /
    '$'
    '%'
    '&'
    '('
    ')'
    '*'
    '+'
    ','
    '-'
    '/'
    '0'
    ';'
    '<'
    '='
    '>'
    '?'
    '@'
    'A'
    '['
    '\'
    ']'
    '^'
    '_'
    '`'
    '{'
    '|'
    '}'
    '~'
  /
  jj  / j1 * j2 /
  hh  / h1 * h2 /
  j   / j1 /
  h   / h1 /
  ;

* the existence of nasty labels should only matter if they are part of
* the MPSGE model
SET notusedinmpsge / 'a = b            a' /;


* ----------------- test long symbol names and long/spacy UELs ---------------

parameters
*          1         2         3         4         5         6         7
* 1234567890123456789012345678901234567890123456789012345678901234567890
  d03456789012345678901234567890123456789012345678901234567890123(i0,hh)  'Reference demands'
  e0(i0,hh)                'Reference endowments'
  ;
d03456789012345678901234567890123456789012345678901234567890123(i0,hh) = uniform(0,1);
e0(i0,hh) = uniform(0,1);

$onText

$model:exchange901234567890twenty78901

$commodities:
        price6789012345678901234567890123456789012345678901234567890123(i0,jj)
*                1         2         3         4         5         6         7
*       1234567890123456789012345678901234567890123456789012345678901234567890

$consumers:
        ra3456789012345678901234567890123456789012345678901234567890123(hh)


$demand:ra3456789012345678901234567890123456789012345678901234567890123(hh) s:1
        d:price6789012345678901234567890123456789012345678901234567890123(i0,jj)     q:d03456789012345678901234567890123456789012345678901234567890123(i0,hh)
        e:price6789012345678901234567890123456789012345678901234567890123(i0,jj)     q:e0(i0,hh)

$offText

$sysInclude mpsgeset exchange901234567890twenty78901

option solvelink=0;
$include EXCHANGE901234567890TWENTY78901.GEN
solve exchange901234567890twenty78901 using mcp;
abort$[exchange901234567890twenty78901.solvestat <> %solveStat.normalCompletion%] 'wrong solvestat (sl=0)';
abort$[exchange901234567890twenty78901.modelstat <> %modelStat.optimal%]          'wrong modelstat (sl=0)';

option solvelink=5;
$include EXCHANGE901234567890TWENTY78901.GEN
solve exchange901234567890twenty78901 using mcp;
abort$[exchange901234567890twenty78901.solvestat <> %solveStat.normalCompletion%] 'wrong solvestat (sl=5)';
abort$[exchange901234567890twenty78901.modelstat <> %modelStat.optimal%]          'wrong modelstat (sl=5)';


* ----------------- test unusual UELs from i1 ---------------

parameters
  d1(i1,h)   'Reference demands'
  e1(i1,h)   'Reference endowments'
  ;
d1(i1,h) = uniform(0,1);
e1(i1,h) = uniform(0,1);

$onText

$model:exchange1

$commodities:
        price1(i1,j)

$consumers:
        ra1(h)


$demand:ra1(h) s:1
        d:price1(i1,j)     q:d1(i1,h)
        e:price1(i1,j)     q:e1(i1,h)

$offText

$sysInclude mpsgeset exchange1

option solvelink=0;
$include EXCHANGE1.GEN
solve exchange1 using mcp;
abort$[exchange1.solvestat <> %solveStat.normalCompletion%] 'wrong solvestat (sl=0)';
abort$[exchange1.modelstat <> %modelStat.optimal%]          'wrong modelstat (sl=0)';

option solvelink=5;
$include EXCHANGE1.GEN
solve exchange1 using mcp;
abort$[exchange1.solvestat <> %solveStat.normalCompletion%] 'wrong solvestat (sl=5)';
abort$[exchange1.modelstat <> %modelStat.optimal%]          'wrong modelstat (sl=5)';


* ----------------- test unusual UELs from i2 ---------------

parameters
  d2(i2,h)   'Reference demands'
  e2(i2,h)   'Reference endowments'
  ;
d2(i2,h) = uniform(0,1);
e2(i2,h) = uniform(0,1);

$onText

$model:exchange2

$commodities:
        price2(i2,j)

$consumers:
        ra1(h)


$demand:ra1(h) s:1
        d:price2(i2,j)     q:d2(i2,h)
        e:price2(i2,j)     q:e2(i2,h)

$offText

$sysInclude mpsgeset exchange2

option solvelink=0;
$include EXCHANGE2.GEN
solve exchange2 using mcp;
abort$[exchange2.solvestat <> %solveStat.normalCompletion%] 'wrong solvestat (sl=0)';
abort$[exchange2.modelstat <> %modelStat.optimal%]          'wrong modelstat (sl=0)';

option solvelink=5;
$include EXCHANGE2.GEN
solve exchange2 using mcp;
abort$[exchange2.solvestat <> %solveStat.normalCompletion%] 'wrong solvestat (sl=5)';
abort$[exchange2.modelstat <> %modelStat.optimal%]          'wrong modelstat (sl=5)';