27.10.2013 Views

Quick start - Gams

Quick start - Gams

Quick start - Gams

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Notes<br />

When a statement like cc(j)=bc(j)+10; is executed this is done for all elements in j so if j<br />

had 100,000 elements this would define values for each and every one.<br />

These assignments can be the sole entry of a data item or may redefine items.<br />

If an item is redefined then it has the new value from then on and does not retain the<br />

original data.<br />

The example cc("j1")=1; shows how one addresses a single specific element not the<br />

whole set, namely one puts the entry in quotes (single or double). This is further<br />

discussed in the Sets chapter.<br />

Calculations do not have to cover all set element cases of the parameters involved<br />

(through partial set references as discussed in the Sets chapter). Set elements that are not<br />

computed over retain their original values if defined or a zero if never defined by entry or<br />

previous calculation.<br />

A lot more on calculations appears in the Calculating chapter.<br />

Algebraic nature of variable and equation specifications<br />

When one moves to algebraic modeling the variable and equation declarations can have an added<br />

element of set dependency as illustrated in our examples and reproduced below<br />

POSITIVE VARIABLES x(j);<br />

VARIABLES PROFIT ;<br />

EQUATIONS OBJective ,<br />

constraint(i) ;<br />

POSITIVE VARIABLES P(commodities)<br />

Qd(commodities)<br />

Qs(commodities) ;<br />

EQUATIONS PDemand(commodities)<br />

PSupply(commodities)<br />

Equilibrium(commodities) ;<br />

Such definitions indicate that these variables and equations are potentially defined for every<br />

element of the defining set (also called the domain) thus x could exist for each and every element<br />

in j. However the actual definition of variables does not occur until the .. equation specifications<br />

are evaluated as discussed next. More on set dependent variable and equation definitions<br />

appears in the Variables, Equations, Models and Solves chapter.<br />

Algebra and model .. specifications<br />

The equations and variables in a model are defined by the evaluation of the .. equation<br />

specifications. The .. equations for our examples are<br />

OBJective.. PROFIT=E= SUM(J,c(J)*x(J)) ;<br />

constraint(i).. SUM(J,a(i,J) *x(J)) =L= b(i);<br />

Courtesy of B.A. McCarl, October 2002 31

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

Saved successfully!

Ooh no, something went wrong!