manpagez: man pages & more
info gmpl
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 Constraint statement

subject to name alias domain : expression , = expression ;

subject to name alias domain : expression , <= expression ;

subject to name alias domain : expression , >= expression ;

subject to name alias domain : expression , <= expression , <= expression ;

subject to name alias domain : expression , >= expression , >= expression ;

Where:

name is the symbolic name of the constraint;

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

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

expressions are linear expressions for computing components of the constraint. (Commae following expressions may be omitted.)

Note:

The keyword subject to may be reduced to subj to, or to s.t., or be omitted at all.

Examples

 
s.t. r: x + y + z, >= 0, <= 1;
limit{t in 1..T}: sum{j in prd} make[j,t] <= max_prd;
subject to balance{i in raw, t in 1..T}:
   store[i,t+1] - store[i,t] - sum{j in prd} units[i,j] * make[j,t];
subject to rlim 'regular-time limit' {t in time}:
   sum{p in prd} pt[p] * rprd[p,t] <= 1.3 * dpp[t] * crews[t];

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

Elemental constraint(s) associated with the model constraint (if it is a simple constraint) or its members (if it is an array) correspond to the linear constraints in the LP/MIP problem formulation (see Section “Linear programming problem”).

If the constraint has the form of equality or single inequality, i.e. includes two expressions, one of which follows the colon and other follows the relation sign =, <=, or >=, both expressions in the statement can be linear expressions. If the constraint has the form of double inequality, i.e. includes three expressions, the middle expression can be a linear expression while the leftmost and rightmost ones can be only numeric expressions.

Generating the model is, generally speaking, generating its constraints, which are always evaluated for the entire subscript domain. Evaluating constraints leads, in turn, to evaluating other model objects such as sets, parameters, and variables.

Constructing the actual linear constraint included in the problem instantce, which (constraint) corresponds to a particular elemental constraint, is performed as follows.

If the constraint has the form of equality or single inequality, evaluation of both linear expressions gives two resultant linear forms:

f = a1 x1 + a2 x2 + … + an xn + a0,

g = b1 x1 + b2 x2 + … + bn xn + b0,

where x1, x2, …, xn are elemental variables, a1, a2, …, an, b1, b2, …, bn are numeric coefficients, a0 and b0 are constant terms. Then all linear terms of f and g are carried to the left-hand side, and the constant terms are carried to the right-hand side that gives the final elemental constraint in the standard form:

(a1 - b1) x1 + (a2 - b2) x2 + … + (an - bn) xn {= | <= | =>} b0 - a0

If the constraint has the form of double inequality, evaluation of the middle linear expression gives the resultant linear form:

f = a1 x1 + a2 x2 + … + an xn + a0,

and evaluation of the leftmost and rightmost numeric expressions gives two numeric values l and u. Then the constant term of the linear form is carried to both left-hand and right-hand sides that gives the final elemental constraint in the standard form:

l - a0 <= a1 x1 + a2 x2 + … + an xn <= u - a0.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.