mcp13.gms : Test equList matching in model statement

Description

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

Contributor: Steven Dirkse, September 2024


Small Model of Type : MCP


Category : GAMS Test library


Main file : mcp13.gms

$title Test equList matching in model statement (MCP13, SEQ=966)

$ontext
Test equList matching in model statement.
In particular, test on valid 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)
  n2(u)
  n3(u)
  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 mf 'include unmatched h' / m1, h /;
$else
model m1 / ( n1 | n2 | n3 ) : v /;
model m2 / ( n1 ) : v /;
model mf 'include unmatched h' / m1, h /;
$endif
model mu 'completely unmatched' / e1, e2, e3 /;

$macro CHECK_MOD(m) abort$[m.solvestat <> 1] 'bad solvestat', m.solvestat


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

solve m1 using mcp;  CHECK_MOD(m1);

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

v.lo('b') = -INF;
solve m1 using mcp;  CHECK_MOD(m1);

v.up('b') = 0.5;
solve m1 using mcp;  CHECK_MOD(m1);
v.up('b') = INF;


$ontext
------------------------------------------------------------------------
rows:       n2_b, n3_c
cols:  v_a,  v_b,  v_c
result: good match as long as v_a is fixed
------------------------------------------------------------------------
$offtext
i1(u) = no;
i2(u) = sameas(u,'b');
i3(u) = sameas(u,'c');
v.fx('a') = 1;

solve m1 using mcp;  CHECK_MOD(m1);

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

v.up('b') = INF;
solve m1 using mcp;  CHECK_MOD(m1);

v.lo('b') = 0.5;
solve m1 using mcp;  CHECK_MOD(m1);
v.lo('b') = -INF;
v.lo('a') = -INF;
v.up('a') =  INF;

$ontext
------------------------------------------------------------------------
rows: n1_a, n1_b, n1_c
cols:  v_a,  v_b,  v_c
result: good match as long as v_a is fixed
------------------------------------------------------------------------
$offtext
i1(u) = yes;
i2(u) = no;
i3(u) = no;
solve m1 using mcp;  CHECK_MOD(m1);
solve m2 using mcp;  CHECK_MOD(m2);

$ontext
------------------------------------------------------------------------
rows: n1_a, n2_b,      h
cols:  v_a,  v_b,  v_c
result: good match, as long as v_c is free
------------------------------------------------------------------------
$offtext
i1(u) = sameas(u,'a');
i2(u) = sameas(u,'b');
i3(u) = no;
solve mf using mcp;  CHECK_MOD(mf);


$ontext
------------------------------------------------------------------------
rows:       e1_b, e2_c
                  e3_c
cols:  v_a,  v_b,  v_c
result: good match, as long as v is free
        but the model is not good, probably not what the user wanted
------------------------------------------------------------------------
$offtext
i1(u) = sameas(u,'b');
i2(u) = sameas(u,'c');
i3(u) = sameas(u,'c');
solve mu using mcp;  CHECK_MOD(mu);