How to create constrained objects

a constraint has finite lower and upper bounds, OPT++ treats it as two separate constraints. In the computation of the residuals and gradients constraints with finite lower bounds appear first followed by those with finte upper bounds. Consequently, in the optimization summary, you will see the constraint count is double the original number of constraints.

Now, we are ready to build an constrained nonlinear program.

Let's consider the two-dimensional Rosenbrock problem with bound constraints.

minimize

\[100(x_2 - x_{1}^2)^2 + (1 - x_1)^2 \]

subject to

\[ -2.0 \le x \le 2.0\]

Step 1: Build your compound constraint.

   int ndim =  2;
   ColumnVector lower(ndim), upper(ndim);
   lower    = -2.0;
   upper    =  2.0;

   Constraint bc = new BoundConstraint(ndim, lower, upper);
   CompoundConstraint* rosen_constraints = new CompoundConstraint(bc);

Step 2: Create a nonlinear function with analytic derivatives.

Step 3: Create a constrained nonlinear problem with analytic derivatives

   NLF1 nips(n,rosen,init_rosen,rosen_constraints);

Voila! You're done.

Next Section: Examples of test fragments | Back to Main Page


Bug Reports    OPT++ Developers    Copyright Information    GNU Lesser General Public License
Documentation, generated by , last revised August 30, 2006.