Cover Image
close this bookMicrocomputers In Policy Research 4b - Key to Exercises in CGE Modeling Using GAMS (includes software) (IFPRI, 2000, 69 p.)
View the document(introduction...)
View the documentExercise 1: GAMS Code
View the documentExercise A1: GAMS Code
View the documentExercise 2: Mathematical Statement
View the documentExercise 2: GAMS Code
View the documentExercise 3: Mathematical Statement
View the documentExercise 3: GAMS Code
View the documentExercise 4: Mathematical Statement
View the documentExercise 4: GAMS Code
View the documentExercise 5: GAMS Code

Exercise 2: GAMS Code


GAMS 2.50.094 DOS Extended/C

12/10/99 14:41:30 PAGE 1

CGE2


3


4

*INTRODUCTION ====================================================




In this file, the starting point is CGE1.


Intermediate demands are added. A modified SAM is presented.




The line before any new feature or modification starts with


"*++".



14


15

*SETS ============================================================

16


17

SETS

18


19

AC global set (SAM accounts and other items)

20

/

AGR-A

agricultural activity

21


NAGR-A

non-agricultural activity

22


AGR-C

agricultural commodity

23


NAGR-C

non-agricultural commodity

24


LAB

labor

25


CAP

capital

26


U-HHD

urban household

27


R-HHD

rural household

28


TOTAL

total account in SAM

/

29


30

ACNT(AC) all elements in AC except total

31


32

A(AC)

activities

33


/AGR-A, NAGR-A/

34



35

C(AC)

commodities

36


/AGR-C, NAGR-C/

37



38

F(AC)

factors

39


/LAB, CAP/

40



41

H(AC)

households

42


/U-HHD, R-HHD/

43

;


44


45

ALIAS(AC,ACP); ALIAS(C,CP); ALIAS(F,FP);

46

ACNT(AC) = YES; ACNT('TOTAL') = NO; ALIAS(ACNT,ACNTP);

47


48


49

*PARAMETERS======================================================

50


51

PARAMETERS

52


53

ad(A)

efficiency parameter in the production fn for a

54

alpha(F,A)

share of value-added to factor f in activity a

55

beta(C,H)

share of household consumption spending on commodity c

56

cpi

consumer price index

57

cwts(C)

weight of commodity c in the CPI

58

*++


59

ica(C,A)

qnty of c as intermediate input per unit of activity a

60

qfs(F)

supply of factor f

61

shry(H,F)

share for household h in the income of factor f

62

theta(A,C)

yield of output c per unit of activity a

63

;

64


65

*VARIABLES=======================================================

66


67

VARIABLES

68


69

P(C)

price of commodity c

70

PA(A)

price of activity a

71

*++


72

PVA(A)

value-added (or net) price for activity a

73

Q(C)

output level for commodity c

74

QA(A)

level of activity a

75

QF(F,A)

quantity demanded of factor f from activity a

76

QH(C,H)

quantity consumed of commodity c by household h

77

*++


78

QINT(C,A)

qnty of commodity c as intermediate input to activity a

79

WF(F)

price of factor f

80

YF(H,F)

income of household h from factor f

81

YH(H)

income of household h

82

;

83


84

*EQUATIONS=======================================================

85


86

EQUATIONS

87


88

*PRODUCTION AND COMMODITY BLOCK++++++++

89

PRODFN(A)

Cobb-Douglas production function for activity a

90

FACDEM(F,A)

demand for factor f from activity a

91

*++


92

INTDEM(C,A)

intermediate demand for commodity c from activity a

93

OUTPUTFN(C)

output of commodity c

94

PADEF(A)

price for activity a

95

*++


96

PVADEF(A)

value-added price for activity a

97


98

*INSTITUTION BLOCK+++++++++++++++++++++

99

FACTTRNS(H,F)

transfer of income from factor f to h-hold h

100

HHDINC(H)

income of household h

101

HHDEM(C,H)

consumption demand for household h & commodity c

102


103

*SYSTEM CONSTRAINT BLOCK+++++++++++++++

104

FACTEQ(F)

market equilibrium condition for factor f

105

COMEQ(C)

market equilibrium condition for commodity c

106

PNORM

price normalization

107

;

108

109

*PRODUCTION AND COMMODITY BLOCK++++++++

110


111

PRODFN(A)..

