- CONSTRAINT constraint [, ...constraint];
- CON constraint [, ...constraint];
The constraint declaration
defines one or more constraints on
expressions in terms of the optimization variables. You can specify
multiple constraint declaration statements.
Constraints can have an upper bound, a lower bound, or both bounds. The
allowed forms are as follows:
- [ name [ { index-set } ]
: ] expression = expression
-
declares an equality constraint or, when an index-set is
specified, a family of equality constraints. The solver attempts to
assign values to the optimization variables to make the two
expressions equal.
- [ name [ { index-set } ]
: ] expression relation expression
-
declares an inequality constraint that has a single upper or lower
bound. When an index-set is specified, this declares a family
of inequality constraints. Relation is the <= or >= operator.
The solver tries to assign optimization variable values so that the left
expression has a value less than or equal to (respectively, greater
than or equal to) the right expression value.
- [ name [ { index-set } ]
: ] bound relation body relation bound
-
declares an inequality constraint that is bounded on both sides, or range constraint.
When an index-set is specified, this declares a family of
range constraints. Relation is the <= or >= operator.
The same operator must be used in both positions. The first
bound expression defines the lower bound (respectively, upper
bound). The second bound expression defines the upper bound
(respectively, lower bound). The solver tries to assign optimization
variables so that the value of the body expression is in the
range between the upper and lower bounds.
Name defines the name for the constraint. Use the name to
reference constraint attributes, such as the bounds, elsewhere in the
PROC OPTMODEL model. If no name is provided, then a default name is
created of the form _ACON_[], where is an
integer. See the section "Constraints" for more information.
Here is a simple example that defines a constraint with a lower bound:
proc optmodel;
var x, y;
number low;
con a: x+y >= low;
The following example adds an upper bound:
var x, y;
number low;
con a: low <= x+y <= low+10;
Indexed families of constraints can be defined by specifying an
index-set after the name. Any dummy
parameters that are declared in the index-set can be
referenced in the expressions that define the constraint. A
particular member of a indexed family can be specified using an
identifier-expression with a bracketed index list,
in the same fashion as array parameters and variables. For example,
the following code creates an indexed family of constraints named incr:
proc optmodel;
number n;
var x{1..n}
/* require nondecreasing x values */
con incr{i in 1..n-1}: x[i+1] >= x[i];
The CON statement in the example creates constraints
incr[1] through incr[1].
Constraint expressions cannot be defined using functions that return
different values each time they are called. See the section "Indexing" for details.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.