Next: , Previous: , Up: Statements   [Contents]

### 4.2 Parameter statement

 param name alias domain , attrib , $\dots$ , attrib ;
Where:

name is the symbolic name of the parameter;

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

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

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

Optional attributes:

integer

specifies that the parameter is integer;

binary

specifies that the parameter is binary;

symbolic

specifies that the parameter is symbolic;

relation expression

(where relation is one of: < <= = == >= > <> !=)
specifies a condition that restricts the parameter or its members to satisfy this condition;

in expression

specifies a superset that restricts the parameter or its members to be in this superset;

:= expression

specifies a value assigned to the parameter or its members;

default expression

specifies a value assigned to the parameter or its members whenever no appropriate data are available in the data section.

Examples

param units{raw, prd} >= 0;
param profit{prd, 1..T+1};
param N := 20, integer, >= 0, <= 100;
param comb 'n choose k' {n in 0..N, k in 0..n} :=
if k = 0 or k = n then 1 else comb[n-1,k-1] + comb[n-1,k];
param p{i in I, j in J}, integer, >= 0, <= i+j, in A[i] symdiff B[j],
in C[i,j], default 0.5 * (i + j);
param month symbolic default 'May' in {'Mar', 'Apr', 'May'};


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

The type attributes integer, binary, and symbolic qualify the type values which can be assigned to the parameter as shown below:

 Type attribute Assigned values not specified Any numeric values integer Only integer numeric values binary Either 0 or 1 symbolic Any numeric and symbolic values

The symbolic attribute cannot be specified along with other type attributes. Being specified it must precede all other attributes.

The condition attribute specifies an optional condition that restricts values assigned to the parameter to satisfy this condition. This attribute has the following syntactic forms:

 < v Check for x < v <= v Check for $x\leq v$ = v, == v Check for x = v >= v Check for $x\geq v$ > v Check for x > v <> v, != v Check for $x\neq v$

where x is a value assigned to the parameter, v is the resultant value of a numeric or symbolic expression specified in the condition attribute. Arbitrary number of condition attributes can be specified for the same parameter. If a value being assigned to the parameter during model evaluation violates at least one specified condition, an error is raised. (Note that symbolic values are ordered lexicographically, and any numeric value precedes any symbolic value.)

The in attribute is similar to the condition attribute and specifies a set expression whose resultant value is a superset used to restrict numeric or symbolic values assigned to the parameter to be in this superset. Arbitrary number of the in attributes can be specified for the same parameter. If a value being assigned to the parameter during model evaluation is not in at least one specified superset, an error is raised.

The assign (:=) attribute specifies a numeric or symbolic expression used to compute a value assigned to the parameter (if it is a simple parameter) or its member (if the parameter is an array). If the assign attribute is specified, the parameter is computable and therefore needs no data to be provided in the data section. If the assign attribute is not specified, the parameter must be provided with data in the data section. At most one assign or default attribute can be specified for the same parameter.

The default attribute specifies a numeric or symbolic expression used to compute a value assigned to the parameter or its member whenever no appropriate data are available in the data section. If neither assign nor default attribute is specified, missing data will cause an error.

Next: , Previous: , Up: Statements   [Contents]