transecs.gms : Transportation model as equilibrium problem using embedded complementarity

Description

Dantzig's original transportation model TRNSPORT (in the GAMS Model
Library) is reformulated using EMP in two ways: first as an embedded
complementarity system or ECS (i.e. using a solve statement containing an
objective variable and an EMP info file with the 'dualvar' directive),
next as a single-agent equilibrium model (i.e. using a solve statement
with no objective direction or variable and an EMP info file starting with
the 'equilibrium' directive and specifying one agent, also with a
'dualvar' directive).  Note that the two EMP models are different but
equivalent ways to specify the same behavior.  Each reproduces the results
of TRANSMCP (in GAMS Model Library) which uses a linear complementarity
approach.

As in TRANSMCP, we have 4 steps:
   1. original fixed-demand LP to get calibration data
   2a. reproduce fixed-demand results with flexible-demand model using ECS
       (long-form solve statement specifying obj var & direction)
   2b. same as 2a, but with short-form solve statement
   3. counter-factual with fixed-demand model
   4a. counter-factual with flexible-demand model (ECS)
   4b. counter-factual with flexible-demand model (equilibrium)

Dantzig, G B, Chapter 3.3. In Linear Programming and Extensions.
Princeton University Press, Princeton, New Jersey, 1963.

Contributor: Steven Dirkse, January 2009


Small Model of Type : ECS


Category : GAMS EMP library


Main file : transecs.gms

$title Transportation model as equilibrium problem using embedded complementarity (TRANSECS,SEQ=14)

$onText
Dantzig's original transportation model TRNSPORT (in the GAMS Model
Library) is reformulated using EMP in two ways: first as an embedded
complementarity system or ECS (i.e. using a solve statement containing an
objective variable and an EMP info file with the 'dualvar' directive),
next as a single-agent equilibrium model (i.e. using a solve statement
with no objective direction or variable and an EMP info file starting with
the 'equilibrium' directive and specifying one agent, also with a
'dualvar' directive).  Note that the two EMP models are different but
equivalent ways to specify the same behavior.  Each reproduces the results
of TRANSMCP (in GAMS Model Library) which uses a linear complementarity
approach.

As in TRANSMCP, we have 4 steps:
   1. original fixed-demand LP to get calibration data
   2a. reproduce fixed-demand results with flexible-demand model using ECS
       (long-form solve statement specifying obj var & direction)
   2b. same as 2a, but with short-form solve statement
   3. counter-factual with fixed-demand model
   4a. counter-factual with flexible-demand model (ECS)
   4b. counter-factual with flexible-demand model (equilibrium)

Dantzig, G B, Chapter 3.3. In Linear Programming and Extensions.
Princeton University Press, Princeton, New Jersey, 1963.

Contributor: Steven Dirkse, January 2009

$offText

Parameter report(*,*,*)  summary report;

$call gamslib -q trnsport

* --- 1. now we solve the original fixed-demand trnsport model
$include trnsport
report(i,j,'fixed')       = x.l(i,j);
report(i,"price",'fixed') = supply.m(i);
report("price",j,'fixed') = demand.m(j);

* now we introduce a flexible demand function
parameters esub(j) price elasticity of demand (at prices equal to unity)
                   / new-york 1.5, chicago 1.2, topeka 2.0  /
           pbar(j) reference price at demand node j;

variable  p(j)             shadow price at demand node j;
Equations flexdemand(j)  price-responsive demand at market j;

flexdemand(j)..   sum(i, x(i,j)) =g= b(j)*(pbar(j)/p(j))**esub(j);

model flex trnsport model with flexible demand / cost,supply,flexdemand /;

p.lo(j) = 1e-3; option limcol=0,limrow=0;

file fx / '%emp.info%' /;

*  calibrate the demand functions:
pbar(j) = demand.m(j);

* --- 2a. replicate the fixed demand equilibrium using ECS
* use the EMP info file to define the price to be the
* dual of the flexible demand equation
put fx '* p(j) = flexdemand.m(j)';
putclose / 'dualvar p flexdemand';
solve flex using emp min z;
report(i,j,"flex-a")       = x.l(i,j);
report(i,"price",'flex-a') = supply.m(i);
report("price",j,"flex-a") = p.l(j);
* report("profit",'',"flex") = sum((i,j), (p.l(j)-c(i,j))*x.l(i,j));

* --- 2b. replicate the fixed demand equilibrium, using 'equilibrium'
put fx / 'equilibrium' /;
put fx / 'min z x cost flexdemand supply' /;
putclose fx / 'dualvar p flexdemand' /;
solve flex using emp;
report(i,j,"flex-b")       = x.l(i,j);
report(i,"price",'flex-b') = supply.m(i);
report("price",j,"flex-b") = p.l(j);

*  prepare data for counter-factual
c("seattle","chicago") = 0.5 * c("seattle","chicago");

* --- 3. counter-factual with fixed demand
Solve transport using lp min z;
report(i,j,'fixed CF')       = x.l(i,j);
report(i,"price",'fixed CF') = supply.m(i);
report("price",j,'fixed CF') = demand.m(j);

* --- 4a. counter-factual with flexible demand
put fx '* p(j) = flexdemand.m(j)';
putclose / 'dualvar p flexdemand';
Solve flex using emp min z;
report(i,j,"flex CF-a")       = x.l(i,j);
report(i,"price",'flex CF-a') = supply.m(i);
report("price",j,"flex CF-a") = p.l(j);
* report("profit",'',"flex CF") = sum((i,j), (p.l(j)-c(i,j))*x.l(i,j));

* --- 4b. counter-factual with flexible demand, using 'equilibrium'
put fx / 'equilibrium' /;
put fx / 'min z x cost flexdemand supply' /;
putclose fx / 'dualvar p flexdemand' /;
solve flex using emp;
report(i,j,"flex CF-b")       = x.l(i,j);
report(i,"price",'flex CF-b') = supply.m(i);
report("price",j,"flex CF-b") = p.l(j);

Display report;
execute_unload 'ecsReport.gdx', report;