e05uc is designed to find the global minimum of an arbitrary smooth function subject to constraints (which may include simple bounds on the variables, linear constraints and smooth nonlinear constraints) by generating a number of different starting points and performing a local search from each using sequential quadratic programming.

Syntax

C#
public static void e05uc(
	int n,
	int nclin,
	int ncnln,
	double[,] a,
	double[] bl,
	double[] bu,
	E05..::..E05UC_CONFUN confun,
	E05..::..E05UC_OBJFUN objfun,
	int npts,
	double[,] x,
	E05..::..E05UC_START start,
	bool repeat,
	int nb,
	double[] objf,
	double[,] objgrd,
	int[] iter,
	double[,] c,
	double[,,] cjac,
	int sdcjac,
	double[,,] r,
	int sdr,
	double[,] clamda,
	int[,] istate,
	E05..::..e05ucOptions options,
	int[] info,
	out int ifail
)
Visual Basic
Public Shared Sub e05uc ( _
	n As Integer, _
	nclin As Integer, _
	ncnln As Integer, _
	a As Double(,), _
	bl As Double(), _
	bu As Double(), _
	confun As E05..::..E05UC_CONFUN, _
	objfun As E05..::..E05UC_OBJFUN, _
	npts As Integer, _
	x As Double(,), _
	start As E05..::..E05UC_START, _
	repeat As Boolean, _
	nb As Integer, _
	objf As Double(), _
	objgrd As Double(,), _
	iter As Integer(), _
	c As Double(,), _
	cjac As Double(,,), _
	sdcjac As Integer, _
	r As Double(,,), _
	sdr As Integer, _
	clamda As Double(,), _
	istate As Integer(,), _
	options As E05..::..e05ucOptions, _
	info As Integer(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void e05uc(
	int n, 
	int nclin, 
	int ncnln, 
	array<double,2>^ a, 
	array<double>^ bl, 
	array<double>^ bu, 
	E05..::..E05UC_CONFUN^ confun, 
	E05..::..E05UC_OBJFUN^ objfun, 
	int npts, 
	array<double,2>^ x, 
	E05..::..E05UC_START^ start, 
	bool repeat, 
	int nb, 
	array<double>^ objf, 
	array<double,2>^ objgrd, 
	array<int>^ iter, 
	array<double,2>^ c, 
	array<double,3>^ cjac, 
	int sdcjac, 
	array<double,3>^ r, 
	int sdr, 
	array<double,2>^ clamda, 
	array<int,2>^ istate, 
	E05..::..e05ucOptions^ options, 
	array<int>^ info, 
	[OutAttribute] int% ifail
)
F#
static member e05uc : 
        n : int * 
        nclin : int * 
        ncnln : int * 
        a : float[,] * 
        bl : float[] * 
        bu : float[] * 
        confun : E05..::..E05UC_CONFUN * 
        objfun : E05..::..E05UC_OBJFUN * 
        npts : int * 
        x : float[,] * 
        start : E05..::..E05UC_START * 
        repeat : bool * 
        nb : int * 
        objf : float[] * 
        objgrd : float[,] * 
        iter : int[] * 
        c : float[,] * 
        cjac : float[,,] * 
        sdcjac : int * 
        r : float[,,] * 
        sdr : int * 
        clamda : float[,] * 
        istate : int[,] * 
        options : E05..::..e05ucOptions * 
        info : int[] * 
        ifail : int byref -> unit 

Parameters

n
Type: System..::..Int32
On entry: n, the number of variables.
Constraint: n>0.
nclin
Type: System..::..Int32
On entry: nL, the number of general linear constraints.
Constraint: nclin0.
ncnln
Type: System..::..Int32
On entry: nN, the number of nonlinear constraints.
Constraint: ncnln0.
a
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, dim2]
Note: dim1 must satisfy the constraint: dim1nclin
Note: the second dimension of the array a must be at least n if nclin>0, and at least 1 otherwise.
On entry: the matrix AL of general linear constraints in (1). That is, the ith row contains the coefficients of the ith general linear constraint, for i=1,2,,nclin.
If nclin=0, the array a is not referenced.
bl
Type: array<System..::..Double>[]()[][]
An array of size [n+nclin+ncnln]
On entry: bl must contain the lower bounds and bu the upper bounds for all the constraints in the following order. The first n elements of each array must contain the bounds on the variables, the next nL elements the bounds for the general linear constraints (if any) and the next nN elements the bounds for the general nonlinear constraints (if any). To specify a nonexistent lower bound (i.e., lj=-), set bl[j-1]-bigbnd, and to specify a nonexistent upper bound (i.e., uj=+), set bu[j-1]bigbnd; the default value of bigbnd is 1020, but this may be changed by the optional parameter Infinite Bound Size. To specify the jth constraint as an equality, set bl[j-1]=bu[j-1]=β, say, where β<bigbnd.
Constraints:
  • bl[j-1]bu[j-1], for j=1,2,,n+nclin+ncnln;
  • if bl[j-1]=bu[j-1]=β, β<bigbnd.
bu
Type: array<System..::..Double>[]()[][]
An array of size [n+nclin+ncnln]
On entry: bl must contain the lower bounds and bu the upper bounds for all the constraints in the following order. The first n elements of each array must contain the bounds on the variables, the next nL elements the bounds for the general linear constraints (if any) and the next nN elements the bounds for the general nonlinear constraints (if any). To specify a nonexistent lower bound (i.e., lj=-), set bl[j-1]-bigbnd, and to specify a nonexistent upper bound (i.e., uj=+), set bu[j-1]bigbnd; the default value of bigbnd is 1020, but this may be changed by the optional parameter Infinite Bound Size. To specify the jth constraint as an equality, set bl[j-1]=bu[j-1]=β, say, where β<bigbnd.
Constraints:
  • bl[j-1]bu[j-1], for j=1,2,,n+nclin+ncnln;
  • if bl[j-1]=bu[j-1]=β, β<bigbnd.
confun
Type: NagLibrary..::..E05..::..E05UC_CONFUN
confun must calculate the vector cx of nonlinear constraint functions and (optionally) its Jacobian (=cx) for a specified n-element vector x. If there are no nonlinear constraints (i.e., ncnln=0), confun will never be called by e05uc and confun may be the dummy method E04UDM. (E04UDM is included in the NAG Library.) If there are nonlinear constraints, the first call to confun will occur before the first call to objfun.

A delegate of type E05UC_CONFUN.

confun should be tested separately before being used in conjunction with e05uc. See also the description of the optional parameter Verify.
objfun
Type: NagLibrary..::..E05..::..E05UC_OBJFUN
objfun must calculate the objective function Fx and (optionally) its gradient gx=Fx for a specified n-vector x.

A delegate of type E05UC_OBJFUN.

objfun should be tested separately before being used in conjunction with e05uc. See also the description of the optional parameter Verify.
npts
Type: System..::..Int32
On entry: the number of different starting points to be generated and used. The more points used, the more likely that the best returned solution will be a global minimum.
Constraint: 1nbnpts.
x
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, nb]
Note: dim1 must satisfy the constraint: dim1n
On exit: x[j-1,i-1] contains the final estimate of the ith solution, for j=1,2,,n.
start
Type: NagLibrary..::..E05..::..E05UC_START
start must calculate the npts starting points to be used by the local optimizer. If you do not wish to write a method specific to your problem then E05UCZ may be used as the actual argument. E05UCZ is supplied in the NAG Library and uses the NAG quasi-random number generators to distribute starting points uniformly across the domain. It is affected by the value of repeat.

