mcp15.gms : Test equList matching in model statement

Description

Test equList matching in model statement.
In particular, test on invalid inputs

Contributor: Steven Dirkse, September 2024


Small Model of Type : MCP


Category : GAMS Test library


Main file : mcp15.gms

$title Test equList matching in model statement (MCP15, SEQ=968)

$onText
Test equList matching in model statement.
In particular, test on invalid inputs

Contributor: Steven Dirkse, September 2024
$offText


scalar c / 0 /;

sets
  u / a, b, c /
  i1(u)
  i2(u)
  i3(u)
  ;

variable v(u);
equations
  n1(u)   'matched =N= rows'
  n2(u)   'matched =N= rows'
  n3(u)   'matched =N= rows'

  e1(u)   'matched equations'
  e2(u)   'matched equations'
  e3(u)   'matched equations'

  h       'unmatched equation'
  ;

n1(i1(u)).. v(u-1) + v(u) + c * v(u+1) =N= min(2,ord(u));
n2(i2(u)).. v(u-1) + v(u) + c * v(u+1) =N= min(2,ord(u));
n3(i3(u)).. v(u-1) + v(u) + c * v(u+1) =N= min(2,ord(u));

e1(i1(u)).. v(u-1) + v(u) + c * v(u+1) =E= min(2,ord(u));
e2(i2(u)).. v(u-1) + v(u) + c * v(u+1) =E= min(2,ord(u));
e3(i3(u)).. v(u-1) + v(u) + c * v(u+1) =E= min(2,ord(u));

h        .. v('b') + v('c')            =E= 2;

$ifthen set OLDWAY
model m1 / n1.v, n2.v, n3.v /;
model m2 / n1.v /;
model m3 / e1.v, e2.v  e3.v /;
model mf 'include unmatched h' / m1, h /;
$else
model m1 / ( n1 | n2 | n3 ) : v /;
model m2 / ( n1 ) : v /;
model m3 / ( e1 | e2 | e3 ) : v /;
model mf 'include unmatched h' / m1, h /;
$endif
$macro CHECK_ERR    abort$(0=execerror) 'expected exec errors from preceding solve'
$macro CHECK_MOD(m) abort$[m.modelstat <> %modelstat.NoSolutionReturned%]     'bad modelstat', m.modelstat; \
                    abort$[m.solvestat <> %solvestat.SolveProcessingSkipped%] 'bad solvestat', m.solvestat
$macro CLEAR_ERR    execerror = 0
* if we do not clear the error subsequent solves will be skipped
$macro DOSTUFF(m)   CHECK_ERR;  CHECK_MOD(m);  CLEAR_ERR


* setting maxexecerror > 0 allows us to continue in the face of errors
maxexecerror = 1;


$ontext
------------------------------------------------------------------------
rows: n1_a, n2_b, n3_c
            n1_b
cols:  v_a,  v_b,  v_c
result: bad match, regardless of bounds on v
------------------------------------------------------------------------
$offtext
i1(u) = sameas(u,'a') or sameas(u,'b');
i2(u) = sameas(u,'b');
i3(u) = sameas(u,'c');

solve m1 using mcp;  DOSTUFF(m1);

* v.fx('b') = 1;
solve m1 using mcp;  DOSTUFF(m1);

v.lo('b') = -INF;
v.up('b') = INF;


$ontext
------------------------------------------------------------------------
rows:       n2_b, n3_c
cols:  v_a,  v_b,  v_c
result: bad match if v_a is not fixed
------------------------------------------------------------------------
$offtext
i1(u) = no;
i2(u) = sameas(u,'b');
i3(u) = sameas(u,'c');

solve m1 using mcp;  DOSTUFF(m1);

v.lo('a') = 1;
solve m1 using mcp;  DOSTUFF(m1);

v.up('a') = 2;
solve m1 using mcp;  DOSTUFF(m1);

v.lo('a') = -INF;
v.up('a') =  INF;


$ontext
------------------------------------------------------------------------
rows:       e1_b, e2_c
                  e3_c
cols:  v_a,  v_b,  v_c
result: bad match, regardless of bounds on v
------------------------------------------------------------------------
$offtext
i1(u) = sameas(u,'b');
i2(u) = sameas(u,'c');
i3(u) = sameas(u,'c');

solve m3 using mcp;    DOSTUFF(m3);