Description
Test if the objective variable is not removed when it is not a free variable. Contributor: Youngdae Kim (11.07.2017)
Small Model of Type : GAMS
Category : GAMS Test library
Main file : selkie18.gms
$title 'SELKIE test suite: obj variable not free' (SELKIE18,SEQ=774)
$ontext
Test if the objective variable is not removed when it is not a free variable.
Contributor: Youngdae Kim (11.07.2017)
$offtext
$if not set TESTTOL $set TESTTOL 1e-4
scalar tol / %TESTTOL% /;
file pathopt / 'path.opt' /;
file opt / 'selkie.opt' /;
file info / '%emp.info%' /;
positive variable obj, x;
equation defobj;
defobj..
obj =E= sqr(x-1) + 5;
model m / defobj /;
put info 'equilibrium';
putclose / 'min', obj, x, defobj;
* We need a strong convergence tolerance to get an accurate solution.
putclose pathopt 'convergence_tolerance 1e-8';
putclose opt 'subsolveropt 1';
m.optfile = 1;
option emp = selkie;
solve m using emp;
display obj.l, x.l;
abort$[ abs(x.l - 1) > tol ] 'bad x.l', x.l;
abort$[ abs(obj.l - 5) > tol ] 'bad obj.l', obj.l;
* By default, it should create an MCP model.
$onecho > agent1_gms
Variables x1,x2,u1;
Positive Variables x1,x2;
Equations e1,dL_dx1,dL_dx2;
e1.. -sqr((-1) + x2) + x1 =E= 5;
dL_dx1.. 1 - u1 + eps*x1 =G= 0;
dL_dx2.. - (-2*(-1 + x2))*u1 =G= 0;
Model m / e1.u1,dL_dx1.x1,dL_dx2.x2 /;
Solve m using mcp;
$offecho
execute 'cat agent1_gms > agent1.gms.want';
execute 'cat "%gams.scrdir%agent1.gms" > agent1.gms.got';
execute '=diff -bw agent1.gms.want agent1.gms.got';
abort$errorlevel 'Files agent1.gms.want and agent1.gms.got differ';