A delegate of type E05UC_START.

repeat
Type: System..::..Boolean
On entry: is passed as an argument to start and may be used to initialize a random number generator to a repeatable, or non-repeatable, sequence.
nb
Type: System..::..Int32
On entry: the number of solutions to be returned. The method saves up to nb local minima ordered by increasing value of the final objective function. If the defining criterion for ‘best solution’ is only that the value of the objective function is as small as possible then nb should be set to 1. However, if you want to look at other solutions that may have desirable properties then setting nb>1 will produce nb local minima, ordered by increasing value of their objective functions at the minima.
Constraint: 1nbnpts.
objf
Type: array<System..::..Double>[]()[][]
An array of size [nb]
On exit: objf[i-1] contains the value of the objective function at the final iterate for the ith solution.
objgrd
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, nb]
Note: dim1 must satisfy the constraint: dim1n
On exit: objgrd[j-1,i-1] contains the gradient of the objective function for the ith solution at the final iterate (or its finite difference approximation), for j=1,2,,n.
iter
Type: array<System..::..Int32>[]()[][]
An array of size [nb]
On exit: iter[i-1] contains the number of major iterations performed to obtain the ith solution. If less than nb solutions are returned then iter[nb-1] contains the number of starting points that have resulted in a converged solution. If this is close to npts then this might be indicative that fewer than nb local minima exist.
c
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, nb]
Note: dim1 must satisfy the constraint: dim1ncnln
On exit: if ncnln>0, c[j-1,i-1] contains the value of the jth nonlinear constraint function cj at the final iterate, for the ith solution, for j=1,2,,ncnln.
If ncnln=0, the array c is not referenced.
cjac
Type: array<System..::..Double,3>[,](,)[,][,]
An array of size [dim1, sdcjac, nb]
Note: dim1 must satisfy the constraint: dim1ncnln
On exit: if ncnln>0, cjac contains the Jacobian matrices of the nonlinear constraint functions at the final iterate for each of the returned solutions, i.e., cjac[k-1,j-1,i-1] contains the partial derivative of the kth constraint function with respect to the jth variable, for k=1,2,,ncnln and j=1,2,,n, for the ith solution. (See the discussion of parameter cjsl under confun.)
If ncnln=0, the array cjac is not referenced.
sdcjac
Type: System..::..Int32
the second dimension of the array cjac.
On entry: the second dimension of the array cjac as declared in the (sub)program from which e05uc is called.
Constraint: if ncnln>0, sdcjacn.
r
Type: array<System..::..Double,3>[,](,)[,][,]
An array of size [dim1, sdr, nb]
Note: dim1 must satisfy the constraint: dim1n
On exit: for each of the nb solutions r will contain a form of the Hessian; for the ith returned solution r[ldr,sdr,i] contains the Hessian that would be returned from the local minimizer. If Hessian=NO, the default, each r[ldr,sdr,i] contains the upper triangular Cholesky factor R of QTHQ, an estimate of the transformed and reordered Hessian of the Lagrangian at x. If Hessian=YES, r[ldr,sdr,i] contains the upper triangular Cholesky factor R of H, the approximate (untransformed) Hessian of the Lagrangian, with the variables in the natural order.
sdr
Type: System..::..Int32
the second dimension of the array r.
On entry: the second dimension of the array r as declared in the (sub)program from which e05uc is called.
Constraint: sdrn.
clamda
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, nb]
Note: dim1 must satisfy the constraint: dim1n+nclin+ncnln
On exit: the values of the QP multipliers from the last QP subproblem solved for the ith solution. clamda[j-1,i-1] should be non-negative if istate[j-1,i-1]=1 and non-positive if istate[j-1,i-1]=2.
istate
Type: array<System..::..Int32,2>[,](,)[,][,]
An array of size [dim1, nb]
Note: dim1 must satisfy the constraint: dim1n+nclin+ncnln
On exit: istate[j-1,i-1] contains the status of the constraints in the QP working set for the ith solution. The significance of each possible value of istate[j-1,i-1] is as follows:
istate[j-1,i-1]Meaning
-0The constraint is satisfied to within the feasibility tolerance, but is not in the QP working set.
-1This inequality constraint is included in the QP working set at its lower bound.
-2This inequality constraint is included in the QP working set at its upper bound.
-3This constraint is included in the QP working set as an equality. This value of istate can occur only when bl[j-1]=bu[j-1].
options
Type: NagLibrary..::..E05..::..e05ucOptions
An Object of type E05.e05ucOptions. Used to configure optional parameters to this method.
info
Type: array<System..::..Int32>[]()[][]
An array of size [nb]
On exit: info[i-1] contains one of 0, 1 or 6. Please see the description of each corresponding value of ifail on exit from e04uc for detailed explanations of these exit values. As usual 0 denotes success.
If ifail=8 on exit, then not all nb solutions have been found, and info[nb-1] contains the number of solutions actually found.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

