e04jc is an easy-to-use algorithm that uses methods of quadratic approximation to find a minimum of an objective function F over xRn, subject to fixed lower and upper bounds on the independent variables x1,x2,,xn. Derivatives of F are not required.
The method is intended for functions that are continuous and that have continuous first and second derivatives (although it will usually work even if the derivatives have occasional discontinuities). Efficiency is maintained for large n.

Syntax

C#
public static void e04jc(
	E04..::..E04JC_OBJFUN objfun,
	int n,
	int npt,
	double[] x,
	double[] bl,
	double[] bu,
	double rhobeg,
	double rhoend,
	E04..::..E04JC_MONFUN monfun,
	int maxcal,
	out double f,
	out int nf,
	out int ifail
)
Visual Basic
Public Shared Sub e04jc ( _
	objfun As E04..::..E04JC_OBJFUN, _
	n As Integer, _
	npt As Integer, _
	x As Double(), _
	bl As Double(), _
	bu As Double(), _
	rhobeg As Double, _
	rhoend As Double, _
	monfun As E04..::..E04JC_MONFUN, _
	maxcal As Integer, _
	<OutAttribute> ByRef f As Double, _
	<OutAttribute> ByRef nf As Integer, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void e04jc(
	E04..::..E04JC_OBJFUN^ objfun, 
	int n, 
	int npt, 
	array<double>^ x, 
	array<double>^ bl, 
	array<double>^ bu, 
	double rhobeg, 
	double rhoend, 
	E04..::..E04JC_MONFUN^ monfun, 
	int maxcal, 
	[OutAttribute] double% f, 
	[OutAttribute] int% nf, 
	[OutAttribute] int% ifail
)
F#
static member e04jc : 
        objfun : E04..::..E04JC_OBJFUN * 
        n : int * 
        npt : int * 
        x : float[] * 
        bl : float[] * 
        bu : float[] * 
        rhobeg : float * 
        rhoend : float * 
        monfun : E04..::..E04JC_MONFUN * 
        maxcal : int * 
        f : float byref * 
        nf : int byref * 
        ifail : int byref -> unit 

Parameters

objfun
Type: NagLibrary..::..E04..::..E04JC_OBJFUN
objfun must evaluate the objective function F at a specified vector x.

A delegate of type E04JC_OBJFUN.

n
Type: System..::..Int32
On entry: n, the number of independent variables.
Constraint: n2 and nr2, where nr denotes the number of non-fixed variables.
npt
Type: System..::..Int32
On entry: m, the number of interpolation conditions imposed on the quadratic approximation at each iteration.
Suggested value: npt=2×nr+1, where nr denotes the number of non-fixed variables.
Constraint: nr+2nptnr+1×nr+22, where nr denotes the number of non-fixed variables.
x
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: an estimate of the position of the minimum. If any component is out-of-bounds it is replaced internally by the bound it violates.
On exit: the lowest point found during the calculations. Thus, if ifail=0 on exit, x is the position of the minimum.
bl
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: the fixed vectors of bounds: the lower bounds  and the upper bounds u, respectively. To signify that a variable is unbounded you should choose a large scalar r appropriate to your problem, then set the lower bound on that variable to -r and the upper bound to r. For well-scaled problems r=rmax14 may be suitable, where rmax denotes the largest positive model number (see x02al).
Constraints:
  • if x[i-1] is to be fixed at bl[i-1], then bl[i-1]=bu[i-1];
  • otherwise bu[i-1]-bl[i-1]2.0×rhobeg, for i=1,2,,n.
bu
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: the fixed vectors of bounds: the lower bounds  and the upper bounds u, respectively. To signify that a variable is unbounded you should choose a large scalar r appropriate to your problem, then set the lower bound on that variable to -r and the upper bound to r. For well-scaled problems r=rmax14 may be suitable, where rmax denotes the largest positive model number (see x02al).
Constraints:
  • if x[i-1] is to be fixed at bl[i-1], then bl[i-1]=bu[i-1];
  • otherwise bu[i-1]-bl[i-1]2.0×rhobeg, for i=1,2,,n.
rhobeg
Type: System..::..Double
On entry: an initial lower bound on the value of the trust-region radius.
Suggested value: rhobeg should be about one tenth of the greatest expected overall change to a variable: the initial quadratic model will be constructed by taking steps from the initial x of length rhobeg along each coordinate direction.
Constraints:
  • rhobeg>0.0;
  • rhobegrhoend.
rhoend
Type: System..::..Double
On entry: a final lower bound on the value of the trust-region radius.
Suggested value: rhoend should indicate the absolute accuracy that is required in the final values of the variables.
Constraint: rhoend>0.0.
monfun
Type: NagLibrary..::..E04..::..E04JC_MONFUN
monfun may be used to monitor the optimization process. It is invoked every time a new trust-region radius is chosen.
If no monitoring is required, monfun may be the dummy monitoring method E04JCP supplied by the NAG Library.

A delegate of type E04JC_MONFUN.

maxcal
Type: System..::..Int32
On entry: the maximum permitted number of calls to objfun.
Constraint: maxcal1.
f
Type: System..::..Double%
On exit: the function value at the lowest point found (x).
nf
Type: System..::..Int32%
On exit: unless ifail=1 or -999 on exit, the total number of calls made to objfun.
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

e04jc is applicable to problems of the form:
minimizexRnFx  subject to  xu  and  u,
where F is a nonlinear scalar function whose derivatives may be unavailable, and where the bound vectors are elements of Rn. Relational operators between vectors are interpreted elementwise.
Fixing variables (that is, setting i=ui for some i) is allowed in e04jc.
You must supply a method to calculate the value of F at any given point x.
The method used by e04jc is based on BOBYQA, the method of Bound Optimization BY Quadratic Approximation described in Powell (2009). In particular, each iteration of e04jc generates a quadratic approximation Q to F that agrees with F at m automatically chosen interpolation points. The value of m is a constant prescribed by you. Updates to the independent variables mostly occur from approximate solutions to trust-region subproblems, using the current quadratic model.

References

Powell M J D (2009) The BOBYQA algorithm for bound constrained optimization without derivatives Report DAMTP 2009/NA06 University of Cambridge http://www.damtp.cam.ac.uk/user/na/NA_papers/NA2009_06.pdf

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
An input parameter is invalid.
ifail=2
The function evaluations limit was reached: objfun has been called maxcal times.
ifail=3
The predicted reduction in a trust-region step was non-positive. Check your specification of objfun and whether the function needs rescaling. Try a different initial x.
ifail=4
A rescue procedure has been called in order to correct damage from rounding errors when computing an update to a quadratic approximation of F, but no further progess could be made. Check your specification of objfun and whether the function needs rescaling. Try a different initial x.
ifail=5
You terminated the solver.
You indicated that you wished to halt solution of the current problem by setting inform to a negative value in either objfun or monfun.
ifail=-999
Internal memory allocation failed.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

Experience shows that, in many cases, on successful termination the -norm distance from the best point x to a local minimum of F is less than 10×rhoend, unless rhoend is so small that such accuracy is unattainable.

Parallelism and Performance

None.

Further Comments

For each invocation of e04jc, local workspace arrays of fixed length are allocated internally. The total size of these arrays amounts to npt+6×npt+nr+nr×3nr+212 real elements and nr integer elements, where nr denotes the number of non-fixed variables; that is, the total size is Onr4. If you follow the recommendation for the choice of npt on entry, this total size reduces to Onr2.
Usually the total number of function evaluations (nf) is substantially less than Onr2, and often, if npt=2×nr+1 on entry, nf is only of magnitude nr or less.

Example

This example involves the minimization of
F=x1+10x22+5x3-x42+x2-2x34+10x1-x44
subject to
-1x13,-2x20,-1x43,
starting from the initial guess 3,-1,0,1.

Example program (C#): e04jce.cs

Example program results: e04jce.r

See Also