QA(A) =E= ad(A)*PROD(F, QF(F,A)**alpha(F,A));

112

*++


113

FACDEM(F,A)..

WF(F) =E= alpha(F,A)*PVA(A)*QA(A) / QF(F,A);

114

*++


115

INTDEM(C,A)..

QINT(C,A) =E= ica(C,A)*QA(A);

116



117

OUTPUTFN(C)..

Q(C) =E= SUM(A, theta(A,C)*QA(A));

118



119

PADEF(A)..

PA(A) =E= SUM(C, theta(A,C)*P(C));

120

*++


121

PVADEF(A)..

PVA(A) =E= PA(A) - SUM(C, P(C)*ica(C,A));

122


123


124

*INSTITUTION BLOCK+++++++++++++++++++++

125


126

FACTTRNS(H,F)..

YF(H,F) =E= shry(H,F)*WF(F)*SUM(A, QF(F,A));

127



128

HHDINC(H)..

YH(H) =E= SUM(F, YF(H,F));

129



130

HHDEM(C,H)..

QH(C,H) =E= beta(C,H)*YH(H)/P(C);

131


132


133

*SYSTEM CONSTRAINT BLOCK+++++++++++++++

134


135

FACTEQ(F)..

SUM(A, QF(F,A)) =E= qfs(F);

136

*++


137

COMEQ('AGR-C')..

Q('AGR-C') =E=

138


SUM(H, QH('AGR-C',H)) + SUM(A, QINT('AGR-C',A));

139



140

PNORM..

SUM(C, cwts(C)*P(C)) =E= cpi;

141


142


143

*MODEL===========================================================

144


145

MODEL

146


CGE2 Model with intermediate demand as new feature

147

/ALL/

148

;

149


150

*SOCIAL ACCOUNTING MATRIX========================================

151


152

TABLE SAM(AC,ACP) social accounting matrix

153


154


AGR-A

NAGR-A

AGR-C

NAGR-C

LAB

CAP

U-HHD

R-HHD

155

AGR-A



225






156

NAGR-A




250





157

AGR-C

60

40





50

75

158

NAGR-C

40

60





100

50

159

LAB

62

55







160

CAP

63

95







161

U-HHD





60

90



162

R-HHD





57

68



163

;









164










165










166

PARAMETER

167

tdiff(AC) column minus row total for account ac;

168


SAM('TOTAL',ACNTP)

= SUM(ACNT, SAM(ACNT,ACNTP));

169


SAM(ACNT,'TOTAL')

= SUM(ACNTP, SAM(ACNT,ACNTP));

170


tdiff(ACNT)

= SAM('TOTAL',ACNT) - SAM(ACNT,'TOTAL');

171


172

DISPLAY SAM, tdiff;

173


174


175

*ASSIGNMENTS FOR PARAMETERS AND VARIABLES========================

176


177

PARAMETERS

178

*The following parameters are used to define initial values of

179

*model variables.

180

P0(C), PA0(A), PVA0(A), Q0(C), QA0(A), QF0(F,A), QH0(C,H), QINT0(C,A),

181

WF0(F), YF0(H,F), YH0(H)

182

;

183


184


185

*PRODUCTION AND COMMODITY BLOCK++++++++

186


187

P0(C)

= 1;

188

PA0(A)

= 1;

189

WF0(F)

= 1;

190


191

*++


192

PVA0(A)

= SUM(F, SAM(F,A)) / (SAM(A,'TOTAL')/PA0(A));

193

Q0(C)

= SAM('TOTAL',C)/P0(C);

194

QA0(A)

= SAM('TOTAL',A)/PA0(A);

195

QF0(F,A)

= SAM(F,A)/WF0(F);

196

*++


197

QINT0(C,A)

= SAM(C,A)/P0(C);

198


199

alpha(F,A)

= SAM(F,A) / SUM(FP, SAM(FP,A));

200

ad(A)

= QA0(A) / PROD(F, QF0(F,A)**alpha(F,A));

201

*++


202

ica(C,A)

= (SAM(C,A)/P0(C)) / QA0(A);

203

theta(A,C)

= (SAM(A,C)/P0(C)) / QA0(A);

204


205


206

*INSTITUTION BLOCK+++++++++++++++++++++

207


208

QH0(C,H)

= SAM(C,H)/P0(C);

209

YF0(H,F)

= SAM(H,F);

