*==>scarfbsum.gms $offsymxref offsymlist offuellist offuelxref $title: Scarf's activity analysis example $inlinecom /* */ /* --------------------------------------------------------------- Reference: H. Scarf, The Computation of Economic Equilibria", (Yale University Press, New Haven, Connecticut, 1973). This is a Walrasian model, with 14 commodities, 4 consumers, and 26 sectors of production (activities). It is the second and larger of the two described by Scarf in Chapter 5.3 of the above reference. The optimal commidity prices p(COM) in this model are determined only up to a positive factor. The price system can be normalized by fixing a numeraire or by fixing the sum of the prices. In this model, we take the latter approach. --------------------------------------------------------------- */ sets run / run1 * run3 /, COM /* commodities */ / agri, food, textile, hserv, /* housing services and heating */ fun, /* entertainment */ houseop, /* housing, end of period */ capeop, /* other capital, eop */ steel, coal, wood, housbop, /* housing, beginning of period */ capbop, /* other capital, bop */ labor, forex /, /* foreign exchange */ outcom(COM) / capbop /, /* commodity to subst for */ incom(COM), CNR / 1 * 4 /, /* consumers */ S / 1 * 26 /; /* production sectors or activities */ alias (COM,CCOM); incom(com) = yes$(not outcom(com)); parameters esub (CNR), /* Elasticities of substitution in demand */ alpha(COM,CNR), /* demand function share parameters */ act(COM,S), /* Activity analysis (input/output) matrix */ e(COM,CNR), /* Consumer's initial commodity endowments */ includerun (run) / run1 01 run2 01 run3 0 * the third start point seems to generate an execution error in the constraints /; /* first two init pts are from Harker & Xiao's paper */ $include 'scarfb.dat' /* ensure each consumer's demand share parameters sum to 1 */ loop (CNR, abort $ (abs (sum (COM, alpha(COM,CNR)) - 1) gt 1e-5) "Error in demand share parameters for consumer ", CNR; ); parameter iprice(COM,run), iprod(S, run); /* iprice(COM,"run1") = 1 / card(COM); */ iprice(COM,"run1") = 1; iprod(S,"run1") = 1; iprice(COM,"run2") = 1 / card(COM); iprod(S,"run2") = 0; scalars psum, /* price sum, fixed to sum(com,p.l(com)) */ eps1 / 1.0e-5 /; positive variables p(COM), /* commodity prices */ y(S), /* levels of production */ u; /* dual to pricesum constraint */ equations supply(COM), /* excess supply of commodities */ profit(S), /* (opposite of) profit for activity */ pricesum; /* constraint on sum of prices */ supply(COM)$incom(COM) .. sum(S, act(COM,S)*Y(S)) /* production */ + sum(CNR, E(COM,CNR)) /* initial endowment */ + u /* multiplier of pricesum constraint */ =G= sum ( cnr$(esub(cnr) ne 1), /* consumer demand (CES func) */ alpha(com,cnr) * p(com)**(-esub(cnr)) * ( (sum (incom, e(incom,cnr)*p(incom)) + sum (outcom, e(outcom,cnr)*(psum - sum(incom,p(incom)))) ) / (sum (incom, p(incom)**(1-esub(cnr)) * alpha(incom,cnr)) + sum (outcom, (psum - sum(incom,p(incom)))**(1-esub(cnr)) * alpha(outcom, cnr)) ) ) ) + sum ( cnr$(esub(cnr) eq 1), /* consumer demand (Cobb-Douglas func) */ alpha(com,cnr) * ( sum (incom, p(incom)*e(incom,cnr)) + sum (outcom, (psum-sum(incom,p(incom)))*e(outcom,cnr)) ) / p(com) ); /* consumer demand */ profit(S).. 0 =g= sum ( COM, ( p(COM)$incom(com) + (psum - sum(incom, p(incom)))$outcom(com) ) * act(COM,S) ); pricesum .. psum =g= sum(incom, p(incom)); model scarf / supply.p, profit.y, pricesum.u /; option limrow = 0; option limcol = 0; option iterlim = 5000; option reslim = 120; *p.lo(com) = 0.0001$(smax(cnr, alpha(com,cnr)) gt eps1); loop (run, if (includerun (run), p.l(COM) = iprice(COM,run); y.l(S) = iprod(S,run); psum = max (1e-1, sum(COM,p.l(COM))); display psum; u.l = 0; solve scarf using mcp; ));