e04jc is an easy-to-use algorithm that uses methods of quadratic approximation to find a minimum of an objective function $F$ over $\mathbf{x}\in {R}^{n}$, subject to fixed lower and upper bounds on the independent variables ${x}_{1},{x}_{2},\dots ,{x}_{n}$. 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
A delegate of type E04JC_OBJFUN.

- n
- Type: System..::..Int32
*On entry*: $n$, the number of independent variables.*Constraint*: ${\mathbf{n}}\ge 2$ and ${n}_{r}\ge 2$, where ${n}_{r}$ 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*: ${\mathbf{npt}}=2\times {n}_{r}+1$, where ${n}_{r}$ denotes the number of non-fixed variables.*Constraint*: ${n}_{r}+2\le {\mathbf{npt}}\le \frac{\left({n}_{r}+1\right)\times \left({n}_{r}+2\right)}{2}$, where ${n}_{r}$ 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 ${\mathbf{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 $\mathbf{\ell}$ and the upper bounds $\mathbf{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={r}_{\mathrm{max}}^{\frac{1}{4}}$ may be suitable, where ${r}_{\mathrm{max}}$ denotes the largest positive model number (see x02al).*Constraints*:- if ${\mathbf{x}}\left[\mathit{i}-1\right]$ is to be fixed at ${\mathbf{bl}}\left[\mathit{i}-1\right]$, then ${\mathbf{bl}}\left[\mathit{i}-1\right]={\mathbf{bu}}\left[\mathit{i}-1\right]$;
- otherwise ${\mathbf{bu}}\left[\mathit{i}-1\right]-{\mathbf{bl}}\left[\mathit{i}-1\right]\ge 2.0\times {\mathbf{rhobeg}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.

- bu
- Type: array<System..::..Double>[]()[][]An array of size [n]
*On entry*: the fixed vectors of bounds: the lower bounds $\mathbf{\ell}$ and the upper bounds $\mathbf{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={r}_{\mathrm{max}}^{\frac{1}{4}}$ may be suitable, where ${r}_{\mathrm{max}}$ denotes the largest positive model number (see x02al).*Constraints*:- if ${\mathbf{x}}\left[\mathit{i}-1\right]$ is to be fixed at ${\mathbf{bl}}\left[\mathit{i}-1\right]$, then ${\mathbf{bl}}\left[\mathit{i}-1\right]={\mathbf{bu}}\left[\mathit{i}-1\right]$;
- otherwise ${\mathbf{bu}}\left[\mathit{i}-1\right]-{\mathbf{bl}}\left[\mathit{i}-1\right]\ge 2.0\times {\mathbf{rhobeg}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{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*:- ${\mathbf{rhobeg}}>0.0$;
- ${\mathbf{rhobeg}}\ge {\mathbf{rhoend}}$.

- 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*: ${\mathbf{rhoend}}>0.0$.

- monfun
- Type: NagLibrary..::..E04..::..E04JC_MONFUNmonfun 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*: ${\mathbf{maxcal}}\ge 1$.

- f
- Type: System..::..Double%
*On exit*: the function value at the lowest point found (x).

- nf
- Type: System..::..Int32%
*On exit*: unless ${\mathbf{ifail}}={1}$ or ${-}{999}$ on exit, the total number of calls made to objfun.

- ifail
- Type: System..::..Int32%
*On exit*: ${\mathbf{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:

where $F$ is a nonlinear scalar function whose derivatives may be unavailable, and where the bound vectors are elements of ${R}^{n}$. Relational operators between vectors are interpreted elementwise.

$$\underset{\mathbf{x}\in {R}^{n}}{\mathrm{minimize}}\phantom{\rule{0.25em}{0ex}}F\left(\mathbf{x}\right)\text{\hspace{1em} subject to \hspace{1em}}\mathbf{\ell}\le \mathbf{x}\le \mathbf{u}\text{\hspace{1em} and \hspace{1em}}\mathbf{\ell}\le \mathbf{u}\text{,}$$ |

You must supply a method to calculate the value of $F$ at any given point $\mathbf{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:

- ${\mathbf{ifail}}=1$
- An input parameter is invalid.

- ${\mathbf{ifail}}=2$

- ${\mathbf{ifail}}=3$

- ${\mathbf{ifail}}=4$

- ${\mathbf{ifail}}=5$
- You terminated the solver.

- ${\mathbf{ifail}}=-999$
- Internal memory allocation failed.

# Accuracy

Experience shows that, in many cases, on successful termination the $\infty $-norm distance from the best point $\mathbf{x}$ to a local minimum of $F$ is less than $10\times {\mathbf{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 $\left({\mathbf{npt}}+6\right)\times \left({\mathbf{npt}}+{n}_{r}\right)+\frac{{n}_{r}\times \left(3{n}_{r}+21\right)}{2}$ real elements and ${n}_{r}$ integer elements, where ${n}_{r}$ denotes the number of non-fixed variables; that is, the total size is $\mathcal{O}\left({n}_{r}^{4}\right)$. If you follow the recommendation for the choice of npt on entry, this total size reduces to $\mathcal{O}\left({n}_{r}^{2}\right)$.

# Example

This example involves the minimization of

subject to

starting from the initial guess $\left(3,-1,0,1\right)$.

$$F={\left({x}_{1}+10{x}_{2}\right)}^{2}+5{\left({x}_{3}-{x}_{4}\right)}^{2}+{\left({x}_{2}-2{x}_{3}\right)}^{4}+10{\left({x}_{1}-{x}_{4}\right)}^{4}$$ |

$$\begin{array}{c}\phantom{-}1\le {x}_{1}\le 3\phantom{,}\\ -2\le {x}_{2}\le 0\phantom{,}\\ \phantom{-}1\le {x}_{4}\le 3\text{,}\end{array}$$ |