vidualvar.gms : VI with dualvar specified for VI constraint

Description

```Usually when we use the empinfo syntax

dualvar x e

it is for the case where e is a constraint in an optimization model,
and we want to use the dual multiplier e.m (aka x) in our algebra.
It is also possible to do this when e is a constraint in a VI, as we
show here.
This wasn't working in GAMS Distribution 24.1.1 and previous.

Contributor: Dirkse & Ferris, June 2013
```

Small Model of Type : VI

Category : GAMS EMP library

Main file : vidualvar.gms

``````\$title VI with dualvar specified for VI constraint (VIDUALVAR,SEQ=96)

\$ontext

Usually when we use the empinfo syntax

dualvar x e

it is for the case where e is a constraint in an optimization model,
and we want to use the dual multiplier e.m (aka x) in our algebra.
It is also possible to do this when e is a constraint in a VI, as we
show here.
This wasn't working in GAMS Distribution 24.1.1 and previous.

Contributor: Dirkse & Ferris, June 2013

\$offtext

\$ontext
We'll specify a simple two-agent problem and then model it in EMP in
several different ways.

min   v + w =: z
s.t.  sqr(v) + 2*w >= 1  perp-to u >= 0
v, w >= 0

VI: F_y() := y - 4*u - 1 perp-to y free

To get a model with dualVar involving a constraint in a VI,
we will rewrite the min agent as a VI.
\$offtext

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'
Dv    'Lagrangian deriv wrt v'
Dw    'Lagrangian deriv wrt w'
Fv    'VI function in opt-as-VI'
Fw    'VI function in opt-as-VI'
;

defz.. v+w =e= z;
g   .. sqrt(v+1) + 2*w =g= 2;
Fy  .. y =e= 4*u - 1;
Dv  .. 1  - (1/(v+1))*u =N= 0;
Dw  .. 1  - 2        *u =N= 0;
Fv  .. 1 =N= 0;
Fw  .. 1 =N= 0;

model opt 'min agent and VI agent' / defz, g, Fy /;
model vi  'VI agent and VI agent'  / Fv, Fw, g, Fy /;
model m   'explicit MCP'           / Dv.v, Dw.w, g.u, Fy.y /;

file jamsopt / 'jams.opt'/;
file empinfo / 'empinfo.txt' /;

putclose jamsopt
'EMPInfoFile empinfo.txt' /
'FileName mcpOpt.gms' /
'Dict dictOpt.txt' /
*  'debug 2' /
;

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

opt.optfile = 1;
opt.iterlim = 0;
defz.m = -1;
g.m = 0.5;
Fy.m = 1;
v.l = 0;
w.l = 0.5;
y.l = 1;
u.l = 0.5;
solve opt using emp;
abort\$[opt.modelStat <> %MODELSTAT.LOCALLY OPTIMAL%] 'Opt should solve OK in zero iters';
abort\$[opt.solveStat <> %SOLVESTAT.NORMAL COMPLETION%] 'Opt should solve OK in zero iters';

m.iterlim = 0;
solve m using mcp;
abort\$[m.modelStat  > %MODELSTAT.LOCALLY OPTIMAL%] 'm should solve OK in zero iters';
abort\$[m.solveStat <> %SOLVESTAT.NORMAL COMPLETION%] 'm should solve OK in zero iters';

putclose jamsopt
'EMPInfoFile empinfo.txt' /
'FileName mcpVI.gms' /
'Dict dictVI.txt' /
*  'debug 2' /
;
putclose empinfo
'equilibrium' /
'  vi Fv v  Fw w  g' /
'  vi Fy y' /
'  dualvar u g' /
;
vi.optfile = 1;
vi.iterlim = 0;
solve vi using emp;
abort\$[vi.modelStat <> %MODELSTAT.LOCALLY OPTIMAL%] 'VI should solve OK in zero iters';
abort\$[vi.solveStat <> %SOLVESTAT.NORMAL COMPLETION%] 'VI should solve OK in zero iters';
``````