NONLINPROG Function
Solves a general nonlinear programming problem using the successive quadratic programming (QP) algorithm.
Usage
result = NONLINPROG(f, m, n)
Input Parameters
f—Scalar string specifying a user-supplied procedure to evaluate the function at a given point. Procedure f  has the following parameters:
*m—Total number of constraints.
*meq—Number of equality constraints.
*x—One-dimensional array at which point the function is evaluated.
*active—One-dimensional array with mmax components indicating the active constraints where mmax is the maximum of (1, m).
*f—Computed function value at the point x. (Output)
*g—One-dimensional array with mmax components containing values of constraints at point x, where mmax is the maximum (1, m). (Output)
m—Total number of constraints.
n—Number of variables.
Returned Value
result—The solution of the nonlinear programming problem.
Input Keywords
Double—If present and nonzero, double precision is used.
Meq—Number of equality constraints. Default: Meq = m
Ibtype—Scalar indicating the types of bounds on variables.
*0User supplies all the bounds.
*1All variables are nonnegative.
*2All variables are nonpositive.
*3User supplies only the bounds on first variable; all other variables have the same bounds.
*Default: no bounds are enforced
XGuess—Array with n components containing an initial guess of the computed solution. Default: XGuess (*) = 0
Grad—Scalar string specifying a user-supplied procedure to evaluate the gradients at a given point. The procedure specified by Grad has the following parameters:
*mmax—Maximum of (1, m).
*m—Total number of constraints.
*meq—Number of equality constraints.
*x—Array at which point the function is evaluated.
*active—Array with mmax components indicating active constraints.
*f—Computed function value at the point x.
*g—Array with mmax components containing the values of the constraints at point x.
*df—Array with n components containing the values of the gradient of the objective function. (Output)
*dg—Array of size n × mmax containing the values of the gradients for the active constraints. (Output)
Err_Rel—Final accuracy. Default: Err_Rel = SQRT(ε), where ε is the machine precision
XScale—Array with n components containing the reciprocal magnitude of each variable. Keyword XScale is used to choose the finite-difference stepsize, h.
The ith component of h is computed as:
where ε is the machine precision, s = XScale, and sign(xi) = 1 if xi 0; otherwise, sign(xi) = –1. Default: XScale (*) = 1
Itmax—Maximum number of iterations allowed. Default: Itmax = 200
Output Keywords
Obj—Name of a variable into which a scalar containing the value of the objective function at the computed solution is stored.
Input/Output Keywords
Xlb—Named variable, containing a one-dimensional array with n components, containing the lower bounds on the variables. (Input, if Ibtype = 0; Output, if Ibtype = 1 or 2; Input/Output, if Ibtype = 3). If there is no lower bound on a variable, the corresponding Xlb value should be set to –106. Default: no lower bounds are enforced on the variables
Xub—Named variable, containing a one-dimensional array with n components, containing the upper bounds on the variables. (Input, if Ibtype = 0; Output, if Ibtype = 1 or 2; Input/Output, if Ibtype = 3). If there is no upper bound on a variable, the corresponding Xub value should be set to 106. Default: no upper bounds are enforced on the variables
Discussion
Function NONLINPROG, based on the subroutine NLPQL developed by Schittkowski (1986), uses a successive quadratic programming method to solve the general nonlinear programming problem.
The problem is stated as follows:
subject to:
,
,  
where all problem functions are assumed to be continuously differentiable. The method, based on the iterative formulation and solution of quadratic programming (QP) subproblems, obtains these subproblems by using a quadratic approximation of the Lagrangian and by linearizing the constraints. That is:
subject to:
,  
,  
where Bk is a positive definite approximation of the Hessian and xk is the current iterate. Let dk be the solution of the subproblem. A line search is used to find a new point xk + 1:
xk + 1 = xk + λdk          
such that a “merit function” has a lower function value at the new point. Here, the augmented Lagrange function (Schittkowski 1986) is used as the merit function.
When optimality is not achieved, Bk is updated according to the modified BFGS formula (Powell 1978). Note that this algorithm may generate infeasible points during the solution process. Therefore, if feasibility must be maintained for intermediate points, this function may not be suitable. For more theoretical and practical details, see Stoer (1985), Schittkowski (1983, 1986), and Gill et al. (1985).
Example
The problem:
min F(x) = (x1 – 2)2 + (x2 – 1)2
subject to:
g1(x) = x1 – 2x2 + 1 = 0
g2(x) = –x21/4 – x22 + 1 0
is solved.
.RUN
; Define the procedure to evaluate the function at a given point.
PRO nlpex, m, meq, x, active, f, g
   tmp1 = x(0) - 2.
   tmp2 = x(1) - 1.
   f = tmp1^2 + tmp2^2
   g = FLTARR(2)
   IF active(0) THEN g(0) = x(0) - 2. * x(1) + 1.
   IF active(1) THEN g(1) = -(x(0)^2)/4. - x(1)^2 + 1.
END
; Call NONLINPROG to compute the solution.
x = NONLINPROG('nlpex', 2, 2, Meq = 1)
PM, x, Title = 'Solution:' ; PV-WAVE prints the following:
; Solution:
;      0.822902
;      0.911452
Warning Errors
MATH_TOO_MANY_ITN—Maximum number of iterations exceeded.
Fatal Errors
MATH_UPHILL_DIRECTION—Search direction is uphill.
MATH_TOO_MANY_LINESEARCH—Line search took more than five function calls.
MATH_NO_PROGRESS_MADE—Search direction is close to zero.
MATH_QP_INCONSISTENT—Constraints for the QP subproblem are inconsistent.