The problem is assumed to be stated in the following form:
minimizexRn​ ​Fx  subject to  lxALxcxu, (1)
where Fx (the objective function) is a nonlinear function, AL is an nL by n linear constraint matrix, and cx is an nN element vector of nonlinear constraint functions. (The matrix AL and the vector cx may be empty.) The objective function and the constraint functions are assumed to be smooth, i.e., at least twice-continuously differentiable. (This method will usually solve (1) if there are only isolated discontinuities away from the solution.)
e05uc solves a user-specified number of local optimization problems with different starting points. You may specify the starting points via the method start. If a random number generator is used to generate the starting points then the parameter repeat allows you to specify whether a repeatable set of points are generated or whether different starting points are generated on different calls. The resulting local minima are ordered and the best nb results returned in order of ascending values of the resulting objective function values at the minima. Thus the value returned in position 1 will be the best result obtained. If a sufficient number of different points are chosen then this is likely to be be the global minimum. Please note that the default version of start uses a random number generator to generate the starting points.

References

Dennis J E Jr and Moré J J (1977) Quasi-Newton methods, motivation and theory SIAM Rev. 19 46–89
Dennis J E Jr and Schnabel R B (1981) A new derivation of symmetric positive-definite secant updates nonlinear programming (eds O L Mangasarian, R R Meyer and S M Robinson) 4 167–199 Academic Press
Dennis J E Jr and Schnabel R B (1983) Numerical Methods for Unconstrained Optimization and Nonlinear Equations Prentice–Hall
Fletcher R (1987) Practical Methods of Optimization (2nd Edition) Wiley
Gill P E, Hammarling S, Murray W, Saunders M A and Wright M H (1986) Users' guide for LSSOL (Version 1.0) Report SOL 86-1 Department of Operations Research, Stanford University
Gill P E, Murray W, Saunders M A and Wright M H (1984) Users' guide for SOL/QPSOL version 3.2 Report SOL 84–5 Department of Operations Research, Stanford University
Gill P E, Murray W, Saunders M A and Wright M H (1986a) Some theoretical properties of an augmented Lagrangian merit function Report SOL 86–6R Department of Operations Research, Stanford University
Gill P E, Murray W, Saunders M A and Wright M H (1986b) Users' guide for NPSOL (Version 4.0): a Fortran package for nonlinear programming Report SOL 86-2 Department of Operations Research, Stanford University
Gill P E, Murray W and Wright M H (1981) Practical Optimization Academic Press
Powell M J D (1974) Introduction to constrained optimization Numerical Methods for Constrained Optimization (eds P E Gill and W Murray) 1–28 Academic Press
Powell M J D (1983) Variable metric methods in constrained optimization Mathematical Programming: the State of the Art (eds A Bachem, M Grötschel and B Korte) 288–311 Springer–Verlag

