However, the user has the option of creating constraints with upper bounds or constraints with lower and upper bounds. The BoundConstraint class contains four constructors.

The first constructor creates a bound constraint in standard form. For example,

BoundConstraint(int nc, const ColumnVector& lower);

To define upper bounds on the variables, such as

use the following constructor:

BoundConstraint(int nc, const ColumnVector& bound, const BoolVector& bdFlag);

Sample code to create

appears below.

bool bdFlag; int numOfCons = 5; ColumnVector bound(numOfCons); bound << 1.0 << 2.0 << 3.0 << 4.0 << 5.0; bdFlag = false; BoundConstraint bc(numOfCons, bound, bdFlag);

To define lower and upper bounds on the variables, use

BoundConstraint(int nc, const ColumnVector& lower, const ColumnVector& upper)

By default, the first ColumnVector contains the lower bounds and the second ColumnVector the upper bounds on the constraints.

OPT++ does not support sparse constraints. Therefore, a bound must be given for each variable even if only a subset of the variables have finite bounds. An infinite lower bound is specified by

Similarly, an infinite upper bound is specified by

Next Section: Constructing linear constraints | Back to Main Page

Last revised * July 13, 2006*