Algebra and model .. specifications

Top  Previous  Next

The equations and variables in a model are defined by the evaluation of the .. equation specifications.  The .. equations for our examples are

 

OBJective.. PROFIT=E=   SUM(J,c(J)*x(J)) ;

constraint(i).. SUM(J,a(i,J) *x(J))  =L= b(i);

 

Pdemand(commodities)..

    P(commodities)=g= 

       intercepts("demand",commodities)

       +sum(cc,slopes("demand",commodities,cc)*Qd(cc));

Psupply(commodities)..

    intercepts("supply",commodities)

   +sum(cc,slopes("supply",commodities,cc)* Qs(cc))

    =g= P(commodities);

Equilibrium(commodities).. 

     Qs(commodities)=g=  Qd(commodities);

 

Here GAMS will operate over all the elements in the sets in each term.  For example, in the OBJective equation GAMS will add up the term c(J)*x(J) for all set elements in j.  Similarly, the equation constraint(i) will define a separate constraint equation case for each element of i.  Also within the equation case associated with an element of i only the elements of a(i,j) associated with that particular i will be included in the term SUM(J,a(i,J) *x(J)).  Similarly, within the second example equations of each type are included for each member of set commodities.

Notes:

These examples show us moving away from the data specification that we were employing in the GAMS the early GAMS examples in this chapter.  In particular rather than entering numbers in the model we are now entering data item names and associated set dependency.  This permits us to specify a model in a more generic fashion as will be discussed in a later section of this tutorial on virtues of algebraic modeling.
The only variables that will be defined for a model are those that appear with nonzero coefficient somewhere in at least one of the equations defined by the .. equations.
More on .. specifications appears within the Variables, Equations, Models and Solves chapter.