Error Indicators and Warnings

Note: e05uc may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDA, LDX, LDOBJD, LDC, LDCJAC, LDR, LDCLDA, LISTAT) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
An input value is incorrect. One, or more, of the following requirements are violated:
  • n1;
  • nclin0;
  • ncnln0;
  • ldanclin;
  • bl[i-1]bu[i-1] for some i;
  • ldxn;
  • 1nbnpts;
  • ldobjdn;
  • ldcncnln;
  • ldcjacncnln;
  • sdcjacn if ncnln>0
  • ldrn;
  • sdrn;
  • ldcldan+nclin+ncnln;
  • listatn+nclin+ncnln.
ifail=2
e05uc has terminated without finding any solutions. The majority of calls to the local optimizer have failed to find a feasible point for the linear constraints and bounds, which means that either no feasible point exists for the given value of the optional parameter Linear Feasibility Tolerance (default value ε, where ε is the machine precision), or no feasible point could be found in the number of iterations specified by the optional parameter Minor Iteration Limit. You should check that there are no constraint redundancies. If the data for the constraints are accurate only to an absolute precision σ, you should ensure that the value of the optional parameter Linear Feasibility Tolerance is greater than σ. For example, if all elements of AL are of order unity and are accurate to only three decimal places, Linear Feasibility Tolerance should be at least 10-3.
ifail=3
e05uc has failed to find any solutions. The majority of local optimizations could not find a feasible point for the nonlinear constraints. The problem may have no feasible solution. This behaviour will occur if there is no feasible point for the nonlinear constraints. (However, there is no general test that can determine whether a feasible point exists for a set of nonlinear constraints.)
ifail=4
e05uc has failed to find any solutions. The majority of local optimizations have failed because the limiting number of iterations have been reached. The Iteration Limit may be changed using (E05ZKF not in this release)
ifail=5
ifail=6
Not used by this method.
ifail=7
The user-supplied derivatives of the objective function and/or nonlinear constraints appear to be incorrect.
Large errors were found in the derivatives of the objective function and/or nonlinear constraints. This value of ifail will occur if the verification process indicated that at least one gradient or Jacobian element had no correct figures. You should refer to or enable the printed output to determine which elements are suspected to be in error.
As a first-step, you should check that the code for the objective and constraint values is correct – for example, by computing the function at a point where the correct value is known. However, care should be taken that the chosen point fully tests the evaluation of the function. It is remarkable how often the values x=0 or x=1 are used to test function evaluation procedures, and how often the special properties of these numbers make the test meaningless.
Special care should be used in this test if computation of the objective function involves subsidiary data communicated in storage, including iuser and ruser in a multithreaded environment. Although the first evaluation of the function may be correct, subsequent calculations may be in error because some of the subsidiary data has accidentally been overwritten.
Gradient checking will be ineffective if the objective function uses information computed by the constraints, since they are not necessarily computed before each function evaluation.
Errors in programming the function may be quite subtle in that the function value is almost correct. For example, the function may not be accurate to full precision because of the inaccurate calculation of a subsidiary quantity, or the limited accuracy of data upon which the function depends. A common error on machines where numerical calculations are usually performed in double precision is to include even one single precision constant in the calculation of the function; since some compilers do not convert such constants to double precision, half the correct figures may be lost by such a seemingly trivial error.
ifail=8
Not all nb solutions have been found. info[nb-1] contains the number actually found.
ifail=9
You terminated the computation by setting mode<0 in start.
If E05UCZ has been used as the actual argument for start then the message displayed, when ifail=0 or -1 on entry to e05uc, will have the following meaning:
-998 – failure to allocate space, a smaller value of npts should be tried;
-997 – an internal error has occurred. Please contact NAG for assistance.
ifail=10
Failed to initialize optional parameter arrays.
ifail=-9000
An error occured, see message report.
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

If ifail=0 on exit and the value of info[i-1]=0, then the vector returned in the array x for solution i is an estimate of the solution to an accuracy of approximately Optimality Tolerance.

Parallelism and Performance

None.

Further Comments

You should be wary of requesting much intermediate output from the local optimizer, since large volumes may be produced if npts is large.
The auxiliary routine E05UCZ makes use of the NAG quasi-random Sobol generator (g05yl and g05ym). If E05UCZ is used as an argument for start (see the description of start) and repeat=false then a randomly chosen value for iskip is used, otherwise iskip is set to 100. If repeat is set to false and the program is executed several times, each time producing the same best answer, then there is increased probability that this answer is a global minimum. However, if it is important that identical results be obtained on successive runs, then repeat should be set to true.

Description of the Printed Output

Example

This example finds the global minimum of the two-dimensional Schwefel function:
minimizexR2f=j=12xjsinxj
subject to the constraints:
-10000<3.0x1-2.0x2<10.0,-1.0<x12-x22+3.0x1x2<500000.0,-0.9<cosx1/2002+x2/100<0.9,-500x1500,-500x2500.

Example program (C#): e05uce.cs

Example program data: e05uce.d

Example program results: e05uce.r

Algorithmic Details

Description of Monitoring Information

See Also