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 A1: GAMS Code

GAMS 2.50.094 DOS Extended/C

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

CGEA1


3


4

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




In this file, the starting point is CGE1. The production function and


the factor demand functions have been rewritten in "longhand".



11


12

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

13


14

SETS

15


16

AC global set (SAM accounts and other items)

17

/

AGR-A

agricultural activity

18


NAGR-A

non-agricultural activity

19


AGR-C

agricultural commodity

20


NAGR-C

non-agricultural commodity

21


LAB

labor

22


CAP

capital

23


U-HHD

urban household

24


R-HHD

rural household

25


TOTAL

total account in SAM

/

26


27

ACNT(AC) all elements in AC except total

28


29

A(AC)

activities

30


/AGR-A, NAGR-A/

31



32

C(AC)

commodities

33


/AGR-C, NAGR-C/

34



35

F(AC)

factors

36


/LAB, CAP/

37



38

H(AC)

households

39


/U-HHD, R-HHD/

40

;


41


42

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

43

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

44


45


46

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

47


48

PARAMETERS

49


50

ad(A)

efficiency parameter in the production fn for a

51

alpha(F,A)

share of value-added to factor f in activity a

52

beta(C,H)

share of household consumption spending on commodity c

53

cpi

consumer price index

54

cwts(C)

weight of commodity c in the CPI

55

qfs(F)

supply of factor f

56

shry(H,F)

share for household h in the income of factor f

57

theta(A,C)

yield of output c per unit of activity a

58

;

59


60

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

61


62

VARIABLES

63


64

P(C)

price of commodity c

65

PA(A)

price of activity a

66

Q(C)

output level for commodity c

67

QA(A)

level of activity a

68

QF(F,A)

quantity demanded of factor f from activity a

69

QH(C,H)

quantity consumed of commodity c by household h

70

WF(F)

price of factor f

71

YF(H,F)

income of household h from factor f

72

YH(H)

income of household h

73

;

74


75

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

76


77

EQUATIONS

78


79

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

80

PRODFN1

Cobb-Douglas production function for AGR-A

81

PRODFN2

Cobb-Douglas production function for NAGR-A

82

FACDEM1

demand for LAB from AGR-A

83

FACDEM2

demand for CAP from AGR-A

84

FACDEM3

demand for LAB from NAGR-A

85

FACDEM4

demand for CAP from NAGR-A

86

*PRODFN(A)

Cobb-Douglas production function for activity a

87

*FACDEM(F,A)

demand for factor f from activity a

88

OUTPUTFN(C)

output of commodity c

89

PADEF(A)

price for activity a

90


91

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

92

FACTTRNS(H,F)

transfer of income from factor f to h-hold h

93

HHDINC(H)

income of household h

94

HHDEM(C,H)

consumption demand for household h & commodity c

95


96

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

97

FACTEQ(F)

market equilibrium condition for factor f

98

COMEQ(C)

market equilibrium condition for commodity c

99

PNORM

price normalization

100

;

101

102

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

103


104

PRODFN1..

QA('AGR-A') =E=

105


ad('AGR-A')*QF('LAB','AGR-A')**alpha('LAB','AGR-A')

106


*QF('CAP','AGR-A')**alpha('CAP','AGR-A');

107



108

PRODFN2..

QA('NAGR-A') =E=

109


ad('NAGR-A')*(QF('LAB','NAGR-A')**alpha('LAB','NAGR-A'))

110


*(QF('CAP','NAGR-A')**alpha('CAP','NAGR-A'));

111



112

FACDEM1..

WF('LAB') =E=

113


alpha('LAB','AGR-A')*PA('AGR-A')*QA('AGR-A')

114


/ QF('LAB','AGR-A');

115



116

FACDEM2..

WF('CAP') =E=

117


alpha('CAP','AGR-A')*PA('AGR-A')*QA('AGR-A')

118


/ QF('CAP','AGR-A');

119



120

FACDEM3..

WF('LAB') =E=

121


alpha('LAB','NAGR-A')*PA('NAGR-A')*QA('NAGR-A')

122


/ QF('LAB','NAGR-A');

123



124

FACDEM4..

WF('CAP') =E=

125


alpha('CAP','NAGR-A')*PA('NAGR-A')*QA('NAGR-A')

126


/ QF('CAP','NAGR-A');

127



128

*PRODFN(A)..

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

129

*FACDEM(F,A)..

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

130



131

OUTPUTFN(C)..

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

132



133

PADEF(A)..

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

134



135



136

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

137


138

FACTTRNS(H,F)..

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

139



140

HHDINC(H)..

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

141



142

HHDEM(C,H)..

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

143


144


145

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

146


147

FACTEQ(F)..

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

148



149

COMEQ('AGR-C')..

Q('AGR-C') =E= SUM(H, QH('AGR-C',H));

150



151

PNORM..

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

152


153


154

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

155


156

MODEL

157


CGEA1A Simple CGE model with selected equations in longhand

/ALL/

158

;

159


160

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

161


162

TABLE SAM(AC,ACP) social accounting matrix

163


164


AGR-A

NAGR-A

AGR-C

NAGR-C

LAB

CAP

U-HHD

R-HHD

165

AGR-A



125






166

NAGR-A




150





167

AGR-C







50

75

168

NAGR-C







100

50

169

LAB

62

55







170

CAP

63

95







171

U-HHD





60

90



172

R-HHD





57

68



173

;









174










175










176

PARAMETER

177

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

178

*This parameter is used to check that the above SAM is balanced.

179


SAM('TOTAL',ACNTP)

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

180


SAM(ACNT,'TOTAL')

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

181


tdiff(ACNT)

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

182


183

DISPLAY SAM, tdiff;

184


185


186

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

187


188

PARAMETERS

189

*The following parameters are used to define initial values of

190

*model variables.

191

P0(C), PA0(A), Q0(C), QA0(A), QF0(F,A), QH0(C,H), WF0(F), YF0(H,F),

192

YH0(H)

193

;

194


195


196

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

197


198

P0(C)

= 1;

199

PA0(A)

= 1;

200

WF0(F)

= 1;

201


202

Q0(C)

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

203

QA0(A)

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

204

QF0(F,A)

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

205


206

alpha(F,A)

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

207

ad(A)

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

208

theta(A,C)

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

209


210


211

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

212


213

QH0(C,H)

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

214

YF0(H,F)

= SAM(H,F);

215

YH0(H)

= SAM('TOTAL',H);

216


217

beta(C,H)

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

218

shry(H,F)

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

219


220


221

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

222


223

cwts(C)

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

224

cpi

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

225

qfs(F)

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

226


227


228

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

229


230

P.L(C)

= P0(C);

231

PA.L(A)

= PA0(A);

232

Q.L(C)

= Q0(C);

233

QA.L(A)

= QA0(A);

234

QF.L(F,A)

= QF0(F,A);

235

QH.L(C,H)

= QH0(C,H);

236

YF.L(H,F)

= YF0(H,F);

237

WF.L(F)

= WF0(F);

238

YH.L(H)

= YH0(H);

239


240


241

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

242


243

DISPLAY

244

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

245


246

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

247

;

248


249


250

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

251


252

*SOLVE CGEA1 USING MCP;

253


254


255

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

256


257

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

258


259

SET

260


SIM

simulations

261


/

BASE

base simulation

262



CINCR

increase in capital stock/

263

264

PARAMETERS

265


266

QFSCAPSIM(SIM) capital supply for sim'on sim (experiment parameter)

267

*Parameter is used to change the value for the capital stock parameter

268

*before solving the model for simulation sim

269


270

QFSREP(F,SIM)

supply of factor f for simulation sim (value used)

271

PREP(C,SIM)

demander price for commodity c

272

PAREP(A,SIM)

price of activity a

273

QREP(C,SIM)

output level for commodity c

274

QAREP(A,SIM)

level of activity a

275

QFREP(F,A,SIM)

demand for factor f from activity a

276

QHREP(C,H,SIM)

consumption of commodity c by household h

277

WFREP(F,SIM)

price of factor f

278

YFREP(H,F,SIM)

income of household h from factor f

279

YHREP(H,SIM)

income of household h

280

SAMREP(SIM,AC,ACP)

SAM computed from model solution

281

BALCHK(AC,SIM)

column minus row total for account ac in SAM

282

;

283


284

QFSCAPSIM('BASE')

= qfs('CAP');

285

QFSCAPSIM('CINCR')

= 1.1*qfs('CAP');

286


287

DISPLAY QFSCAPSIM;

288


289


290

LOOP(SIM,

291


292

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

293


294

SOLVE CGEA1 USING MCP;

295


296

QFSREP(F,SIM)

= qfs(F);

297



298

PREP(C,SIM)

= P.L(C);

299

PAREP(A,SIM)

= PA.L(A);

300

QREP(C,SIM)

= Q.L(C);

301

QAREP(A,SIM)

= QA.L(A);

302

QFREP(F,A,SIM)

= QF.L(F,A);

303

QHREP(C,H,SIM)

= QH.L(C,H);

304

WFREP(F,SIM)

= WF.L(F);

305

YFREP(H,F,SIM)

= YF.L(H,F);

306

YHREP(H,SIM)

= YH.L(H);

307



308

*Payments from activities

309

SAMREP(SIM,F,A)

= WF.L(F)*QF.L(F,A);

310

*Payments from commodities

311

SAMREP(SIM,A,C)

= P.L(C)*theta(A,C)*QA.L(A);

312

*Payments from factors

313

SAMREP(SIM,H,F)

= YF.L(H,F);

314

*Payments from households

315

SAMREP(SIM,C,H)

= P.L(C)*QH.L(C,H);

316


317

);

318


319


320

*Computing totals for SAMREP

321

SAMREP(SIM,'TOTAL',ACNTP)

= SUM(ACNT, SAMREP(SIM,ACNT,ACNTP));

322

SAMREP(SIM,ACNT,'TOTAL')

= SUM(ACNTP, SAMREP(SIM,ACNT,ACNTP));

323


324

*Check that SAMREP is balanced

325

BALCHK(ACNT,SIM) = SAMREP(SIM,'TOTAL',ACNT) - SAMREP(SIM,ACNT,'TOTAL');

326


327


328

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

329


330

DISPLAY

331

QFSREP, PREP, PAREP, QREP, QAREP, QFREP, QHREP, WFREP, YFREP, YHREP,

332

SAMREP, BALCHK

333

;