4.3 Variable statement

var name alias domain , attrib , $\dots$ , attrib ;

Where:

name is the symbolic name of the variable;

alias is an optional string literal which specifies the alias of the variable;

domain is an optional indexing expression which specifies the subscript domain of the variable;

attrib, $\dots$, attrib are optional attributes of the variable. (Commae preceding attributes may be omitted.)

Optional attributes:

integer

restricts the variable to be integer;

binary

restricts the variable to be binary;

>= expression

specifies an lower bound of the variable;

<= expression

specifies an upper bound of the variable;

= expression, == expression

specifies a fixed value of the variable;

Examples

var x >= 0;
var y{I,J};
var make{p in prd}, integer, >= commit[p], <= market[p];
var store{raw, 1..T+1} >= 0;
var z{i in I, j in J} >= i+j;

The variable statement declares a variable. If the subscript domain is not specified, the variable is a simple (scalar) variable, otherwise it is a n-dimensional array of elemental variables.

Elemental variable(s) associated with the model variable (if it is a simple variable) or its members (if it is an array) correspond to the variables in the LP/MIP problem formulation (see Section “Linear programming problem”). Note that only the elemental variables actually referenced in some constraints and/or objectives are included in the LP/MIP problem instance to be generated.

The type attributes integer and binary restrict the variable to be integer or binary, respectively. If no type attribute is specified, the variable is continuous. If all variables in the model are continuous, the corresponding problem is of LP class. If there is at least one integer or binary variable, the problem is of MIP class.

The lower bound (>=) attribute specifies a numeric expression for computing the lower bound of the variable. At most one lower bound can be specified. By default all variables (except binary ones) have no lower bounds, so if a variable is required to be non-negative, its zero lower bound should be explicitly specified.

The upper bound (<=) attribute specifies a numeric expression for computing the upper bound of the variable. At most one upper bound attribute can be specified.

The fixed value (=) attribute specifies a numeric expression for computing the value, at which the variable is fixed. This attribute cannot be specified along with lower/upper bound attributes.