Description
Test evList matching in model statement. In particular, test on valid inputs. Contributor: Steven Dirkse, April 2025
Small Model of Type : GAMS
Category : GAMS Test library
Main file : mcp18.gms
$title Test evList matching in model statement (MCP18, SEQ=982)
$ontext
Test evList matching in model statement.
In particular, test on valid inputs.
Contributor: Steven Dirkse, April 2025
$offtext
set
k / a, b /
j / 1, 2 /
kj(k,j)
;
alias (k,i);
table A(i,k,j)
a.1 a.2 b.1 b.2
a 1 -1 4 1
b 1 1 1 4 ;
parameter
v_(k,j)
b(i)
;
v_(k,j) = ord(k) + (ord(j)-1)/2;
b(i) = sum{(k,j), A(i,k,j)*v_(k,j)};
variable
v(k,j)
;
equation
f(i)
;
f(i).. sum{(k,j), A(i,k,j)*v(k,j)} =E= b(i);
model mf / ( f ) : ( v ) /;
$macro CHECK_MOD(m) abort$[m.solvestat <> 1] 'bad solvestat', m.solvestat
$ontext
------------------------------------------------------------------------
case: (f).(v)
rows: f_a, f_b cols: v_a1, v_a2, v_b1, v_b2
result: good match, assuming 2 cols are free and the rest are fixed
------------------------------------------------------------------------
$offtext
kj(k,j) = NO;
kj(i,'2') = YES;
v.lo(k,j) = -INF; v.up(k,j) = INF;
v.fx(kj) = v_(kj);
solve mf using mcp; CHECK_MOD(mf);
kj(k,j) = NO;
kj('a','2') = YES;
kj('b','1') = YES;
v.lo(k,j) = -INF; v.up(k,j) = INF;
v.fx(kj) = v_(kj);
* Make sure, that evList models can be part of another model
model mmf / mf /;
solve mmf using mcp; CHECK_MOD(mmf);
kj(k,j) = NO;
kj('a',j) = YES;
v.lo(k,j) = -INF; v.up(k,j) = INF;
v.fx(kj) = v_(kj);
solve mf using mcp; CHECK_MOD(mf);