mpsge11.gms : MPSGE test - multiple fixed income levels

Description

Usually only one numeraire is fixed in an MPSGE model: either a price
or income level chosen by the user or an income level chosen by
MPSGE.  But in some cases the user fixes multiple income levels.  The
MPSGE function evaluator must check for this and use the fixed income
levels instead of the usual computed ones.

To test this we adapt the scarfmge model from gamslib.

Contributor: Tom Rutherford, Steve Dirkse


Small Model of Type : MPSGE


Category : GAMS Test library


Main file : mpsge11.gms

$title MPSGE test -  multiple fixed income levels (MPSGE11,SEQ=481)

$onText
Usually only one numeraire is fixed in an MPSGE model: either a price
or income level chosen by the user or an income level chosen by
MPSGE.  But in some cases the user fixes multiple income levels.  The
MPSGE function evaluator must check for this and use the fixed income
levels instead of the usual computed ones.

To test this we adapt the scarfmge model from gamslib.

Contributor: Tom Rutherford, Steve Dirkse

$offText


SET SC TAX RATE SCENARIOS /ZERO, LOW, MEDIUM, HIGH/;

PARAMETER  T(SC)        TAX RATES / LOW 0.05, MEDIUM 0.20, HIGH 0.50/;

SETS
       C       COMMODITIES

               /UNSKLAB, SKILLAB, CAPEOP, NONDURBL, DURABLE, CAPBOP/

       K(C)    CAPITAL INPUT IDENTIFIER /CAPBOP/,

       H       CONSUMERS /AGENT1,AGENT2,AGENT3,AGENT4,AGENT5/

       S       SECTORS /D1, D2, N1, N2, N3, CD, C1, C2/;

ALIAS (C,CC);

TABLE E(C,H)  Commodity endowments

            AGENT1     AGENT2     AGENT3     AGENT4     AGENT5
CAPBOP         3         0.1         2          1           6
SKILLAB        5         0.1         6          0.1         0.1
UNSKLAB        0.1       7           0.1        8           0.5
DURABLE        1         2           1.5        1           2

PARAMETER       TR(H)   TAX DISTRIBUTION RULE /AGENT1 1/;

SCALAR          TK      TAX ON CAPITAL IN CURRENT SCENARIO;

TABLE D(C,H) Reference demands

            AGENT1     AGENT2     AGENT3     AGENT4     AGENT5
CAPEOP         4         0.4          2         5          3
SKILLAB        0.2                    0.5
UNSKLAB                  0.6                    0.2        0.2
NONDURBL       2         4           2          5          4
DURABLE        3.2       1           1.5        4.5        2

PARAMETER  ESUB(H)  Elasticities in demand

/       AGENT1          1.2,
       AGENT2          1.6,
       AGENT3          0.8,
       AGENT4          0.5,
       AGENT5          0.6  /;

TABLE DATA(*,C,S)  Activity analysis matrix

                        D1          D2          N1          N2          N3

OUTPUT.NONDURBL                                 6.0         8.0         7.0
OUTPUT.DURABLE          4.0         3.5
OUTPUT.CAPEOP           4.0         4.0         1.6         1.6         1.6
INPUT .CAPBOP           5.3         5.0         2.0         2.0         2.0
INPUT .SKILLAB          2.0         1.0         2.0         4.0         1.0
INPUT .UNSKLAB          1.0         6.0         3.0         1.0         8.0

             +          CD          C1          C2

OUTPUT.CAPEOP           0.9         7.0         8.0
INPUT .CAPBOP           1.0         4.0         5.0
INPUT .SKILLAB                      3.0         2.0
INPUT .UNSKLAB                      1.0         8.0;


$onText

$MODEL: SCARF

$SECTORS:
       Y(S)    ! Activity level

$COMMODITIES:
       P(C)    ! Market price
       PT$TK   ! Price index for lumpsum redistribution of tax revenue.

$CONSUMERS:
       HH(H)   ! Household income
       GOVT$TK ! Government tax revenue (only included when taxes are levied).

$REPORT:
       V:WELFARE(H)    W:HH(H)

$PROD:Y(S)
       O:P(C)          Q:DATA("OUTPUT",C,S)
       I:P(C)          Q:DATA("INPUT" ,C,S)  A:GOVT$TK  T:TK$K(C)

$DEMAND:HH(H)  s:ESUB(H)
       D:P(C)          Q:D(C,H)
       E:P(C)          Q:E(C,H)
       E:PT$TK         Q:TR(H)

$DEMAND:GOVT$TK
       D:PT

$REPORT:
       V:X(c,h)        D:P(C)  DEMAND:HH(h)

$offText

*       READ THE HEADER:
$sysInclude mpsgeset SCARF

TK = 1;

* Fix income levels to arbitrary values:
HH.FX(h) = sum(c, E(c,h));

* Solve the fixed income relaxation:
$include SCARF.GEN
SOLVE SCARF USING MCP;


* verify a correct GAMS/MPSGE function evaluator
parameter   err(h,*)  Error in the solution returned by MPSGE;
scalar dt;
err(h,"HH.L") = HH.L(h);
err(h,"P*X")  = sum(c, P.L(c)*X.L(c,h));
err(h,"Diff") = HH.L(h) - sum(c, P.L(c)*X.L(c,h));
dt = sum{h, abs(err(h,"Diff"))};
display err, dt;
* if this is too greedy we can always ask for less precision
abort$[dt > 1e-8] 'error in solution returned by MPSGE', err, dt;