selkie13.gms : SELKIE test suite: dualvar

Description

Test dualvar.

Contributor: Youngdae Kim (08.31.2017)


Small Model of Type : GAMS


Category : GAMS Test library


Main file : selkie13.gms

$title 'SELKIE test suite: dualvar'  (SELKIE13,SEQ=769)

$ontext

Test dualvar.

Contributor: Youngdae Kim (08.31.2017)

$offtext

$if not set TESTTOL $set TESTTOL 1e-4
scalar tol / %TESTTOL% /;
file opt   / 'selkie.opt' /;
file info  / '%emp.info%' /;

positive variables
  v  'belongs to min agent'
  w  'belongs to min agent'
  u  'equivalenced to g.m'
;

free variables
  y  'belongs to VI agent'
  z  'objective var'
;

equations
  defz  'objective def'
  g     'constraint for min agent'
  Fy    'VI function'
;

defz.. v+w =e= z;
g   .. sqrt(v+1) + 2*w =g= 2;
Fy  .. y =e= 4*u - 1;

putclose info
   'equilibrium' /
   'min z v w defz g' /
   'vi Fy y' /
   'dualvar u g' /
   ;

model m 'min agent and VI agent' / defz, g, Fy /;

option emp = selkie;
solve m using emp;

abort$[ abs(v.l - 0.0) > tol ] 'bad v.l', v.l;
abort$[ abs(w.l - 0.5) > tol ] 'bad w.l', w.l;
abort$[ abs(y.l - 1.0) > tol ] 'bad y.l', y.l;
abort$[ abs(u.l - 0.5) > tol ] 'bad u.l', u.l;

$onecho > agent1_gms

Variables  x1,x2,x3;

Positive Variables  x1,x2,x3;

Equations  e2,dL_dx1,dL_dx2;

e2.. sqrt(1 + x1) + 2*x2 =G= 2;

dL_dx1.. 1 - (0.5/sqrt(1 + x1))*x3 =G= 0;

dL_dx2.. 1 - 2*x3 + eps*x2 =G= 0;



Model m / e2.x3,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 diff';

$onecho > agent2_gms

Variables  x3,x4;

Positive Variables  x3;

Equations  e3;

e3..  - 4*x3 + x4 =E= -1;



* fix levels belonging to other agents
x3.fx = 0;

Model m / e3.x4 /;

Solve m using mcp;

$offecho

execute 'cat agent2_gms > agent2.gms.want';
execute 'cat "%gams.scrdir%agent2.gms" > agent2.gms.got';
execute '=diff -bw agent2.gms.want agent2.gms.got';
abort$errorlevel 'Files agent2.gms.want and agent2.gms.got diff';