Variables

Top  Previous  Next

GAMS requires an identification of the variables in a problem.  This is accomplished through a VARIABLES command as reproduced below for each of the three problems.

 

VARIABLES              Z;                (optimize.gms)

NonNegative Variables  Xcorn ,Xwheat,Xcotton;

 

POSITIVE VARIABLES     P, Qd , Qs;                (econequil.gms)

 

Variables              ba, so4, baoh, oh, hso4, h ;(nonlinsys.gms)

 

The POSITIVE and Nonnegative modifiers on the variable definitions means that these variables listed thereafter are nonnegative i.e.  Xcorn , Xwheat , Xcotton, P, Qd, Qs.

The use of the word VARIABLES without the POSITIVE modifier (note several other modifiers are possible as discussed in the Variables, Equations, Models and Solvers chapter) means that the named variables are unrestricted in sign as Z, ba, so4, baoh, oh, hso4, and h are above.

Notes:

The general form of these statements is

         modifier variables comma or line feed specified list of variables ;

 where

         modifier is optional (positive for example)

         variable or variables is required

         a list of variables follows

         a ; ends the statement

 

This statement may be more complex including set element definitions (as we will elaborate on below) and descriptive text as illustrated in the file (model.gms)

Variables

  Tcost' Total Cost Of Shipping- All Routes';

Binary Variables

  Build(Warehouse)Warehouse Construction Variables;

Positive Variables

  Shipsw(Supplyl,Warehouse)Shipment to warehouse
  Shipwm(Warehouse,Market)Shipment from Warehouse
  Shipsm(Supplyl,Market)Direct ship to Demand;

Semicont Variables

  X,y,z;

 

as discussed in the Variables, Equations, Models and Solves chapter.

The variable names can be up to 63 characters long as discussed and illustrated in the Rules for Item Names, Element names and Explanatory Text chapter.
GAMS is not case sensitive, thus it is equivalent to type the command VARIABLE as variable or the variable names XCOTTON as XcOttoN.  However, there is case sensitivity with respect to the way things are printed out with the first presentation being the one used as discussed in the Rules for Item Capitalization and Ordering chapter.
GAMS does not care about spacing or multiple lines.  Also a line feed can be used instead of a comma.  Thus, the following three command versions are all the same

POSITIVE VARIABLES

Xcorn ,Xwheat,Xcotton;

Positive Variables

Xcorn,

Xwheat,

Xcotton;

positive variables

Xcorn

Xwheat   ,    Xcotton;