210

YH0(H)

= SAM('TOTAL',H);

211


212

beta(C,H)

= SAM(C,H)/SUM(CP, SAM(CP,H));

213

shry(H,F)

= SAM(H,F)/SAM('TOTAL',F);

214


215


216

*SYSTEM CONSTRAINT BLOCK+++++++++++++++

217


218

cwts(C)

= SUM(H, SAM(C,H)) / SUM((CP,H), SAM(CP,H));

219

cpi

= SUM(C, cwts(C)*P0(C));

220

qfs(F)

= SAM(F,'TOTAL')/WF0(F);

221


222


223

*INITIALIZING ALL VARIABLES++++++++++++

224


225

P.L(C)

= P0(C);

226

PA.L(A)

= PA0(A);

227

*++


228

PVA.L(A)

= PVA0(A);

229

Q.L(C)

= Q0(C);

230

QA.L(A)

= QA0(A);

231

QF.L(F,A)

= QF0(F,A);

232

QH.L(C,H)

= QH0(C,H);

233

*++


234

QINT.L(C,A)

= QINT0(C,A);

235

YF.L(H,F)

= YF0(H,F);

236

WF.L(F)

= WF0(F);

237

YH.L(H)

= YH0(H);

238

;

239


240


241

*DISPLAY+++++++++++++++++++++++++++++++

242


243

DISPLAY

244

ad, alpha, beta, cpi, cwts, ica, qfs, shry, theta,

245


246

P.L, PA.L, PVA.L, Q.L, QA.L, QF.L, QH.L, QINT.L, WF.L, YF.L, YH.L

247

;

248


249


250

*SOLVE STATEMENT FOR BASE========================================

251


252

*SOLVE CGE2 USING MCP;

253


254


255

*REPORT SETUP AND BASE REPORT====================================

256


257

*SET AND PARAMETERS FOR REPORTS++++++++

258


259


260

SET

261


SIM

simulations

262


/

BASE

base simulation

263



CINCR

increase in capital stock/

264


265


266


267

PARAMETERS

268


269

QFSCAPSIM(SIM)

capital supply for sim'on sim (experiment parameter)

270



271

QFSREP(F,SIM)

supply of factor f for simulation sim (value used)

272

PREP(C,SIM)

demander price for commodity c

273

PAREP(A,SIM)

price of activity a

274

PVAREP(A,SIM)

value-added price for activity a

275

QREP(C,SIM)

output level for commodity c

276

QAREP(A,SIM)

level of activity a

277

QFREP(F,A,SIM)

demand for factor f from activity a

278

QHREP(C,H,SIM)

consumption of commodity c by household h

279

QINTREP(C,A,SIM)

qnty of commodity c as intermed. input for activity a

280

WFREP(F,SIM)

price of factor f

281

YFREP(H,F,SIM)

income of household h from factor f

282

YHREP(H,SIM)

income of household h

283

;

284


285


286

QFSCAPSIM('BASE')

= qfs('CAP');

287

QFSCAPSIM('CINCR')

= 1.1*qfs('CAP');

288


289

DISPLAY QFSCAPSIM;

290


291


292


293

LOOP(SIM,

294


295

qfs('CAP') = QFSCAPSIM(SIM);

296


297

SOLVE CGE2 USING MCP;

298


299

QFSREP(F,SIM)

= qfs(F);

300

PREP(C,SIM)

= P.L(C);

301

PAREP(A,SIM)

= PA.L(A);

302

PVAREP(A,SIM)

= PVA.L(A);

303

QREP(C,SIM)

= Q.L(C);

304

QAREP(A,SIM)

= QA.L(A);

305

QFREP(F,A,SIM)

= QF.L(F,A);

306

QHREP(C,H,SIM)

= QH.L(C,H);

307

QINTREP(C,A,SIM)

= QINT.L(C,A);

308

WFREP(F,SIM)

= WF.L(F);

309

YFREP(H,F,SIM)

= YF.L(H,F);

310

YHREP(H,SIM)

= YH.L(H);

311



312

);


313



314

OPTION QFREP:3:1:1, QHREP:3:1:1, YFREP:3:1:1;

315


316

DISPLAY

317

QFSREP, PREP, PAREP, PVAREP, QREP, QAREP, QFREP, QHREP, QINTREP,

318

WFREP, YFREP, YHREP

319

;