Constructing nonlinear constraints

In this section, you will learn about

Declaring Nonlinear Constraint Functions

Like the objective function, the nonlinear constraint functions are classified according to the availability of the derivatives. However, the argument list of the constructors for the two objects differ in the storage types for the function's value, gradient, and Hessian. Now, we turn our focus to the construction of nonlinear equations.

Creating Nonlinear Equations

The nonlinear equation is written as

\[ h(x) = 0. \]

There are two NonLinearEquation constructors. The first constructor requires two parameters, a pointer to an NLP object and an integer argument for the number of nonlinear equations, which defaults to one. The right-hand side is set to zero. For example,

   NonLinearEquation(NLP* nlprob, int numconstraints = 1);

The second constructor

   NonLinearEquation(NLP* nlprob, const ColumnVector& rhs, 
                    int numconstraints = 1);
permits a nonzero value for the right-hand side.

The following code fragment creates

\[ h_j(x) = j, \forall j=1,2,3. \]

   //  Number of nonlinear equations 
   int ncnln    = 3;
   ColumnVector b(ncnln);
   
   //  Create a pointer to an NLP object 
   NLP* nlprob  = new NLP( new NLF1(n, ncnln, nleqn, init_nleqn) );

   //  Initialize the right-hand side of the equations 
   b << 1.0 << 2.0 << 3.0;

   //  Create a set of nonlinear equations 
   NonLinearEquation(nlprob, b, ncnln);

Creating Nonlinear Inequalities

In OPT++, the standard form for a nonlinear inequality is

\[ g(x) \ge 0. \]

The corresponding constructor is

   NonLinearInequality(NLP* nlprob, int numconstraints = 1);

To define a nonzero right-hand side for the inequalities, use the following constructor:

   NonLinearInequality(NLP* nlprob, const ColumnVector& rhs, 
                       int numconstraints = 1);

If the user wants nonzero upper bounds on the constraints, such as

\[ g(x) \le b, \]

then they must use the following constructor:

   NonLinearInequality(NLP* nlprob, const ColumnVector& rhs, 
                       const bool flag, int numconstraints = 1);

To create lower and upper bounds for the constraints, use

   NonLinearInequality(NLP* nlprob, const ColumnVector& lower, 
                       const ColumnVector& upper, int numconstraints = 1);
which generates

\[l \le g(x) \le u. \]

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

\[l_i \le -1.0e10. \]

Similarly, an infinite upper bound is specified by

\[u_i \ge 1.0e10. \]

Next Section: Constructing a compound constraint | Back to Main Page

Last revised July 13, 2006


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