Skip to content

Instantly share code, notes, and snippets.

@trialsolution
Created February 10, 2014 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trialsolution/8921953 to your computer and use it in GitHub Desktop.
Save trialsolution/8921953 to your computer and use it in GitHub Desktop.
Finding efficient policy combinations in an optimization framework, aka Salhofer (1996)
* GAMS code based on the bread grain market model in
* Salhofer (1996), “Efficient Income Redistribution for a Small Country Using Optimal Combined Instruments.”
* Salhofer, K. 1996. “Efficient Income Redistribution for a Small Country Using Optimal Combined Instruments.” Agricultural Economics 13 (3): 191–99. doi:10.1016/0169-5150(95)01162-5.
* The code builds on Salhofer's GAMS example provided in the course "Welfare Economics"
* General idea of the optimization model:
* Maximizes consumers/taxpayers surplus s.t. a given support level and four policy instruments
SCALARS ES elasticity of supply /1.13/
ED elasticity of demand /-.3/
OQD observed demanded quantity (1000 t) /601.668/
OQS observed supplied quantity (1000 t) /1182.892/
OP observed price (ATS per kilogram) /3.699/
OY observed co-responsibility levy (ATS per kilogram) /.255/
OZ observed difference between support price and reduced price (ATS per kilogram) /.782/
w world market price (ATS per kilogram) /1.12/
OPS observed producer surplus (mill. ATS) in /1979.033141226/
MCF marginal cost of public funds /1.2/;
VARIABLES alpha "multiplicative parameter in the log-linear demand function D=alpha*P^ED"
beta "multiplicative parameter in the log-linear supply function S=beta*P^ES"
QC "quota leve (output control) in 1000t"
P floor price (ATS per kilogram)
Y co-responsibility levy (ATS per kilogram)
Z difference between support price and reduced price (ATS per kilogram)
QD domestic quantity demanded (1000t)
QS domestic quantity supplied (1000t)
PS change in producer surplus (mill. ATS)
CS change in consumer surplus (mill. ATS)
T change in taxpayer surplus (mill. ATS)
CT change in consumer-taxpayer surplus (mill. ATS);
POSITIVE VARIABLES QC,P,Y,Z,QD,QS,PS;
parameter reporting;
* Version 1: Log-linear behavioural curves with Analytical calibration
**********************Initial guesses for variables****************************
QC.L = 694;
P.L = 4.3;
Y.L = 0;
Z.L = 2;
QD.L = 587;
QS.L = 694;
PS.L = 2300;
CS.L = -2200;
T.L = -300;
CT.L = -2500;
*******************************************************************************
* --- Calibration phase
alpha.fx = OQD / (OP**ED);
beta.fx = OQS / [(OP - OY - OZ)**ES];
EQUATIONS
DEMAND domestic demand
SUPPLY domestic supply
PSF change in producer surplus
CSF change in consumer surplus
TF change in taxpayer surplus
CTF change in consumer-taxpayer surplus
CONSTR producer surplus constraint equation
CONSTR1 QS greater-equal Qc;
DEMAND.. QD =E= alpha * (P**ED);
SUPPLY.. QS =E= beta *[(P-Y-Z)**ES];
PSF.. PS =E= (beta/(ES+1)) * [(P-Y-Z)**(ES+1) - w**(ES+1)] + Z*QC;
CSF.. CS =E= (alpha/(ED+1)) * [w**(ED+1) - P**(ED+1)];
TF.. T =E= MCF*((P-Y-w)*(QD-QC)+QD*Y+(P-Y-Z-w)*(QC-QS));
CTF.. CT =E= -(CS+T);
CONSTR.. PS =E= OPS;
CONSTR1.. QS =G= QC;
*******************************************************************************
MODEL OPTPOL /DEMAND, SUPPLY, PSF, CSF, TF, CTF, CONSTR, CONSTR1/;
SOLVE OPTPOL USING NLP MINIMIZING CT;
reporting("P", "log-lin", "analytical") = P.L;
reporting("Y", "log-lin", "analytical") = Y.L;
reporting("Z", "log-lin", "analytical") = Z.L;
reporting("QC", "log-lin", "analytical") = QC.L;
reporting("PS", "log-lin", "analytical") = PS.L;
reporting("CS", "log-lin", "analytical") = CS.L;
reporting("T", "log-lin", "analytical") = T.L;
reporting("QD", "log-lin", "analytical") = QD.L;
reporting("CT", "log-lin", "analytical") = CT.L;
* Version 2: LOG-LINEAR behavioural curves with Numerical calibration
**********************Initial guesses for variables****************************
QC.L = 694;
P.L = 4.3;
Y.L = 0;
Z.L = 2;
QD.L = 587;
QS.L = 694;
PS.L = 2300;
CS.L = -2200;
T.L = -300;
CT.L = -2500;
*******************************************************************************
alpha.LO = -inf;
alpha.UP = +inf;
beta.LO = -inf;
beta.UP = +inf;
model CALIB /DEMAND.alpha, SUPPLY.beta/;
* fix supply and demand at benchmark values
QD.fx = OQD;
QS.fx = OQS;
P.fx = OP;
Y.fx = OY;
Z.fx = OZ;
* Numercial calibration model
solve CALIB using CNS;
* calibrated parameters (fixed variables in GAMS)
alpha.fx = alpha.L;
beta.fx = beta.L;
* free up variables which were fixed for the numerical calibration
QD.LO = 0;
QS.LO = 0;
P.LO = 0;
Y.LO = 0;
Z.LO = 0;
QD.UP = +inf;
QS.UP = +inf;
P.UP = +inf;
Y.UP = +inf;
Z.UP = +inf;
solve optpol using NLP minimizing CT;
reporting("P", "log-lin", "numerical") = P.L;
reporting("Y", "log-lin", "numerical") = Y.L;
reporting("Z", "log-lin", "numerical") = Z.L;
reporting("QC", "log-lin", "numerical") = QC.L;
reporting("PS", "log-lin", "numerical") = PS.L;
reporting("CS", "log-lin", "numerical") = CS.L;
reporting("T", "log-lin", "numerical") = T.L;
reporting("QD", "log-lin", "numerical") = QD.L;
reporting("CT", "log-lin", "numerical") = CT.L;
* Version 3: Linear behavioural funcitons with numerical calibration
* Define calibration parameters for the linear functional forms
variables
c "intercept supply curve"
a "intercept demand curve"
d "slope supply curve"
b "slope demand curve"
;
equations
DEMAND_lin "linear demand curve"
SUPPLY_lin "linear supply curve"
Elaslin_D "demand elasticity assuming linear demand curve"
Elaslin_S "supply elasticity assuming linear supply curve"
PSF_lin "change in producer surplus (linear)"
CSF_lin "change in consumer surplus (linear)"
;
DEMAND_lin.. QD =E= a+b*P;
SUPPLY_lin.. QS =E= c+d*(P-Y-Z);
Elaslin_D.. ED =E= b*P/QD;
Elaslin_S.. ES =E= d*(P-Y-Z)/QS;
PSF_lin.. PS =E= c*(P-Y-Z-w)+d/2*((P-Y-Z)**2-w**2)+Z*QC;
CSF_lin.. CS =E= a*(w-p)+b/2*(w**2-P**2);
* Calibration model for the linear supply/demand curves
model CALIB_lin /DEMAND_lin.a, SUPPLY_lin.c, Elaslin_D.b, Elaslin_S.d/;
* fix supply and demand at benchmark values
QD.fx = OQD;
QS.fx = OQS;
P.fx = OP;
Y.fx = OY;
Z.fx = OZ;
solve CALIB_lin using CNS;
* calibrated parameters (fixed variables in GAMS)
a.fx = a.L;
c.fx = c.L;
b.fx = b.L;
d.fx = d.L;
* free up variables which were fixed for the numerical calibration
QD.LO = 0;
QS.LO = 0;
P.LO = 0;
Y.LO = 0;
Z.LO = 0;
QD.UP = +inf;
QS.UP = +inf;
P.UP = +inf;
Y.UP = +inf;
Z.UP = +inf;
* Optimal policy selection model for the linear case
MODEL OPTPOL_lin /DEMAND_lin, SUPPLY_lin, PSF_lin, CSF_lin, TF, CTF, CONSTR, CONSTR1/;
solve OPTPOL_lin using NLP minimizing CT;
reporting("P", "linear", "numerical") = P.L;
reporting("Y", "linear", "numerical") = Y.L;
reporting("Z", "linear", "numerical") = Z.L;
reporting("QC", "linear", "numerical") = QC.L;
reporting("PS", "linear", "numerical") = PS.L;
reporting("CS", "linear", "numerical") = CS.L;
reporting("T", "linear", "numerical") = T.L;
reporting("QD", "linear", "numerical") = QD.L;
reporting("CT", "linear", "numerical") = CT.L;
execute_unload "salhofer_results.gdx", reporting;
**End of program***************************************************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment