nag_opt_bounds_qa_no_deriv (e04jcc) (PDF version)
e04 Chapter Contents
e04 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_opt_bounds_qa_no_deriv (e04jcc)

## 1  Purpose

nag_opt_bounds_qa_no_deriv (e04jcc) 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 function 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$.

## 2  Specification

 #include #include
void  nag_opt_bounds_qa_no_deriv (
 void (*objfun)(Integer n, const double x[], double *f, Nag_Comm *comm, Integer *inform),
Integer n, Integer npt, double x[], const double bl[], const double bu[], double rhobeg, double rhoend,
 void (*monfun)(Integer n, Integer nf, const double x[], double f, double rho, Nag_Comm *comm, Integer *inform),
Integer maxcal, double *f, Integer *nf, Nag_Comm *comm, NagError *fail)

## 3  Description

nag_opt_bounds_qa_no_deriv (e04jcc) is applicable to problems of the form:
 $minimize x∈Rn Fx subject to ℓ ≤ x ≤ u and ℓ≤u ,$
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.
Fixing variables (that is, setting ${\ell }_{i}={u}_{i}$ for some $i$) is allowed in nag_opt_bounds_qa_no_deriv (e04jcc).
You must supply a function to calculate the value of $F$ at any given point $\mathbf{x}$.
The method used by nag_opt_bounds_qa_no_deriv (e04jcc) is based on BOBYQA, the method of Bound Optimization BY Quadratic Approximation described in Powell (2009). In particular, each iteration of nag_opt_bounds_qa_no_deriv (e04jcc) 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.

## 4  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

## 5  Arguments

1:     objfunfunction, supplied by the userExternal Function
objfun must evaluate the objective function $F$ at a specified vector $\mathbf{x}$.
The specification of objfun is:
 void objfun (Integer n, const double x[], double *f, Nag_Comm *comm, Integer *inform)
1:     nIntegerInput
On entry: $n$, the number of independent variables.
2:     x[n]const doubleInput
On entry: $\mathbf{x}$, the vector at which the objective function is to be evaluated.
3:     fdouble *Output
On exit: must be set to the value of the objective function at $\mathbf{x}$, unless you have specified termination of the current problem using inform.
4:     commNag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to objfun.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_opt_bounds_qa_no_deriv (e04jcc) you may allocate memory and initialize these pointers with various quantities for use by objfun when called from nag_opt_bounds_qa_no_deriv (e04jcc) (see Section 3.2.1.1 in the Essential Introduction).
5:     informInteger *Output
On exit: must be set to a value describing the action to be taken by the solver on return from objfun. Specifically, if the value is negative the solution of the current problem will terminate immediately; otherwise, computations will continue.
2:     nIntegerInput
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.
3:     nptIntegerInput
On entry: $m$, the number of interpolation conditions imposed on the quadratic approximation at each iteration.
Suggested value: ${\mathbf{npt}}=2×{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)×\left({n}_{r}+2\right)}{2}$, where ${n}_{r}$ denotes the number of non-fixed variables.
4:     x[n]doubleInput/Output
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{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR on exit, x is the position of the minimum.
5:     bl[n]const doubleInput
6:     bu[n]const doubleInput
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 nag_real_largest_number (X02ALC)).
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×{\mathbf{rhobeg}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
7:     rhobegdoubleInput
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}}$.
8:     rhoenddoubleInput
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$.
9:     monfunfunction, supplied by the userExternal Function
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 specified as NULLFN.
The specification of monfun is:
 void monfun (Integer n, Integer nf, const double x[], double f, double rho, Nag_Comm *comm, Integer *inform)
