selkie08.gms : SELKIE test suite

Description

Test grouping feature of SELKIE.

A general equilibrium model is formulated as a MOPEC. The example is taken
from the following paper:

  Lars Mathiesen. An algorithm based on a sequence of linear complementarity
  problems applied to a Walrasian equilibrium model: an example.
  Mathematical Programming 37 (1987) 1-18.

In the paper, an explicit inverse demand function was used.
Here, we explicitly represent utility maximization problem to formulate the
problem as a MOPEC.

The solution is y* = (3), p* = (6,1,5), and x* = (3,2,0).

Contributor: Youngdae Kim (10.27.2016)


Small Model of Type : GAMS


Category : GAMS Test library


Main file : selkie08.gms

$title 'SELKIE test suite'  (SELKIE08,SEQ=764)

$ontext

Test grouping feature of SELKIE.

A general equilibrium model is formulated as a MOPEC. The example is taken
from the following paper:

  Lars Mathiesen. An algorithm based on a sequence of linear complementarity
  problems applied to a Walrasian equilibrium model: an example.
  Mathematical Programming 37 (1987) 1-18.

In the paper, an explicit inverse demand function was used.
Here, we explicitly represent utility maximization problem to formulate the
problem as a MOPEC.

The solution is y* = (3), p* = (6,1,5), and x* = (3,2,0).

Contributor: Youngdae Kim (10.27.2016)

$offtext

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

set i commodities / 1*3 /;

parameters
    ATmat(i)  technology matrix  / 1 1  , 2 -1 , 3 -1 /
    s(i)      budget share       / 1 0.9, 2 0.1, 3 0 /
    b(i)      endowment          / 1 0  , 2 5  , 3 3 /;

variable u    utility of the consumer;
positive variables
    y         activity of the producer
    x(i)      Marshallian demand of the consumer
    p(i)      prices;

equations
    mkt(i)    constraint on excess demand
    profit    profit of activity
    udef      Cobb-Douglas utility function
    budget    budget constraint;

mkt(i)..
    b(i) + ATmat(i)*y - x(i) =G= 0;

profit..
    sum(i, -ATmat(i)*p(i)) =G= 0;

udef..
    u =E= sum(i, s(i)*log(x(i)));

budget..
    sum(i, p(i)*x(i)) =L= sum(i, p(i)*b(i));

model m / mkt, profit, udef, budget /;

* The second commodity is used as a numeraire.
p.fx('2') = 1;
x.l(i) = 1;

put info 'equilibrium' /;
put 'max', u, 'x', udef, budget /;
put 'vi mkt p profit y' /;
putclose info;

putclose opt 'agent_group   {{1,2}}';

option emp = selkie;
m.optfile = 1;

solve m using emp;
abort$[ abs(y.l      - 3) > tol ] 'bad y.l', y.l;
abort$[ abs(p.l('1') - 6) > tol ] 'bad p.l("1")', p.l;
abort$[ abs(p.l('2') - 1) > tol ] 'bad p.l("2")', p.l;
abort$[ abs(p.l('3') - 5) > tol ] 'bad p.l("3")', p.l;
abort$[ abs(x.l('1') - 3) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2') - 2) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3') - 0) > tol ] 'bad x.l("3")', p.l;

$onecho > agent3_gms

Variables  x2,x3,x4,x5,x6,x7,x8,u6;

Positive Variables  x2,x3,x4,x5,x6,x8,u6;

Equations  e1,e2,e3,e4,e6,dL_dx3,dL_dx4,dL_dx5;

e1..    x2 - x3 + eps*x6 =G= 0;

e2..  - x2 - x4 + eps*x7 =G= -5;

e3..  - x2 - x5 + eps*x8 =G= -3;

e4..  - x6 + x7 + x8 + eps*x2 =G= 0;

e6.. 0 =G= x6*x3 + x7*x4 + x8*x5 - 5*x7 - 3*x8;

dL_dx3.. (-0.9/x3)/(1) + (x6)*u6 =G= 0;

dL_dx4.. (-0.1/x4)/(1) + (x7)*u6 =G= 0;

dL_dx5.. (x8)*u6 + eps*x5 =G= 0;

* set non-default bounds
x7.fx = 1;

* set non-default levels and fix prox terms
x3.l = 1;
x4.l = 1;
x5.l = 1;

Model m / e1.x6,e2.x7,e3.x8,e4.x2,e6.u6,dL_dx3.x3,dL_dx4.x4,dL_dx5.x5 /;

Solve m using mcp;

$offecho

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