27.10.2013 Views

Quick start - Gams

Quick start - Gams

Quick start - Gams

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

POSITIVE VARIABLES P(commodities)<br />

Qd(commodities)<br />

Qs(commodities) ;<br />

EQUATIONS PDemand(commodities)<br />

PSupply(commodities)<br />

Equilibrium(commodities) ;<br />

alias (cc,commodities);<br />

Pdemand(commodities)..<br />

P(commodities)=g=<br />

intercepts("demand",commodities)<br />

+sum(cc,slopes("demand",commodities,cc)*Qd(cc));<br />

Psupply(commodities)..<br />

intercepts("supply",commodities)<br />

+sum(cc,slopes("supply",commodities,cc)* Qs(cc))<br />

=g= P(commodities);<br />

Equilibrium(commodities)..<br />

Qs(commodities)=g= Qd(commodities);<br />

MODEL PROBLEM /Pdemand.Qd, Psupply.Qs,Equilibrium.P/;<br />

SOLVE PROBLEM USING MCP;<br />

Dissecting the algebraic model<br />

Sets<br />

Above we used the subscripts i , j, commodities and cc for addressing the variable, equation and<br />

data items. In GAMS subscripts are SETs. In order to use any subscript one must declare an<br />

equivalent set.<br />

The set declaration contains<br />

the set name<br />

a list of elements in the set (up to 31 characters long spaces etc allowed in quotes)<br />

optional labels describing the whole set<br />

optional labels defining individual set elements<br />

The general format for a set statement is:<br />

SET setname optional defining text<br />

/ firstsetelementname optional defining text<br />

secondsetelementname optional defining text<br />

... /;<br />

Examples<br />

(sets.gms)<br />

SETs j /x1,x2,x3/<br />

i /r1 ,r2/;<br />

SET PROCESS PRODUCTION PROCESSES /X1,X2,X3/;<br />

SET Commodities Crop commodities /<br />

corn in bushels,<br />

wheat in metric tons,<br />

milk in hundred pounds/ ;<br />

More on sets appears in the Sets chapter.<br />

Courtesy of B.A. McCarl, October 2002 27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!