1:     nIntegerInput
On entry: $n$, the number of independent variables.
2:     nfIntegerInput
On entry: the cumulative number of calls made to objfun.
3:     x[n]const doubleInput
On entry: the current best point.
4:     fdoubleInput
On entry: the value of objfun at x.
5:     rhodoubleInput
On entry: a lower bound on the current trust-region radius.
6:     commNag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to monfun.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_opt_bounds_qa_no_deriv (e04jcc) you may allocate memory and initialize these pointers with various quantities for use by monfun when called from nag_opt_bounds_qa_no_deriv (e04jcc) (see Section 3.2.1.1 in the Essential Introduction).
7:     informInteger *Output
On exit: must be set to a value describing the action to be taken by the solver on return from monfun. Specifically, if the value is negative the solution of the current problem will terminate immediately; otherwise, computations will continue.
10:   maxcalIntegerInput
On entry: the maximum permitted number of calls to objfun.
Constraint: ${\mathbf{maxcal}}\ge 1$.
11:   fdouble *Output
On exit: the function value at the lowest point found (x).
12:   nfInteger *Output
On exit: unless ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_RESCUE_FAILEDNE_TOO_MANY_FEVALSNE_TR_STEP_FAILED or NE_USER_STOP on exit, the total number of calls made to objfun.
13:   commNag_Comm *Communication Structure
The NAG communication argument (see Section 3.2.1.1 in the Essential Introduction).
14:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).
nag_opt_bounds_qa_no_deriv (e04jcc) returns with ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR if the final trust-region radius has reached its lower bound rhoend.

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_BOUND
On entry, ${\mathbf{rhobeg}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{bl}}\left[i-1\right]=⟨\mathit{\text{value}}⟩$, ${\mathbf{bu}}\left[i-1\right]=⟨\mathit{\text{value}}⟩$ and $i=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{bl}}\left[i-1\right]\ne {\mathbf{bu}}\left[i-1\right]$ in coordinate $i$, then ${\mathbf{bu}}\left[i-1\right]-{\mathbf{bl}}\left[i-1\right]\ge 2×{\mathbf{rhobeg}}$.
NE_INT
On entry, ${\mathbf{maxcal}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{maxcal}}\ge 1$.
There were ${n}_{r}=⟨\mathit{\text{value}}⟩$ unequal bounds.
Constraint: ${n}_{r}\ge 2$.
There were ${n}_{r}=⟨\mathit{\text{value}}⟩$ unequal bounds and ${\mathbf{npt}}=⟨\mathit{\text{value}}⟩$ on entry.
Constraint: ${n}_{r}+2\le {\mathbf{npt}}\le \frac{\left({n}_{r}+1\right)×\left({n}_{r}+2\right)}{2}$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL
On entry, ${\mathbf{rhobeg}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{rhobeg}}>0.0$.
On entry, ${\mathbf{rhoend}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{rhoend}}>0.0$.
NE_REAL_2
On entry, ${\mathbf{rhobeg}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{rhoend}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{rhoend}}\le {\mathbf{rhobeg}}$.
NE_RESCUE_FAILED
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.
NE_TOO_MANY_FEVALS
The function evaluations limit was reached: objfun has been called maxcal times.
NE_TR_STEP_FAILED
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.
NE_USER_STOP
User-supplied monitoring function requested termination.
User-supplied objective function requested termination.

## 7  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×{\mathbf{rhoend}}$, unless rhoend is so small that such accuracy is unattainable.

## 8  Parallelism and Performance

nag_opt_bounds_qa_no_deriv (e04jcc) is not threaded by NAG in any implementation.
nag_opt_bounds_qa_no_deriv (e04jcc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the Users' Note for your implementation for any additional implementation-specific information.

## 9  Further Comments

For each invocation of nag_opt_bounds_qa_no_deriv (e04jcc), local workspace arrays of fixed length are allocated internally. The total size of these arrays amounts to $\left({\mathbf{npt}}+6\right)×\left({\mathbf{npt}}+{n}_{r}\right)+\frac{{n}_{r}×\left(3{n}_{r}+21\right)}{2}$ double 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)$.
Usually the total number of function evaluations (nf) is substantially less than $\mathcal{O}\left({n}_{r}^{2}\right)$, and often, if ${\mathbf{npt}}=2×{n}_{r}+1$ on entry, nf is only of magnitude ${n}_{r}$ or less.

## 10  Example

This example involves the minimization of
 $F = x1+10x2 2 +5⁢ x3 - x4 2 + x2-2 x3 4 +10⁢ x1 - x4 4$
subject to
 $-1≤x1≤ 3, -2≤x2≤ 0, -1≤x4≤ 3,$
starting from the initial guess $\left(3,-1,0,1\right)$.

### 10.1  Program Text

Program Text (e04jcce.c)

None.

### 10.3  Program Results

Program Results (e04jcce.r)

nag_opt_bounds_qa_no_deriv (e04jcc) (PDF version)
e04 Chapter Contents
e04 Chapter Introduction
NAG Library Manual