# Constrained minimization

Consider the general nonlinear programming problem

minimize

subject to

In this section, we provide the framework for the general nonlinear programming problem. We also examine the construction of linear, nonlinear and compound constraints.

If 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 have all the necessary tools to build a nonlinear programming problem.

## Creating a general nonlinear programming problem

Let's consider Problem 65 from the Hock and Schittkowski suite of test problems:

minimize

subject to

Step 1: Build your constraints. The constraint set consists of bounds on the variables plus one nonlinear inequality.

```   // Number of bounds and number of nonlinear constraints
int numBds = 3, ncnln = 1;

ColumnVector lower(numBds), upper(numBds);

// Construct the nonlinear equation
NLP* chs65      = new NLP( new NLF2(numBds,ncnln,ineq_hs65,init_hs65) );
Constraint ineq = new NonLinearInequality(chs65);

// Construct the bound constraints
lower << -4.5 << -4.5 << -5.0;
upper <<  4.5 <<  4.5 <<  5.0 ;
Constraint bc   = new BoundConstraint(n,lower,upper);

// Construct the compound constraint
CompoundConstraint* constraints = new CompoundConstraint(ineq,bc);
```

Step 2: Create a constrained problem where the objective function has analytic Hessians.

```   NLF2 hs65_problem(n,hs65,init_hs65,constraints);
```

## Specifying the optimization method

In OPT++, the only freely available method to solve a general nonlinear problem is OptNIPS, a nonlinear interior-point method. However, we do provide an wrapper to NPSOL, a sequential quadratic programming algorithm. For more information, go to the <a href ="http://www.sbsi-sol-optimize.com/NPSOL.htm>NPSOL website.

Last revised July 13, 2006