h Chapter Contents
h Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_ip_bb (h02bbc)

## 1  Purpose

nag_ip_bb (h02bbc) solves ‘zero-one’, ‘general’, ‘mixed’ or ‘all’ integer linear and quadratic programming problems using a branch and bound method. The function may also be used to find either the first integer solution or the optimum integer solution. It is not intended for large sparse problems.

## 2  Specification

 #include #include
void  nag_ip_bb (Integer n, Integer m, const double a[], Integer tda, const double bl[], const double bu[], const Nag_Boolean intvar[], const double cvec[], const double h[], Integer tdh,
 void (*qphess)(Integer n, Integer jthcol, const double h[], Integer tdh, const double x[], double hx[], Nag_Comm *comm),
double x[], double *objf, Nag_H02_Opt *options, Nag_Comm *comm, NagError *fail)

## 3  Description

nag_ip_bb (h02bbc) is capable of solving certain types of integer programming (IP) problems using a branch and bound (BB) method, see Taha (1987). In order to describe these types of integer programs and to briefly state the BB method, we define the following problem.
 $minimize x ∈ R n f x subject to l ≤ x A x ≤ u ,$ (1)
where $A$ is an $m$ by $n$ matrix and $f\left(x\right)$ may be specified in a variety of ways depending upon the particular problem to be solved. The available forms for $f\left(x\right)$ are listed in Table 1 below. For the moment, however, we assume that $f\left(x\right)={c}^{\mathrm{T}}x$ so that (1) is a linear programming (LP) problem.
If, in (1), it is required that some (or all) of the variables take integer values, then the integer program is of type mixed (or all) general IP problem. If, additionally, the integer variables are restricted to take only 0-1 values (i.e., ${l}_{j}=0$ and ${u}_{j}=1$) then the integer program is of type mixed (or all) zero-one IP problem. nag_ip_bb (h02bbc) does not treat the all integer or zero-one cases specially; therefore, since the mixed integer general IP case is the most general, we shall refer to (1), together with whatever integrality restrictions are applied, as a mixed integer linear programming (MILP) problem, with the assumption that the special cases are included in this.
The BB method applies directly to these integer programs. The general idea of BB is to solve the problem without the integrality restrictions as an LP problem (first or root node). If in the optimal solution an integer variable ${x}_{k}$ takes a non-integer value ${x}_{k}^{*}$, two LP sub-problems or nodes are created by branching, imposing ${x}_{k}\le \left[{x}_{k}^{*}\right]$ and ${x}_{k}\ge \left[{x}_{k}^{*}\right]+1$ respectively, where $\left[{x}_{k}^{*}\right]$ denotes the integer part of ${x}_{k}^{*}$. This method of branching continues until the first integer solution (bound) is obtained. The hanging nodes are then solved and investigated in order to prove the optimality of the solution. The algorithm is described in more detail in Section 11.
The same method may also be applied when the objective function $f\left(x\right)$ takes other forms. An important assumption for the method to be theoretically valid is that each sub-problem is solved to global optimality. This is the case when, for example, $f\left(x\right)$ is a quadratic function which has a positive (semi-)definite Hessian. For such $f\left(x\right)$ the sub-problems of the BB search are quadratic programming (QP) problems, which can, in principle, be solved to global optimality. With a quadratic objective function, the problem becomes a mixed integer quadratic programming (MIQP) problem.
nag_ip_bb (h02bbc) is able to solve problems in which $f\left(x\right)$ is a linear or quadratic function, defined in a variety of ways as described in Table 1 below. The sub-problems are solved using the algorithm of nag_opt_qp (e04nfc).
 Problem Type $f\left(x\right)$ Matrix $H$ MILP ${c}^{\mathrm{T}}x$ Not applicable MIQP1 $\phantom{{c}^{\mathrm{T}}x+}\frac{1}{2}{x}^{\mathrm{T}}Hx$ symmetric MIQP2 ${c}^{\mathrm{T}}x+\frac{1}{2}{x}^{\mathrm{T}}Hx$ symmetric MIQP3 $\phantom{{c}^{\mathrm{T}}x+}\frac{1}{2}{x}^{\mathrm{T}}{H}^{\mathrm{T}}Hx$ $m$ by $n$ upper trapezoidal MIQP4 ${c}^{\mathrm{T}}x+\frac{1}{2}{x}^{\mathrm{T}}{H}^{\mathrm{T}}Hx$ $m$ by $n$ upper trapezoidal
Table 1

### 3.1  Suitability of BB Method for MIQP Problems

The BB method is applicable to an IP problem whenever the global optimum may reliably be found for each sub-problem, and this is theoretically true for an MILP problem. However, this may not be true for an MIQP problem in which the Hessian is not positive (semi-)definite; in such a case the sub-problems may have solutions which are locally but not globally optimal and, in general, it is not possible to ensure that a QP sub-problem solver will always find the global optimum when local optima are present. For problems of type MIQP3 and MIQP4, it is a consequence of the way the Hessian is defined that it must be positive (semi-)definite, but no such guarantee holds for problems of type MIQP1 or MIQP2.
nag_ip_bb (h02bbc) does not check if the Hessian is positive (semi-)definite. This provides for the possibility that you have special knowledge about the problem, for example that an indefinite Hessian is positive (semi-)definite on the feasible region defined by the problem constraints (in which case the problem has no local optima). Alternatively, you may wish to use nag_ip_bb (h02bbc) as a heuristic, with the understanding that if a solution is obtained, it may not be the true global optimum of the MIQP problem, or that no solution might be found even though one does exist. If you wish to check whether the Hessian of a problem of type MIQP1 or MIQP2 is positive (semi-)definite, and therefore whether any solution obtained can be relied upon, one way this may be achieved is to analyse its eigenvalues (for example using nag_real_symm_eigenvalues (f02aac)): the Hessian is positive semidefinite if and only if all of its eigenvalues are $\ge 0$.

### 3.2  Maximization Problems

nag_ip_bb (h02bbc) attempts to solve a minimization problem of the form (1) (together with the integrality requirements). In principle, a maximization problem can be solved by minimizing $-f\left(x\right)$, i.e., reversing the sign of the objective function. This is always valid in the case of an MILP problem, as long as the resulting problem is not unbounded, and simply involves reversing the signs of the coefficients of $c$ (the elements of the input argument array cvec, see Section 4). In the case of an MIQP problem some care must be taken since reversing the sign of a positive (semi-)definite Hessian will make it negative (semi-)definite and vice-versa. Recall that the theoretical validity of the BB method, applied to an MIQP problem, effectively requires that the Hessian be positive (semi-)definite on the feasible region defined by the problem constraints.
Assuming these considerations to be taken into account, a maximization problem of type MIQP1 can be solved by reversing the signs of the elements of $H$; type MIQP2 problems require the signs of the coefficients of $c$ to be reversed also. Problem types MIQP3 and MIQP4 have a positive (semi-)definite Hessian by definition, so it would not normally make sense to solve these as maximization problems. Hence, nag_ip_bb (h02bbc) does not allow you to reverse the sign of the quadratic objective term for these problem types.

## 4  References

Dakin R J (1965) A tree search algorithm for mixed integer programming problems Comput. J. 8 250–255
Mitra G (1973) Investigation of some branch and bound strategies for the solution of mixed integer linear programs Math. Programming 4 155–170
Taha H A (1987) Operations Research: An Introduction Macmillan, New York
Williams H P (1993) Model Building in Mathematical Programming (3rd Edition) Wiley

## 5  Arguments

1:     nIntegerInput
On entry: $n$, the number of variables.
Constraint: ${\mathbf{n}}>0$.
2:     mIntegerInput
On entry: $m$, the number of general linear constraints.
Constraint: ${\mathbf{m}}\ge 0$.
3:     a[${\mathbf{m}}×{\mathbf{tda}}$]const doubleInput
Note: the $\left(i,j\right)$th element of the matrix $A$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{tda}}+j-1\right]$.
On entry: the $\mathit{i}$th row of a must contain the coefficients of the $\mathit{i}$th general linear constraint, for $\mathit{i}=1,2,\dots ,m$.
If ${\mathbf{m}}=0$, the array a is not referenced and may be set to the null pointer.
4:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: if ${\mathbf{m}}>0$, ${\mathbf{tda}}\ge {\mathbf{n}}$
5:     bl[${\mathbf{n}}+{\mathbf{m}}$]const doubleInput
6:     bu[${\mathbf{n}}+{\mathbf{m}}$]const doubleInput
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, and the next $m$ elements the bounds for the general linear constraints (if any). To specify a nonexistent lower bound (i.e., ${l}_{j}=-\infty$), set ${\mathbf{bl}}\left[j-1\right]\le -{\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$, and to specify a nonexistent upper bound (i.e., ${u}_{j}=+\infty$), set ${\mathbf{bu}}\left[j-1\right]\ge {\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$, where ${\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$ is one of the optional arguments (default value ${10}^{20}$, see Section 10.2). To specify the $j$th constraint as an equality, set ${\mathbf{bl}}\left[j-1\right]={\mathbf{bu}}\left[j-1\right]=\beta$, say, where $\left|\beta \right|<{\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$.
Constraint: ${\mathbf{bl}}\left[\mathit{j}\right]\le {\mathbf{bu}}\left[\mathit{j}\right]$, for $\mathit{j}=0,1,\dots ,{\mathbf{n}}+{\mathbf{m}}-1$.
7:     intvar[n]const Nag_BooleanInput
On entry: indicates which are the integer variables in the problem. For example, if ${x}_{j}$ is an integer variable then ${\mathbf{intvar}}\left[j-1\right]$ must be set to 1, and 0 otherwise. The degenerate case, in which all elements of intvar are zero, is allowed. In this case, nag_ip_bb (h02bbc) solves a single LP or QP problem (depending on the problem type as specified by the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{prob}}$, see Section 10.2).
Constraint: ${\mathbf{intvar}}\left[\mathit{j}\right]=0\text{​ or ​}1$, for $\mathit{j}=0,1,\dots ,{\mathbf{n}}-1$.
8:     cvec[n]const doubleInput
On entry: the coefficients ${c}_{j}$ of the explicit linear term of the objective function when the problem is of type MILP, MIQP2 or MIQP4. The default problem type is MILP; other problem types can be specified using the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{prob}}$, see Section 10.2.
If the problem is of type MIQP1 or MIQP3, cvec is not referenced and may be set to the null pointer.
9:     h[${\mathbf{n}}×{\mathbf{tdh}}$]const doubleInput
On entry: h may be used to store the quadratic term $H$ of the MIQP objective function if desired. The elements of h are accessed only by the function qphess; thus, h is not accessed if the problem is of the type MILP (the default) and may be set to the null pointer.
The number of rows of h is denoted by ${n}_{H}$ and its default value is equal to $n$. (The optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$ may be used to specify a value of ${n}_{H}; see Section 10.2).
If the problem is of type MIQP1 or MIQP2, the first ${n}_{H}$ rows and columns of h must contain the leading ${n}_{H}$ by ${n}_{H}$ rows and columns of the symmetric Hessian matrix. Only the diagonal and upper triangular elements of the leading ${n}_{H}$ rows and columns of h are referenced. The remaining elements need not be assigned.
For problems of type MIQP3 and MIQP4, the first ${n}_{H}$ rows of h must contain an ${n}_{H}$ by $n$ upper trapezoidal factor of the Hessian matrix. The factor need not be of full rank, i.e., some of the diagonals may be zero. However, as a general rule, the larger the dimension of the leading non-singular sub-matrix of $H$, the fewer iterations will be required. Elements outside the upper trapezoidal part of the first ${n}_{H}$ rows of $H$ are assumed to be zero and need not be assigned.
In some cases, you need not use h to store $H$ explicitly (see the specification of function qphess).
10:   tdhIntegerInput
On entry: the stride separating matrix column elements in the array h.
Constraint: ${\mathbf{tdh}}\ge {\mathbf{n}}$ or at least the value of the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$ if it is set. This constraint is enforced only for problems of type MIQP in which the qphess argument is null.
11:   qphessfunction, supplied by the userExternal Function
In general, you need not provide a version of qphess, because a ‘default’ function is included in the NAG C Library. If the default function is required then the NAG defined null function pointer, NULLFN, should be supplied in the call to nag_ip_bb (h02bbc). The algorithm of nag_ip_bb (h02bbc) requires only the product of $H$ and a vector $x$; and in some cases you may obtain increased efficiency by providing a version of qphess that avoids the need to define the elements of the matrix $H$ explicitly.
qphess is not referenced for problems of type MILP (the default), in which case qphess should be replaced by NULLFN.
The specification of qphess is:
 void qphess (Integer n, Integer jthcol, const double h[], Integer tdh, const double x[], double hx[], Nag_Comm *comm)
1:     nIntegerInput
On entry: $n$, the number of variables.
2:     jthcolIntegerInput
On entry: jthcol specifies whether or not the vector $x$ is a column of the identity matrix.
${\mathbf{jthcol}}=j>0$
The vector $x$ is the $j$th column of the identity matrix, and hence $Hx$ is the $j$th column of $H$, which can sometimes be computed very efficiently and qphess may be coded to take advantage of this. However special code is not necessary because $x$ is always stored explicitly in the array x.
${\mathbf{jthcol}}=0$
$x$ has no special form.
3:     h[${\mathbf{n}}×{\mathbf{tdh}}$]const doubleInput
On entry: the matrix $H$ of the QP objective function. The matrix element ${H}_{ij}$ is contained in ${\mathbf{h}}\left[\left(i-1\right)×tdh+j-1\right]$ for $i=1,2,\dots ,n$ and $j=1,2,\dots ,n$. In some situations, it may be desirable to compute $Hx$ without accessing h – for example, if $H$ is sparse or has special structure. (This is illustrated in the function qphess in Section 9.) The arguments h and tdh may then refer to any convenient array.
4:     tdhIntegerInput
On entry: the stride separating matrix column elements in the array h.
5:     x[n]const doubleInput
On entry: the vector $x$.
6:     hx[n]doubleOutput
On exit: the product $Hx$.
7:     commNag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to qphess.
flagIntegerInput/Output
On entry: qphess is called with $\mathbf{comm}\mathbf{\to }\mathbf{flag}$ set to a non-negative number.
On exit: if qphess resets $\mathbf{comm}\mathbf{\to }\mathbf{flag}$ to some negative number then nag_ip_bb (h02bbc) will terminate immediately with the error indicator NE_USER_STOP. If fail is supplied to nag_ip_bb (h02bbc), ${\mathbf{fail}}\mathbf{.}\mathbf{errnum}$ will be set to your setting of $\mathbf{comm}\mathbf{\to }\mathbf{flag}$.
firstNag_BooleanInput
On entry: will be set to Nag_TRUE on the first call to qphess and Nag_FALSE for all subsequent calls.
nfIntegerInput
On entry: the number of calls made to qphess including the current one.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void * with a C compiler that defines void * and char * otherwise.
Before calling nag_ip_bb (h02bbc) these pointers may be allocated memory and initialized with various quantities for use by qphess when called from nag_ip_bb (h02bbc).
Note: qphess should be tested separately before being used in conjunction with nag_ip_bb (h02bbc). The input arrays h and x must not be changed by qphess.
12:   x[n]doubleInput/Output
On entry: an initial estimate of the solution of the first sub-problem (the problem as described in Section 3).
If optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}=\mathrm{Nag_Branch_InitX}$ (which is not the default value), then the initial values in x of the integer variables influence the branching procedure in the BB algorithm. Typically, an estimate of the values of the integer variables in the IP solution would be provided in this case. See Section 10.2 for details.
On exit: with ${\mathbf{fail}}\mathbf{.}\mathbf{code}=\mathrm{NE_NOERROR}$, x contains a solution which will be an estimate of either the optimum integer solution or the first integer solution, depending on the value of optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{first_soln}}$. If ${\mathbf{fail}}\mathbf{.}\mathbf{code}={\mathbf{NW_MIP_MAX_NODES_INT_SOL}}$, NW_MIP_MAX_DEPTH_INT_SOL, NW_MIP_MAX_ITER_INT_SOL, or NE_MIP_HESS_TOO_BIG_INT_SOL then x contains a solution which may not be the optimal IP solution because nag_ip_bb (h02bbc) was unable to investigate all of the nodes. See Section 6 for more details.
13:   objfdouble *Output
On exit: with ${\mathbf{fail}}\mathbf{.}\mathbf{code}=\mathrm{NE_NOERROR}$, NW_MIP_MAX_NODES_INT_SOL, NW_MIP_MAX_DEPTH_INT_SOL, NW_MIP_MAX_ITER_INT_SOL, or NE_MIP_HESS_TOO_BIG_INT_SOL, objf contains the value of the objective function for the IP solution.
14:   optionsNag_H02_Opt *Input/Output
On entry/exit: a pointer to a structure of type Nag_H02_Opt whose members are optional arguments for nag_ip_bb (h02bbc). These structure members offer the means of adjusting some of the argument values of the algorithm and on output will supply further details of the results. A description of the members of options is given below in Section 10.
The options structure also allows names to be assigned to the variables and constraints of the problem, which are then used in solution output. In particular, if the problem is defined by an MPSX file, the function nag_ip_mps_read (h02buc) may be used to read the file, and to store the variable and constraint names in options for use by nag_ip_bb (h02bbc).
If any of these optional arguments are required then the structure options should be declared and initialized by a call to nag_ip_init (h02xxc) and supplied as an argument to nag_ip_bb (h02bbc). However, if the optional arguments are not required the NAG defined null pointer, H02_DEFAULT, can be used in the function call.
15:   commNag_Comm *Input/Output
Note: comm is a NAG defined type (see Section 3.2.1.1 in the Essential Introduction).
On entry/exit: structure containing pointers for communication to the user-supplied function, qphess, and the optional user-defined printing function. See the description of qphess and Section 10.3.1 for details. If you do not need to make use of this communication feature the null pointer NAGCOMM_NULL may be used in the call to nag_ip_bb (h02bbc); comm will then be declared internally for use in calls to user-supplied functions.
16:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

### 5.1  Description of Printed Output

Intermediate and final results are printed out by default. The level of printed output can be controlled with the structure member ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}$ (see Section 10.2).
The default, ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Soln_Iter}$, provides a single line of output at the end of each node and the final IP result. If nag_ip_bb (h02bbc) fails to find an IP solution, the final solution printed will be the original LP or QP (root node) solution. This section describes the default printout produced by nag_ip_bb (h02bbc).
The following line of summary output is produced at the end of every node. It gives the outcome of forcing an integer variable with a non-integer value to take a value within its specified lower and upper bounds.
 Node No is the current node number of the BB tree being investigated. Parent Node is the parent node number of the current node. Obj Value is the final objective function value. If a node does not have a feasible solution then Infeasible is printed instead of the objective function value. If a node whose optimum solution exceeds the best integer solution so far is encountered (i.e., it does not pay to explore the sub-problem any further), then its objective function value is printed together with a CO (Cut Off). Varbl Chosen is the index of the integer variable chosen for branching. Value Before is the non-integer value of the integer variable chosen. Lower Bound is the lower bound value that the integer variable is allowed to take. Upper Bound is the upper bound value that the integer variable is allowed to take. Value After is the value of the integer variable after the current optimization. Depth is the depth of the BB tree at the current node.
The final printout includes a listing of the status of each variable and constraint.
 Varbl gives the name of variable $\mathit{j}$, for $\mathit{j}=1,2,\dots ,n$. If an options structure is supplied to nag_ip_bb (h02bbc), and the ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$ member is assigned to an array of variable and constraint names (see Section 10.2 for details), the name supplied in ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[j-1\right]$ is assigned to the $j$th variable. Otherwise, a default name is assigned to the variable. State gives the state of the variable (FR if neither bound is in the working set, EQ if a fixed variable, LL if on its lower bound, UL if on its upper bound, TF if temporarily fixed at its current value). If Value lies outside the upper or lower bounds by more than the feasibility tolerance, State will be ++ or -- respectively. Value is the value of the variable at the final iteration. Lower Bound is the lower bound ${l}_{j}$ specified for the variable. (None indicates that ${l}_{j}\le -{\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$, where ${\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$ is the optional argument.) The bound is that imposed at the node which provided the IP solution. (If no IP solution was found, the bound is that supplied in bl.) Upper Bound is the upper bound ${u}_{j}$ specified for the variable. (None indicates that ${u}_{j}\ge {\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$.) The bound is that imposed at the node which provided the IP solution. (If no IP solution was found, the bound is that supplied in bu.) Lagr Mult is the value of the Lagrange multiplier for the associated bound constraint. This will be zero if State is FR or TF. If $x$ is optimal, the multiplier should be non-negative if State is LL, and non-positive if State is UL. Residual is the difference between the variable Value and the nearer of its bounds ${l}_{j}$ and ${u}_{j}$.
The meaning of the printout for general constraints is the same as that given above for variables, with ‘variable’ replaced by ‘constraint’, $n$ replaced by $m$, ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[j-1\right]$ replaced by ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[n+j-1\right]$, ${l}_{j}$ and ${u}_{j}$ replaced by ${l}_{n+i}$ and ${u}_{n+i}$ respectively, and with the following change in the heading:
 Constr gives the name of the constraint.
Numerical values are output with a fixed number of digits; they are not guaranteed to be accurate to this precision.

## 6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, ${\mathbf{tda}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tda}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{tdh}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdh}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{tdh}}=〈\mathit{\text{value}}〉$ while ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdh}}\ge {\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}$ had an illegal value.
On entry, argument ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}$ had an illegal value.
On entry, argument ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}$ had an illegal value.
On entry, argument ${\mathbf{options}}\mathbf{.}{\mathbf{prob}}$ had an illegal value.
On entry, argument ${\mathbf{options}}\mathbf{.}{\mathbf{varsel}}$ had an illegal value.
NE_BOUND
The lower bound for variable $〈\mathit{\text{value}}〉$ (array element ${\mathbf{bl}}\left[〈\mathit{\text{value}}〉\right]$) is greater than the upper bound.
NE_BOUND_LCON
The lower bound for linear constraint $〈\mathit{\text{value}}〉$ (array element ${\mathbf{bl}}\left[〈\mathit{\text{value}}〉\right]$) is greater than the upper bound.
NE_CVEC_NULL
${\mathbf{options}}\mathbf{.}{\mathbf{prob}}=〈\mathit{\text{value}}〉$ but argument ${\mathbf{cvec}}=\text{}$ NULL.
NE_H_NULL
${\mathbf{options}}\mathbf{.}{\mathbf{prob}}=〈\mathit{\text{value}}〉$, qphess is NULL but argument h is also NULL. If the default function for qphess is to be used for this problem then an array must be supplied in argument h.
NE_INT_ARG_LT
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
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_INVALID_INT_RANGE_1
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$ is not valid. Correct range is ${\mathbf{n}}\ge {\mathbf{options}}\mathbf{.}{\mathbf{hrows}}\ge 0$.
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{max_depth}}$ is not valid. Correct range is ${\mathbf{options}}\mathbf{.}{\mathbf{max_depth}}\ge 2$.
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$ is not valid. Correct range is ${\mathbf{n}}\ge {\mathbf{options}}\mathbf{.}{\mathbf{max_df}}\ge 1$.
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{max_iter}}$ is not valid. Correct range is ${\mathbf{options}}\mathbf{.}{\mathbf{max_iter}}\ge 0$.
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}$ is not valid. Correct range is ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}=\mathtt{ALL_NODES}$ or ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}\ge 1$.
NE_INVALID_REAL_RANGE_F
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{feas_tol}}$ is not valid. Correct range is ${\mathbf{options}}\mathbf{.}{\mathbf{feas_tol}}>0.0$.
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$ is not valid. Correct range is ${\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}>0.0$.
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$ is not valid. Correct range is ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}\ge 0.0$.
NE_INVALID_REAL_RANGE_FF
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}$ is not valid. Correct range is $0.0<{\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}<1.0$.
Value $〈\mathit{\text{value}}〉$ given to ${\mathbf{options}}\mathbf{.}{\mathbf{rank_tol}}$ is not valid. Correct range is $0.0\le {\mathbf{options}}\mathbf{.}{\mathbf{rank_tol}}<1.0$.
NE_MIP_HESS_TOO_BIG_INT_SOL
Reduced Hessian exceeds assigned dimension during BB tree search. ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}=〈\mathit{\text{value}}〉$. An IP solution was found.
This error can only occur with MIQP problems. Whilst attempting to solve a node during the BB tree search, the QP algorithm needed to expand the reduced Hessian when it was already at its maximum dimension, as specified by the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$. No further nodes were examined. An IP solution was found but it may not be optimal.
The value of the argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$ is too small. Rerun nag_ip_bb (h02bbc) with a larger value. The IP objective obtained should be assigned to ${\mathbf{options}}\mathbf{.}{\mathbf{int_obj_bound}}$ to aid the BB tree search in the repeated run.
NE_MIP_HESS_TOO_BIG_NO_INT_SOL
Reduced Hessian exceeds assigned dimension during BB tree search. ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}=〈\mathit{\text{value}}〉$. No IP solution was found.
This error can only occur with MIQP problems. Whilst attempting to solve a node during the BB tree search, the QP algorithm needed to expand the reduced Hessian when it was already at its maximum dimension, as specified by the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$. No further nodes were examined. No IP solution was found amongst the nodes examined.
The value of the argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$ is too small. Rerun nag_ip_bb (h02bbc) with a larger value.
NE_MIP_ROOT_HESS_TOO_BIG
Reduced Hessian exceeds assigned dimension at root node. ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}=〈\mathit{\text{value}}〉$.
This error can only occur with MIQP problems. Whilst attempting to solve the root node, the QP algorithm needed to expand the reduced Hessian when it was already at its maximum dimension, as specified by the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$.
The value of the argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$ is too small. Rerun nag_ip_bb (h02bbc) with a larger value.
NE_MIP_ROOT_INFEAS
The root node of the BB tree is infeasible.
A feasible point could not be found for the original LP or QP problem, i.e., it was not possible to satisfy all the constraints to within the feasibility tolerance (determined by optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{feas_tol}}$). If the data for the constraints are accurate only to the absolute precision $\sigma$, you should ensure that the value of the feasibility tolerance is greater than $\sigma$. For example, if all elements of $A$ are of order unity and are accurate only to three decimal places, the feasibility tolerance should be at least ${10}^{-3}$ (see Section 8).
NE_MIP_ROOT_MAX_ITER
The maximum number of iterations (determined by optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_iter}}$) was reached before normal termination occurred for the original LP or QP problem (see Section 8).
The maximum number of iterations, $〈\mathit{\text{value}}〉$, was performed before normal termination occurred for the root node of the BB tree.
NE_MIP_ROOT_UNBOUNDED
The root node of the BB tree appears to be unbounded.
See Section 11 for advice.
NE_NAME_TOO_LONG
The character string pointed to by ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[〈\mathit{\text{value}}〉\right]$ is too long. It should be no longer than 8 characters.
NE_NOT_APPEND_FILE
Cannot open file $〈\mathit{string}〉$ for appending.
NE_NOT_CLOSE_FILE
Cannot close file $〈\mathit{string}〉$.
NE_OPT_NOT_INIT
Options structure not initialized.
NE_PRIORITY_NULL
${\mathbf{options}}\mathbf{.}{\mathbf{varsel}}=\mathrm{Nag_Use_Priority}$ but ${\mathbf{options}}\mathbf{.}{\mathbf{priority}}$ is NULL.
NE_USER_STOP
User requested termination, user flag value $\text{}=〈\mathit{\text{value}}〉$.
This exit occurs if you set $\mathbf{comm}\mathbf{\to }\mathbf{flag}$ to a negative value in qphess. If fail is supplied the value of ${\mathbf{fail}}\mathbf{.}\mathbf{errnum}$ will be the same as your setting of $\mathbf{comm}\mathbf{\to }\mathbf{flag}$.
NE_WRITE_ERROR
Error occurred when writing to file $〈\mathit{string}〉$.
NW_MIP_MAX_DEPTH_INT_SOL
An IP solution was found but the search has been terminated because the maximum allowed tree depth (as determined by optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_depth}}$) has been reached.
Increase ${\mathbf{options}}\mathbf{.}{\mathbf{max_depth}}$ and rerun nag_ip_bb (h02bbc). The IP objective obtained should be assigned to ${\mathbf{options}}\mathbf{.}{\mathbf{int_obj_bound}}$ to aid the BB tree search in the repeated run.
NW_MIP_MAX_DEPTH_NO_INT_SOL
The maximum allowed tree depth (as determined by optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_depth}}$) has been reached before any integer solution has been found.
Increase ${\mathbf{options}}\mathbf{.}{\mathbf{max_depth}}$ and rerun nag_ip_bb (h02bbc).
NW_MIP_MAX_ITER_INT_SOL
The IP solution found may not be the optimum. The search had to be terminated in at least one branch of the BB tree because the iteration limit was reached.
It was not possible to solve at least one node of the BB tree, which means that the tree search could not be completed. An IP solution was found but a better one may be present in the unsearched portion of the tree. See Section 8 for more information.
NW_MIP_MAX_ITER_NO_INT_SOL
No IP solution was found but the search had to be terminated in at least one branch of the BB tree because the iteration limit was reached.
It was not possible to solve at least one node of the BB tree, which means that the tree search could not be completed. No IP solution was found but one may be present in the unsearched portion of the tree. See Section 8 for more information.
NW_MIP_MAX_NODES_INT_SOL
The IP solution found is the best for the number of nodes (as determined by optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}$) investigated in the BB tree.
Increase ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}$ and rerun nag_ip_bb (h02bbc). The IP objective obtained should be assigned to ${\mathbf{options}}\mathbf{.}{\mathbf{int_obj_bound}}$ to aid the BB tree search in the repeated run.
NW_MIP_MAX_NODES_NO_INT_SOL
No integer solution was found for the number of nodes (as determined by ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}$) investigated in the BB tree.
Increase ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}$ and rerun nag_ip_bb (h02bbc).
NW_MIP_NO_INT_SOL
No feasible IP solution was found, i.e., it was not possible to satisfy all the integer variables to within optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}$.
It may be appropriate to increase ${\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}$ and rerun nag_ip_bb (h02bbc).
NW_OVERFLOW_WARN
Serious ill-conditioning in the working set after adding constraint $〈\mathit{\text{value}}〉$. Overflow may occur in subsequent iterations.
If overflow occurs preceded by this warning then serious ill-conditioning has probably occurred in the working set when adding a constraint during the solution of a node in the BB tree. It may be possible to avoid the difficulty by increasing the magnitude of the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{feas_tol}}$ and rerunning the program. If the problem recurs even after this change, see Section 8.

## 7  Accuracy

nag_ip_bb (h02bbc) implements a numerically stable active set strategy and returns solutions that are as accurate as the condition of the problem warrants on the machine.

## 8  Further Comments

The root node may not have an optimum solution, i.e., nag_ip_bb (h02bbc) terminates with ${\mathbf{fail}}\mathbf{.}\mathbf{code}={\mathbf{NE_MIP_ROOT_UNBOUNDED}}$, NE_MIP_ROOT_INFEAS, NE_MIP_ROOT_MAX_ITER, NE_MIP_ROOT_HESS_TOO_BIG or overflow may occur. In this case, you are recommended to relax the integer restrictions of the problem and try to find the optimum LP or QP solution by using nag_opt_lp (e04mfc) (for LP) or nag_opt_qp (e04nfc) (for QP) instead.
In the BB method, it is possible for a node to terminate without finding a solution. For example, this may occur due to the number of iterations exceeding the maximum allowed. Therefore the BB tree search for that particular branch cannot be continued and if an IP solution is found, the final solution reported is not necessarily the optimum IP solution (${\mathbf{fail}}\mathbf{.}\mathbf{code}={\mathbf{NW_MIP_MAX_ITER_INT_SOL}}$). Similarly, if no IP solution is found, it is not necessarily the case that no IP solution exists (${\mathbf{fail}}\mathbf{.}\mathbf{code}={\mathbf{NW_MIP_MAX_ITER_NO_INT_SOL}}$).

## 9  Example

One of the applications of integer programming is to the so-called diet problem. Given the nutritional content of a selection of foods, the cost of each food, the amount available of each food and the consumer's minimum daily energy requirements, the problem is to find the cheapest combination. This gives rise to the following problem:
minimize
 $cT x subject to Ax ≥ b , 0 ≤ x ≤ u ,$
where
 $c = 3 24 13 9 20 19 T , x = x 1 , x 2 , x 3 , x 4 , x 5 , x 6 T is integer,$
 $A = 110 205 160 160 420 260 4 32 13 8 4 14 2 12 54 285 22 80 , b = 2000 55 800 and$
 $u = 4 3 2 8 2 2 T .$
The rows of $A$ correspond to energy, protein and calcium and the columns of $A$ correspond to oatmeal, chicken, eggs, milk, pie and bacon respectively.
The following program solves the above problem to obtain the optimal integer solution and then examines the effect of decreasing the energy required to 1970 units. The example involves a number of calls to nag_ip_bb (h02bbc) illustrating the use of some of the optional arguments.
The data is read and the options structure initialized. All options are left at their default values except: the ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$ member is assigned to the local char * array, crnames, the elements of which point to strings containing the variable and constraint names; and ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Soln}$.
nag_ip_bb (h02bbc) is called to obtain the optimal IP solution of the problem, and then the lower bound on the minimum energy constraint (i.e., the first general constraint) is reduced. Since the problem is now less constrained than the original IP problem, the objective function value returned in objf from the original problem provides an upper bound for the objective of the optimal IP solution of the modified problem. Optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{int_obj_bound}}$ is initialized to this value with a small number added to ensure that it is a strict upper bound on the optimal objective of the modified problem. Also, the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}=\mathrm{Nag_Deep_Search}$ to modify the way nag_ip_bb (h02bbc) selects nodes during the tree search. The results from this show that the value assigned to ${\mathbf{options}}\mathbf{.}{\mathbf{int_obj_bound}}$ allow a number of nodes to be cut off (indicated by CO in the printout) before the first IP solution is found.
Next, the effect of supplying branching directions is illustrated. The optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}=\mathrm{Nag_Branch_InitX}$ to instruct nag_ip_bb (h02bbc) to branch according to the values of the integer variables provided in the initial x argument. In this case x contains the optimal IP solution from the last call of nag_ip_bb (h02bbc). The results show that these values allow nag_ip_bb (h02bbc) to find and confirm the optimal IP solution quickly.
The final two calls to nag_ip_bb (h02bbc) show its use in solving an MIQP problem. First, nag_ip_bb (h02bbc) is called with the intvar argument set to an array intvar2 which specifies all variables to be non-integer. This solves the root LP problem of the adjusted diet problem (as solved in the previous three calls to nag_ip_bb (h02bbc)). Let ${x}^{*}$ be the solution to this LP problem. Then, retaining the same constraints, the linear objective is replaced by the quadratic objective
 $∑ i=1 n x i - x i * 2 - ∑ i=1 n x i * 2 = xT x - 2 x * T x$
which measures, to within a constant, the sum of squares deviation of $x$ from ${x}^{*}$. That is, the problem is to find the IP solution which most closely approximates (in the least squares sense) the LP solution. Before solving this problem, the memory assigned to the pointers in the options structure is freed by nag_ip_free (h02xzc) and the structure is reinitialized by nag_ip_free (h02xzc). Then optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{prob}}=\mathrm{Nag_MIQP2}$ and ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$ is assigned as before; otherwise, default options are used. The quadratic term of the objective is supplied via the function qphess which does not require explicit storage for the matrix $H$. nag_ip_bb (h02bbc) is called to solve the MIQP problem, and finally nag_ip_free (h02xzc) is called to free the memory in options.

### 9.1  Program Text

Program Text (h02bbce.c)

### 9.2  Program Data

Program Data (h02bbce.d)

### 9.3  Program Results

Program Results (h02bbce.r)

## 10  Optional Arguments

A number of optional input and output arguments to nag_ip_bb (h02bbc) are available through the structure argument options, type Nag_H02_Opt. An argument may be selected by assigning an appropriate value to the relevant structure member; those arguments not selected will be assigned default values. If no use is to be made of any of the optional arguments you should use the NAG defined null pointer, H02_DEFAULT, in place of options when calling nag_ip_bb (h02bbc) the default settings will then be used for all arguments.
Before assigning values to options directly the structure must be initialized by a call to the function nag_ip_init (h02xxc). Values may then be assigned to the structure members in the normal C manner.
Option settings may also be read from a text file using the function nag_ip_read (h02xyc) in which case initialization of the options structure will be performed automatically if not already done. Any subsequent direct assignment to the options structure must not be preceded by initialization.
If assignment of functions and memory to pointers in the options structure is required, then this must be done directly in the calling program; they cannot be assigned using nag_ip_read (h02xyc).

### 10.1  Optional Argument Checklist and Default Values

For easy reference, the following list shows the members of options which are valid for nag_ip_bb (h02bbc) together with their default values where relevant. The number $\epsilon$ is a generic notation for machine precision (see nag_machine_precision (X02AJC)).
 Nag_MIP_ProbType prob Nag_MILP Boolean list Nag_TRUE Nag_PrintType print_level Nag_Soln_Iter char outfile[80] stdout void (*print_fun)() NULL Integer max_iter $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(50,5\left({\mathbf{n}}+{\mathbf{m}}\right)\right)$ Integer max_nodes ALL_NODES Boolean first_soln Nag_FALSE Integer max_depth $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(10,3{\mathbf{n}}/2\right)$ double int_tol ${10}^{-5}$ double int_obj_bound ${10}^{20}$ double soln_tol $\sqrt{\epsilon }$ Nag_Node_Selection nodsel Nag_MinObj_Search Nag_Var_Selection varsel Nag_First_Int Nag_Branch_Direction branch_dir Nag_Branch_Left double *priority NULL double feas_tol $\sqrt{\epsilon }$ double inf_bound ${10}^{20}$ double rank_tol $100\epsilon$ Integer hrows 0 or n Integer max_df n char **crnames NULL double *lower size ${\mathbf{n}}+{\mathbf{m}}$ double *upper size ${\mathbf{n}}+{\mathbf{m}}$ double *lambda size ${\mathbf{n}}+{\mathbf{m}}$ Integer *state size ${\mathbf{n}}+{\mathbf{m}}$

### 10.2  Description of the Optional Arguments

 prob – Nag_MIP_ProbType Default $\text{}=\mathrm{Nag_MILP}$
On entry: specifies the type of objective function to be minimized during the optimality phase. The following are the five possible values of ${\mathbf{options}}\mathbf{.}{\mathbf{prob}}$ and the size of the arrays h and cvec that are required to define the objective function:
 Nag_MILP h not referenced, ${\mathbf{cvec}}\left[{\mathbf{n}}\right]$; Nag_MIQP1 ${\mathbf{h}}\left[\left({\mathbf{n}}\right)×{\mathbf{tdh}}+{\mathbf{tdh}}\right]$ symmetric, cvec not referenced; Nag_MIQP2 ${\mathbf{h}}\left[\left({\mathbf{n}}\right)×{\mathbf{tdh}}+{\mathbf{tdh}}\right]$ symmetric, ${\mathbf{cvec}}\left[{\mathbf{n}}\right]$; Nag_MIQP3 ${\mathbf{h}}\left[\left({\mathbf{n}}\right)×{\mathbf{tdh}}+{\mathbf{tdh}}\right]$ upper trapezoidal, cvec not referenced; Nag_MIQP4 ${\mathbf{h}}\left[\left({\mathbf{n}}\right)×{\mathbf{tdh}}+{\mathbf{tdh}}\right]$ upper trapezoidal, ${\mathbf{cvec}}\left[{\mathbf{n}}\right]$.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{prob}}=\mathrm{Nag_MILP}$, $\mathrm{Nag_MIQP1}$, $\mathrm{Nag_MIQP2}$, $\mathrm{Nag_MIQP3}$ or $\mathrm{Nag_MIQP4}$.
 list – Nag_Boolean Default $\text{}=\mathrm{Nag_TRUE}$
On entry: if ${\mathbf{options}}\mathbf{.}{\mathbf{list}}=\mathrm{Nag_TRUE}$ the argument settings in the call to nag_ip_bb (h02bbc) will be printed.
 print_level – Nag_PrintType Default $\text{}=\mathrm{Nag_Soln_Iter}$
On entry: the level of results printout produced by nag_ip_bb (h02bbc). The following values are available:
 Nag_NoPrint No output. Nag_Soln The final IP solution. Nag_Soln_Root The root node and final IP solution. Nag_Iter One line of output for each node investigated. Nag_Soln_Iter The final IP solution and one line of output for each node. Nag_Soln_Root_Iter The root node and final IP solution and one line of output for each node.
Details of each level of results printout are described in Section 10.3.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_NoPrint}$, $\mathrm{Nag_Soln}$, $\mathrm{Nag_Soln_Root}$, $\mathrm{Nag_Iter}$, $\mathrm{Nag_Soln_Iter}$ or $\mathrm{Nag_Soln_Root_Iter}$.
 outfile – const char[80] Default $\text{}=\mathtt{stdout}$
On entry: the name of the file to which results should be printed. If ${\mathbf{options}}\mathbf{.}{\mathbf{outfile}}\left[0\right]=\text{'\0'}$ then the stdout stream is used.
 print_fun – pointer to function Default $\text{}=\text{}$ NULL
On entry: printing function defined by you; the prototype of ${\mathbf{options}}\mathbf{.}{\mathbf{print_fun}}$ is
```void (*print_fun)(const Nag_Search_State *st, Nag_Comm *comm);
```
See Section 10.3.1 below for further details.
 max_iter – Integer Default $\text{}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(50,5\left({\mathbf{n}}+{\mathbf{m}}\right)\right)$
On entry: the limit on the number of iterations for each node.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{max_iter}}\ge 0$.
 max_nodes – Integer Default $\text{}=\mathtt{ALL_NODES}$
On entry: the maximum number of nodes that are to be searched in order to find a solution (optimum integer solution). If ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}$ is not set, or is set equal to the symbol ALL_NODES, and the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{first_soln}}=\mathrm{Nag_FALSE}$ (the default), then the BB tree search is continued until all the nodes have been investigated.
Constraints:
• ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}>0$ or ;
• ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}=\mathtt{ALL_NODES}$.
 first_soln – Nag_Boolean Default $\text{}=\mathrm{Nag_FALSE}$
On entry: specifies whether to terminate the BB tree search after the first integer solution (if any) is obtained. If ${\mathbf{options}}\mathbf{.}{\mathbf{first_soln}}=\mathrm{Nag_TRUE}$ then the BB tree search is terminated at node $k$ say, which contains the first integer solution. For optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}\ne$ ALL_NODES this applies only if $k\le {\mathbf{options}}\mathbf{.}{\mathbf{max_nodes}}$.
 max_depth – Integer Default $\text{}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(10,3{\mathbf{n}}/2\right)$
On entry: the maximum depth of the BB tree used for branch and bound.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{max_depth}}\ge 2$.
 int_tol – double Default $\text{}={10}^{-5}$
On entry: the integer feasibility tolerance; i.e., an integer variable is considered to take an integer value if its violation does not exceed ${\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}$. For example, if the integer variable ${x}_{j}$ is of order unity then ${x}_{j}$ is considered to be integer if $\left(1-{\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}\right)\le {x}_{j}\le \left(1+{\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}\right)$.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}>0.0$.
 int_obj_bound – double Default $\text{}={10}^{20}$
On entry: specifies an initial bound on the optimum integer solution. You should supply a value for this argument only if a valid strict upper bound for the IP problem is available. Supplying too small a value will result in nag_ip_bb (h02bbc) not finding an IP solution. If a valid value is provided then this may help to reduce the number of nodes searched in the BB tree (see Section 11.3).
The default value, ${10}^{20}$, is equivalent to no such bound being available.
 soln_tol – double Default $\text{}=\sqrt{\epsilon }$
On entry: specifies a tolerance on the optimal IP solution, i.e., an IP solution returned by nag_ip_bb (h02bbc) as optimal may have an objective function value which is as much as ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$ greater than that associated with the true optimal IP solution. By setting ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$ to a nonzero value, the size of the BB search tree may be reduced at the expense of obtaining a (possibly) inferior solution (see Section 11.3).
This argument only takes effect after the first IP solution has been found. It therefore has no effect if optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{first_soln}}=\mathrm{Nag_TRUE}$ and need not be taken into account when setting optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{int_obj_bound}}$.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}\ge 0.0$.
 nodsel – Nag_Node_Selection Default $\text{}=\mathrm{Nag_MinObj_Search}$
On entry: specifies how nodes are selected during the BB tree search (see Section 11.2). The selection is made from those nodes which are still ‘active’, i.e., those which either have not yet been solved, or which have been solved but not yet branched from. If the node selected has not been solved then it will be solved next; otherwise, it is branched from and one of the resulting child nodes will be solved next. In the latter case, the choice of which child node is solved first is determined by the value of optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}$ (see below). The possible values of ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}$ and their meanings are described below.
 Nag_MinObj_Search selects the node with smallest objective function value. A node which has not yet been solved is assigned its parent's objective function value as the basis for its selection. Nag_Deep_Search selects the deepest node in the BB tree. When selecting a node for branching and there is more than one candidate at the deepest level, preference is given to the node which was solved earliest. This type of node selection is affected by the value of ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}$ (see below). Nag_Broad_Search selects the shallowest node in the tree. This has the effect of searching across the tree (rather than down as for Nag_Deep_Search). Nag_DeepMinObj_Search as Nag_Deep_Search until the first integer solution is found and as Nag_MinObj_Search thereafter. Nag_DeepBroad_Search as Nag_Deep_Search until the first integer solution is found and as Nag_Broad_Search thereafter.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}=\mathrm{Nag_MinObj_Search}$, $\mathrm{Nag_Deep_Search}$, $\mathrm{Nag_Broad_Search}$, $\mathrm{Nag_DeepMinObj_Search}$ or $\mathrm{Nag_DeepBroad_Search}$.
 varsel – Nag_Var_Selection Default $\text{}=\mathrm{Nag_First_Int}$
On entry: specifies how nag_ip_bb (h02bbc) selects the variable to branch on, when an unbranched node has been chosen according to optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}$. Let ${x}^{*}$ denote the solution associated with the selected node. Integer variables are scanned in order of their index in $x$, and any which are integral to within the optional tolerance argument ${\mathbf{options}}\mathbf{.}{\mathbf{int_tol}}$ are ignored. The following values of ${\mathbf{options}}\mathbf{.}{\mathbf{varsel}}$ are available.
 Nag_First_Int select the first integer variable ${x}_{i}$ such that ${x}_{i}^{*}$ is non-integer. Nag_Nearest_Half select the integer variable ${x}_{i}$ such that $\left|{x}_{i}^{*}-\left[{x}_{i}^{*}\right]\right|$ is nearest to $0.5$, where $\left[{x}_{i}^{*}\right]$ denotes the integer part of ${x}_{i}^{*}$. That is, ${x}_{i}$ is the integer variable such that ${x}_{i}^{*}$ is farthest from having an integer value. Nag_Use_Priority branch on the integer variable selected according to the set of priorities provided in optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{priority}}$ (see below).
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{varsel}}=\mathrm{Nag_First_Int}$, $\mathrm{Nag_Nearest_Half}$ or $\mathrm{Nag_Use_Priority}$.
 branch_dir – Nag_Branch_Direction Default $\text{}=\mathrm{Nag_Branch_Left}$
On entry: specifies which node to solve first when two nodes are created by a branching operation. This option is unlikely to have much effect when optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}=\mathrm{Nag_MinObj_Search}$ or $\mathrm{Nag_Broad_Search}$, since the overall order in which parts of the tree are examined will remain the same. However, when ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}=\mathrm{Nag_Deep_Search}$, ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}$ will influence the path taken by nag_ip_bb (h02bbc) as the tree is descended. Similarly, this argument will affect the initial deep search when ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}=\mathrm{Nag_DeepMinObj_Search}$ or $\mathrm{Nag_DeepBroad_Search}$. The following values of ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}$ are available.
 Nag_Branch_Left solve the ‘left’ node first, i.e., that which was formed by reducing the upper bound on the branching variable. Nag_Branch_Right solve the ‘right’ node first, i.e., that which was formed by increasing the lower bound on the branching variable. Nag_Branch_InitX branch according to the initial values of the integer variables, as supplied in the argument x to nag_ip_bb (h02bbc). Let ${x}^{0}$ be the initial solution as supplied by you, and let $i$ be the index of the integer variable currently being branched on. Then if ${z}_{i}^{0}$ is the nearest integer to ${x}_{i}^{0}$ which satisfies the initial bounds on $x$, nag_ip_bb (h02bbc) will first branch towards ${z}_{i}^{0}$ and solve this sub-problem. This value of ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}$ would be appropriate, in conjunction with a deep search (as defined by ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}$), if you can provide in x a good estimate of an integer solution to the IP problem.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{branch_dir}}=\mathrm{Nag_Branch_Left}$, $\mathrm{Nag_Branch_Right}$ or $\mathrm{Nag_Branch_InitX}$.
 priority – double Default $\text{}=\text{}$ NULL
On entry: if ${\mathbf{options}}\mathbf{.}{\mathbf{varsel}}=\mathrm{Nag_Use_Priority}$ then for each integer variable ${x}_{i}$, ${\mathbf{options}}\mathbf{.}{\mathbf{priority}}\left[i-1\right]$ must contain the priority the variable should be given when nag_ip_bb (h02bbc) selects a variable to branch on (${x}_{\mathit{i}}$ is an integer variable if ${\mathbf{intvar}}\left[\mathit{i}-1\right]=\mathrm{Nag_TRUE}$, for $\mathit{i}=1,2,\dots ,n$). For example, if ${x}_{k}$ and ${x}_{l}$ are integer variables and ${\mathbf{options}}\mathbf{.}{\mathbf{priority}}\left[l-1\right]>{\mathbf{options}}\mathbf{.}{\mathbf{priority}}\left[k-1\right]$, then variable ${x}_{l}$ will be selected in preference to ${x}_{k}$. Variables with equal priorities are selected according to their indices (i.e., ${x}_{k}$ is selected if $k and ${\mathbf{options}}\mathbf{.}{\mathbf{priority}}\left[k-1\right]={\mathbf{options}}\mathbf{.}{\mathbf{priority}}\left[l-1\right]$).
With some problems of type MILP, setting ${\mathbf{options}}\mathbf{.}{\mathbf{priority}}$ to cvec might be effective, since the objective coefficient of a variable could be regarded as a measure of the importance of the variable in the problem.
If ${x}_{i}$ is not an integer variable (i.e., ${\mathbf{intvar}}\left[i-1\right]=\mathrm{Nag_FALSE}$), ${\mathbf{options}}\mathbf{.}{\mathbf{priority}}\left[i-1\right]$ is not referenced. If optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{varsel}}\ne \mathrm{Nag_Use_Priority}$ then ${\mathbf{options}}\mathbf{.}{\mathbf{priority}}$ is not referenced.
 feas_tol – double Default $\text{}=\sqrt{\epsilon }$
On entry: the maximum acceptable absolute violation in each constraint at a ‘feasible’ point (feasibility tolerance); i.e., a constraint is considered satisfied if its violation does not exceed ${\mathbf{options}}\mathbf{.}{\mathbf{feas_tol}}$.
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{feas_tol}}>0.0$.
 inf_bound – double Default $\text{}={10}^{20}$
On entry: ${\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$ defines the ‘infinite’ bound in the definition of the problem constraints. Any upper bound greater than or equal to ${\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$ will be regarded as $+\infty$ (and similarly any lower bound less than or equal to $-{\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$ will be regarded as $-\infty$).
Constraint: ${\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}>0.0$.
 rank_tol – double Default $\text{}=100\epsilon$
This argument is not used for problems of type MILP.
On entry: ${\mathbf{options}}\mathbf{.}{\mathbf{rank_tol}}$ enables you to control the condition number of the triangular matrix factor $R$ which arises in solving a QP subproblem (see Section 11 in nag_opt_qp (e04nfc) for details). If ${\rho }_{i}$ denotes the function ${\rho }_{i}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left\{\left|{R}_{11}\right|,\left|{R}_{22}\right|,\dots ,\left|{R}_{ii}\right|\right\}$, the dimension of $R$ is defined to be smallest index $i$ such that $\left|{R}_{i+1,i+1}\right|\le {\mathbf{options}}\mathbf{.}{\mathbf{rank_tol}}×\left|{\rho }_{i+1}\right|$.
Constraint: $0.0\le {\mathbf{options}}\mathbf{.}{\mathbf{rank_tol}}<1.0$.
 hrows – Integer Default $\text{}=0$ or n
On entry: specifies ${n}_{H}$, the number of rows of the quadratic term $H$ of the QP objective function. For the default MILP problem type, ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$ is not used and its value is set to zero. For MIQP problem types, the default value of ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$ is n, the number of variables. However, a value of ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$ less than n is appropriate for problems of type MIQP3 or MIQP4 when $H$ is an upper trapezoidal matrix with ${n}_{H}$ rows. Similarly, ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$ may be used to define the dimension of a leading block of nonzeros in the Hessian matrices for problems of type MIQP1 or MIQP2, in which case the last ${\mathbf{n}}-{n}_{H}$ rows and columns of $H$ are assumed to be zero.
Constraint: $0\le {\mathbf{options}}\mathbf{.}{\mathbf{hrows}}\le {\mathbf{n}}$.
 max_df – Integer Default $\text{}={\mathbf{n}}$
On entry: places a limit on the storage allocated for the triangular factor $R$ of the reduced Hessian ${H}_{r}$ of QP sub-problems (see Section 11 in nag_opt_qp (e04nfc) for details). Ideally, ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$ should be set slightly larger than the value of ${n}_{r}$ (the number of rows and columns of ${H}_{r}$) expected at the solution. It need not be larger than ${m}_{n}+1$, where ${m}_{n}$ is the number of variables that appear nonlinearly in the quadratic objective function. For many problems it can be much smaller than ${m}_{n}$.
For quadratic problems, a minimizer may lie on any number of constraints, so that ${n}_{r}$ may vary between $1$ and $n$. The default value is therefore normally n but if the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$ is specified then the default value of ${\mathbf{options}}\mathbf{.}{\mathbf{max_df}}$ is set to the value in ${\mathbf{options}}\mathbf{.}{\mathbf{hrows}}$.
Constraint: $1\le {\mathbf{options}}\mathbf{.}{\mathbf{max_df}}\le {\mathbf{n}}$.
 crnames – char ** Default $\text{}=\text{}$ NULL
On entry: if ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$ is not NULL then it must point to an array of ${\mathbf{n}}+{\mathbf{m}}$ character strings, with maximum string length 8, containing the names of the variables and constraints of the problem. Thus, ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[j-1\right]$ contains the name of the $j$th variable, $j=1,2,\dots ,{\mathbf{n}}$, and ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[{\mathbf{n}}+i-1\right]$ contains the names of the $i$th constraint, $i=1,2,\dots ,{\mathbf{m}}$. If supplied, the names are used in the solution output (see Section 5.1 and Section 10.3).
If a problem is defined by an MPSX file, it may be read by calling nag_ip_mps_read (h02buc) prior to calling nag_ip_bb (h02bbc). In this case, nag_ip_mps_read (h02buc) may optionally be used to allocate memory to ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$ and to read the variable and constraint names defined in the MPSX file into ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$. In this case, the memory freeing function nag_ip_free (h02xzc) should be used to free the memory pointed to by ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$ on return from nag_ip_bb (h02bbc). You should not use the standard C function free() for this purpose.
 lower – double Default $\text{}={\mathbf{n}}+{\mathbf{m}}$
On entry: ${\mathbf{n}}+{\mathbf{m}}$ values of memory will be automatically allocated by nag_ip_bb (h02bbc) and this is the recommended method of use of ${\mathbf{options}}\mathbf{.}{\mathbf{lower}}$. However you may supply memory from the calling program.
On exit: the lower bounds imposed at the point returned in x. If no IP solution was found ${\mathbf{options}}\mathbf{.}{\mathbf{lower}}$ contains the same bounds as supplied in bl. The first n elements contain the lower bounds on the variables, and the next m elements contain the lower bounds for the general linear constraints (if any).
 upper – double Default $\text{}={\mathbf{n}}+{\mathbf{m}}$
On entry: ${\mathbf{n}}+{\mathbf{m}}$ values of memory will be automatically allocated by nag_ip_bb (h02bbc) and this is the recommended method of use of ${\mathbf{options}}\mathbf{.}{\mathbf{upper}}$. However you may supply memory from the calling program.
On exit: the upper bounds imposed at the point returned in x. If no IP solution was found ${\mathbf{options}}\mathbf{.}{\mathbf{upper}}$ contains the same bounds as supplied in bu. The first n elements contain the upper bounds on the variables, and the next m elements contain the upper bounds for the general linear constraints (if any).
 state – Integer Default $\text{}={\mathbf{n}}+{\mathbf{m}}$
On entry: ${\mathbf{n}}+{\mathbf{m}}$ values of memory will be automatically allocated by nag_ip_bb (h02bbc) and this is the recommended method of use of ${\mathbf{options}}\mathbf{.}{\mathbf{state}}$. However you may supply memory from the calling program.
On exit: the status of the constraints in the working set at the point returned in x. The significance of each possible value of ${\mathbf{options}}\mathbf{.}{\mathbf{state}}\left[j\right]$ is as follows:
 ${\mathbf{options}}\mathbf{.}{\mathbf{state}}\left[j\right]$ Meaning $-2$ The constraint violates its lower bound by more than the feasibility tolerance. $-1$ The constraint violates its upper bound by more than the feasibility tolerance. $\phantom{-}0$ The constraint is satisfied to within the feasibility tolerance, but is not in the working set. $\phantom{-}1$ This inequality constraint is included in the working set at its lower bound. $\phantom{-}2$ This inequality constraint is included in the working set at its upper bound. $\phantom{-}3$ This constraint is included in the working set as an equality. This value of ${\mathbf{options}}\mathbf{.}{\mathbf{state}}$ can occur only when ${\mathbf{bl}}\left[j\right]={\mathbf{bu}}\left[j\right]$. $\phantom{-}4$ This corresponds to optimality being declared with ${\mathbf{x}}\left[j\right]$ being temporarily fixed at its current value. This value of ${\mathbf{options}}\mathbf{.}{\mathbf{state}}$ can only occur if the optimal solution is not unique.
 lambda – double Default $\text{}={\mathbf{n}}+{\mathbf{m}}$
On entry: ${\mathbf{n}}+{\mathbf{m}}$ values of memory will be automatically allocated by nag_ip_bb (h02bbc) and this is the recommended method of use of ${\mathbf{options}}\mathbf{.}{\mathbf{lambda}}$. However you may supply memory from the calling program.
On exit: the values of the Lagrange multipliers for each constraint with respect to the current working set at the point returned in x. The first n elements contain the multipliers (reduced costs) for the bound constraints on the variables, and the next m elements contain the multipliers (shadow costs) for the general linear constraints (if any). If ${\mathbf{options}}\mathbf{.}{\mathbf{state}}\left[j\right]=0$, ${\mathbf{options}}\mathbf{.}{\mathbf{lambda}}\left[j\right]$ is zero. If $x$ is optimal, ${\mathbf{options}}\mathbf{.}{\mathbf{lambda}}\left[j\right]$ should be non-negative if ${\mathbf{options}}\mathbf{.}{\mathbf{state}}\left[j\right]=1$, non-positive if ${\mathbf{options}}\mathbf{.}{\mathbf{state}}\left[j\right]=2$ and zero if ${\mathbf{options}}\mathbf{.}{\mathbf{state}}\left[j\right]=4$.

### 10.3  Description of Printed Output

The level of printed output can be controlled with the structure members ${\mathbf{options}}\mathbf{.}{\mathbf{list}}$ and ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}$ (see Section 10.2).
If ${\mathbf{options}}\mathbf{.}{\mathbf{list}}=\mathrm{Nag_TRUE}$ then the argument values to nag_ip_bb (h02bbc) are listed, whereas the printout of results is governed by the value of ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}$. The default of ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Soln_Iter}$ provides intermediate and final results.
If ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Iter}$, $\mathrm{Nag_Soln_Iter}$ or $\mathrm{Nag_Soln_Root_Iter}$, the following line of summary output is produced at the end of every node. It gives the outcome of forcing an integer variable with a non-integer value to take a value within its specified lower and upper bounds.
 Node No is the current node number of the BB tree being investigated. Parent Node is the parent node number of the current node. Obj Value is the final objective function value. If a node does not have a feasible solution then Infeasible is printed instead of the objective function value. If a node whose optimum solution exceeds the best integer solution so far is encountered (i.e., it does not pay to explore the sub-problem any further), then its objective function value is printed together with a CO (Cut Off). Varbl Chosen is the index of the integer variable chosen for branching. Value Before is the non-integer value of the integer variable chosen. Lower Bound is the lower bound value that the integer variable is allowed to take. Upper Bound is the upper bound value that the integer variable is allowed to take. Value After is the value of the integer variable after the current optimization. Depth is the depth of the BB tree at the current node.
If ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Soln_Root}$ or $\mathrm{Nag_Soln_Root_Iter}$, the root node solution is output before the BB search is commenced. If ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Soln}$, $\mathrm{Nag_Soln_Iter}$, $\mathrm{Nag_Soln_Root}$ or $\mathrm{Nag_Soln_Root_Iter}$ the final IP solution or, if none was found, the root node solution is output.
The following describes the printout for each variable and constraint for both root node and final IP solution printout.
 Varbl gives the name of variable $\mathit{j}$, for $\mathit{j}=1,2,\dots ,n$. If an options structure is supplied to nag_ip_bb (h02bbc), and the ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$ member is assigned to an array of variable and constraint names (see Section 10.2 for details), the name supplied in ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[j-1\right]$ is assigned to the $j$th variable. Otherwise, a default name is assigned to the variable. State gives the state of the variable (FR if neither bound is in the working set, EQ if a fixed variable, LL if on its lower bound, UL if on its upper bound, TF if temporarily fixed at its current value). If Value lies outside the upper or lower bounds by more than the feasibility tolerance, State will be ++ or -- respectively. Value is the value of the variable at the final iteration. Lower Bound is the lower bound ${l}_{j}$ specified for the variable. (None indicates that ${l}_{j}\le -{\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$, where ${\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$ is the optional argument.) For root node printout, ${l}_{j}={\mathbf{bl}}\left[j-1\right]$; for IP solution printout, ${l}_{j}$ is the lower bound imposed at the node which provided the IP solution. Upper Bound is the upper bound ${u}_{j}$ specified for the variable. (None indicates that ${u}_{j}\ge {\mathbf{options}}\mathbf{.}{\mathbf{inf_bound}}$.) For root node printout, ${u}_{j}={\mathbf{bu}}\left[j-1\right]$; for IP solution printout, ${u}_{j}$ is the upper bound imposed at the node which provided the IP solution. Lagr Mult is the value of the Lagrange multiplier for the associated bound constraint. This will be zero if State is FR or TF. If $x$ is optimal, the multiplier should be non-negative if State is LL, and non-positive if State is UL. Residual is the difference between the variable Value and the nearer of its bounds ${l}_{j}$ and ${u}_{j}$.
The meaning of the printout for general constraints is the same as that given above for variables, with ‘variable’ replaced by ‘constraint’, $n$ replaced by $m$, ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[j-1\right]$ replaced by ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[n+j-1\right]$, ${l}_{j}$ and ${u}_{j}$ replaced by ${l}_{n+i}$ and ${u}_{n+i}$ respectively, and with the following change in the heading:
 Constr gives the name of constraint $i$, $i=1,2,\dots ,m$. If an options structure is supplied to nag_ip_bb (h02bbc), and the ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}$ member is assigned to an array of variable and constraint names (see Section 10.2 for details), the name supplied in ${\mathbf{options}}\mathbf{.}{\mathbf{crnames}}\left[n+i-1\right]$ is assigned to the constraint. Otherwise, a default name is assigned to the constraint.
Numerical values are output with a fixed number of digits; they are not guaranteed to be accurate to this precision.
If ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_NoPrint}$ then printout will be suppressed; you can print the final solution when nag_ip_bb (h02bbc) returns to the calling program.

#### 10.3.1  Output of results via a user-defined printing function

You may also specify your own print function for output of iteration results and the final solution by use of the ${\mathbf{options}}\mathbf{.}{\mathbf{print_fun}}$ function pointer, which has prototype
```void (*print_fun)(const Nag_Search_State *st, Nag_Comm *comm);
```
This section may be skipped if you wish to use the default printing facilities.
When a user-defined function is assigned to ${\mathbf{options}}\mathbf{.}{\mathbf{print_fun}}$ this will be called in preference to the internal print function of nag_ip_bb (h02bbc). Calls to the user-defined function are again controlled by means of the ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}$ member. Information is provided through st and comm, the two structure arguments to ${\mathbf{options}}\mathbf{.}{\mathbf{print_fun}}$.
If $\mathbf{comm}\mathbf{\to }\mathbf{node_prt}=\mathrm{Nag_TRUE}$ then the results from the most recently solved node are provided through st. Note that ${\mathbf{options}}\mathbf{.}{\mathbf{print_fun}}$ will be called with $\mathbf{comm}\mathbf{\to }\mathbf{node_prt}=\mathrm{Nag_TRUE}$ only if ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Iter}$, $\mathrm{Nag_Soln_Iter}$ or $\mathrm{Nag_Soln_Root_Iter}$. The following members of st are set:
node_numInteger
The current node number of the BB tree being investigated.
parent_nodeInteger
The parent node number of the current node.
node_statusNag_NodeStatus
The status of the current node. The possible values of $\mathbf{st}\mathbf{\to }\mathbf{node_status}$ and their meanings are as follows:
 Nag_NS_NotBranched the node has been solved but the branch cannot yet be eliminated from the search. Nag_NS_Integer an integer solution was found at this node. There is no need to search this branch further. Nag_NS_Bounded the objective value exceeds the upper bound on the optimal IP solution. There is no need to search this branch further. Nag_NS_Infeasible the problem was infeasible at this node. There is no need to search this branch further. Nag_NS_Terminated the iteration limit was exceeded at this node. The search has to be terminated prematurely for this branch.
objfdouble
If $\mathbf{st}\mathbf{\to }\mathbf{node_status}=\mathbf{Nag_NS_NotBranched}\text{, ​}\mathbf{Nag_NS_Integer}\text{​ or ​}\mathbf{Nag_NS_Bounded}$, then objf holds the objective value.
branch_indexInteger
The index in $x$ of the variable chosen for branching.
x_lodouble
The lower bound on the branching variable.
x_updouble
The upper bound on the branching variable.
x_beforedouble
The non-integer value of the branching variable before the node was solved.
x_afterdouble
The value of the branching variable after the node was solved.
depthInteger
The depth of the BB tree at the current node.
If $\mathbf{comm}\mathbf{\to }\mathbf{rootnode_sol_prt}=\mathrm{Nag_TRUE}$ then the solution of the root node is provided through st. Note that ${\mathbf{options}}\mathbf{.}{\mathbf{print_fun}}$ will be called with $\mathbf{comm}\mathbf{\to }\mathbf{rootnode_sol_prt}=\mathrm{Nag_TRUE}$ only if ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Soln_Root}$ or $\mathrm{Nag_Soln_Root_Iter}$. The following members of st are set:
endstateNag_EndState
The state of termination of the sub-problem solver at the root node. Some of these states result in immediate termination of the algorithm. If this is the case, then no valid solution is available. The other states allow the algorithm to proceed with the BB tree search. Possible values of $\mathbf{st}\mathbf{\to }\mathbf{endstate}$ and their correspondence, if any, to the exit value of fail from nag_ip_bb (h02bbc) are:
 Value of $\mathbf{st}\mathbf{\to }\mathbf{endstate}$ Value of fail Nag_Optimal (BB search may proceed) Nag_Deadpoint (BB search may proceed) Nag_Weakmin (BB search may proceed) Nag_Unbounded NE_MIP_ROOT_UNBOUNDED Nag_Infeasible NE_MIP_ROOT_INFEAS Nag_Too_Many_Iter NE_MIP_ROOT_MAX_ITER Nag_Hess_Too_Big NE_MIP_ROOT_HESS_TOO_BIG
nInteger
The number of variables.
mInteger
The number of linear constraints.
objfdouble
The value of the objective function.
xdouble
The components ${\mathbf{x}}\left[\mathit{j}-1\right]$ of the solution $x$, for $\mathit{j}=1,2,\dots ,\mathbf{st}\mathbf{\to }\mathbf{n}$.
axdouble
If $\mathbf{st}\mathbf{\to }\mathbf{m}>0$, $\mathbf{st}\mathbf{\to }\mathbf{ax}\left[\mathit{j}-1\right]$ contains the components of the linear constraint vector, for $\mathit{j}=1,2,\dots ,\mathbf{st}\mathbf{\to }\mathbf{m}$.
stateInteger
Contains the status of the $\mathbf{st}\mathbf{\to }\mathbf{n}$ variables and $\mathbf{st}\mathbf{\to }\mathbf{m}$ general linear constraints. See Section 10.2 for a description of the possible status values.
Contains the $\mathbf{st}\mathbf{\to }\mathbf{n}+\mathbf{st}\mathbf{\to }\mathbf{m}$ values of the Lagrange multipliers.
bldouble
Contains the $\mathbf{st}\mathbf{\to }\mathbf{n}+\mathbf{st}\mathbf{\to }\mathbf{m}$ lower bounds on the variables.
budouble
Contains the $\mathbf{st}\mathbf{\to }\mathbf{n}+\mathbf{st}\mathbf{\to }\mathbf{m}$ upper bounds on the variables.
If $\mathbf{comm}\mathbf{\to }\mathbf{sol_prt}=\mathrm{Nag_TRUE}$ then the final IP solution is provided through st. Note that ${\mathbf{options}}\mathbf{.}{\mathbf{print_fun}}$ will be called with $\mathbf{comm}\mathbf{\to }\mathbf{sol_prt}=\mathrm{Nag_TRUE}$ only if ${\mathbf{options}}\mathbf{.}{\mathbf{print_level}}=\mathrm{Nag_Soln}$, $\mathrm{Nag_Soln_Root}$, $\mathrm{Nag_Soln_Iter}$ or $\mathrm{Nag_Soln_Root_Iter}$. If no IP solution was found then the root node solution is available. The $\mathbf{st}\mathbf{\to }\mathbf{endstate}$ member of st should be examined to determine the status of the solution. The following members of st are set:
endstateNag_EndState
The state of termination of nag_ip_bb (h02bbc). Possible values of $\mathbf{st}\mathbf{\to }\mathbf{endstate}$ and their correspondence to the exit value of fail are shown below.
 Value of $\mathbf{st}\mathbf{\to }\mathbf{endstate}$ Value of fail Nag_MIP_Best_ISol or Nag_MIP_Stop_First_ISol NE_NOERROR Nag_MIP_No_ISol NW_MIP_NO_INT_SOL Nag_MIP_Root_Unbounded NE_MIP_ROOT_UNBOUNDED Nag_MIP_Root_Infeasible NE_MIP_ROOT_INFEAS Nag_MIP_Root_Max_Itn NE_MIP_ROOT_MAX_ITER Nag_MIP_Root_Big_Hess NE_MIP_ROOT_HESS_TOO_BIG Nag_MIP_Max_Itn_ISol NW_MIP_MAX_ITER_INT_SOL Nag_MIP_Max_Itn_No_ISol NW_MIP_MAX_ITER_NO_INT_SOL Nag_MIP_Big_Hess_ISol NE_MIP_HESS_TOO_BIG_INT_SOL Nag_MIP_Big_Hess_No_ISol NE_MIP_HESS_TOO_BIG_NO_INT_SOL Nag_MIP_Max_Nodes_ISol NW_MIP_MAX_NODES_INT_SOL Nag_MIP_Max_Nodes_No_ISol NW_MIP_MAX_NODES_NO_INT_SOL Nag_MIP_Max_Depth_ISol NW_MIP_MAX_DEPTH_INT_SOL Nag_MIP_Max_Depth_No_ISol NW_MIP_MAX_DEPTH_NO_INT_SOL
nInteger
The number of variables.
mInteger
The number of linear constraints.
nnodesInteger
The number of nodes examined during the BB tree search.
objfdouble
The value of the objective function.
xdouble
The components ${\mathbf{x}}\left[\mathit{j}-1\right]$ of the solution $x$, for $\mathit{j}=1,2,\dots ,\mathbf{st}\mathbf{\to }\mathbf{n}$.
axdouble
If $\mathbf{st}\mathbf{\to }\mathbf{m}>0$, $\mathbf{st}\mathbf{\to }\mathbf{ax}\left[\mathit{j}-1\right]$ contains the components of the linear constraint vector, for $\mathit{j}=1,2,\dots ,\mathbf{st}\mathbf{\to }\mathbf{m}$.
stateInteger
Contains the status of the $\mathbf{st}\mathbf{\to }\mathbf{n}$ variables and $\mathbf{st}\mathbf{\to }\mathbf{m}$ general linear constraints. See Section 10.2 for a description of the possible status values.
Contains the $\mathbf{st}\mathbf{\to }\mathbf{n}+\mathbf{st}\mathbf{\to }\mathbf{m}$ values of the Lagrange multipliers.
bldouble
Contains the $\mathbf{st}\mathbf{\to }\mathbf{n}+\mathbf{st}\mathbf{\to }\mathbf{m}$ lower bounds on the variables.
budouble
Contains the $\mathbf{st}\mathbf{\to }\mathbf{n}+\mathbf{st}\mathbf{\to }\mathbf{m}$ upper bounds on the variables.
The relevant members of the structure comm are:
rootnode_sol_prtNag_Boolean
Will be Nag_TRUE when the print function is called with the solution of the root node.
node_prtNag_Boolean
Will be Nag_TRUE when the print function is called with the result of the most recently solved node.
sol_prtNag_Boolean
Will be Nag_TRUE when the print function is called with the final solution.
userdouble
iuserInteger
pPointer
Pointers for communication of user information. If used they must be allocated memory either before entry to nag_ip_bb (h02bbc) or during a call to qphess or ${\mathbf{options}}\mathbf{.}{\mathbf{print_fun}}$. The type Pointer will be void * with a C compiler that defines void * and char * otherwise.

## 11  Further Description

This section provides further information about the BB algorithm used by nag_ip_bb (h02bbc).
Further descriptions of the BB algorithm may be found in Dakin (1965) and Mitra (1973).

### 11.1  Overview

As outlined in Section 3, the essence of the BB algorithm is to form a ‘tree’ of sub-problems which are relatively easy to solve. The initial sub-problem, the root node of the tree, is a relaxation of the IP problem, in that it is the IP problem with the integer restrictions removed. When that has been solved, two child sub-problems or nodes are formed by selecting an integer variable ${x}_{k}$ which in the solution to the relaxed problem takes a non-integer value ${x}_{k}^{*}$, and branching on that variable, i.e., imposing ${x}_{k}\le \left[{x}_{k}^{*}\right]$ for one node and ${x}_{k}\ge \left[{x}_{k}^{*}\right]+1$ for the other, where $\left[{x}_{k}^{*}\right]$ denotes the integer part of ${x}_{k}^{*}$. One of these nodes is then solved. At this point, either a further branching operation is carried out from the node just solved, creating two new unsolved nodes (one of which is solved next), or the remaining unsolved child node is solved. Continuing in this way, the tree is developed – at each stage selecting an unsolved node to solve, or a solved node to branch from. The selection of the node and, in the case of a branching operation, the selection of the variable to branch on, is considered further in Section 11.2.
The mechanism for forming the nodes on branching simply involves adjusting the lower or upper bound on the branching variable. Note that as the tree is descended, each child node inherits any bound adjustments made to its parent node, and so a child node is always more constrained than its parent.
If the procedure described above is continued, eventually a child must be created for which all of its integer variables are fixed at integer values, or which is infeasible. If the latter is true then the search down that branch of the tree may be terminated since any children of that node must also be infeasible (the child is always more constrained than the parent). If the former is true then we have an integer feasible solution for the IP problem, which may or may not be the optimum integer solution. For some applications of IP, it is sufficient to obtain any integer feasible solution and the search may terminate here, but usually the search must be continued, either to find a better integer solution, or to confirm that the optimal integer solution has been found. In nag_ip_bb (h02bbc) the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{first_soln}}$ may be set to Nag_TRUE to request termination at the first integer solution (the default value is Nag_FALSE; see Section 10.2).
Assuming that the optimal integer solution is required, the rest of the tree must be searched. The efficiency of the method relies on not having to examine every node of the tree which could, potentially, be formed by applying the procedure as described above. The method incorporates features which have the effect of eliminating certain portions of the tree from the search. As already explained, the search is terminated along a particular branch on encountering an infeasible node. Similarly, once an integer solution has been found, this can be used to eliminate parts of the search tree as follows. Suppose an integer feasible solution ${x}^{+}$ has been found, with an associated objective function value $f\left({x}^{+}\right)$. Now suppose during the search of the remainder of the tree, a node is encountered, whose objective function value exceeds $f\left({x}^{+}\right)$. In this case there is no need to examine any further down that branch of the tree since any children of that node will also have objective function values which exceed $f\left({x}^{+}\right)$. The quantity $f\left({x}^{+}\right)$ therefore acts as a bound on the optimal integer solution. This bound may be refined as better integer solutions are found. Finally, if an integer solution is found before all integer variables have been fixed by the branching process, simply because the unfixed integer variables happen to have integer values at the solution of a particular node, there is again no need to search further along that branch of the tree. Termination of the search at a node, whether through finding an integer solution there, detecting infeasibility, or bounding it based on a known integer solution, is known as fathoming the node.

### 11.2  Selection of Node and Branching Variable

Since each branching operation generates two unsolved nodes (sub-problems), at a typical stage of the algorithm there will be a number of nodes which are either unsolved or which have been solved but have not yet been branched from. Therefore, when a node has been solved there is a choice to be made as to which node should be solved next, and this will either be an existing, unsolved node, or one which will be created by a branching operation.
If a node is selected to be branched from, there is a further choice to be made and that is the integer variable to be branched on.
Within nag_ip_bb (h02bbc) these choices are controlled by the optional arguments ${\mathbf{options}}\mathbf{.}{\mathbf{nodsel}}$, which controls node selection, and ${\mathbf{options}}\mathbf{.}{\mathbf{varsel}}$, which controls branching variable selection. The default node selection behaviour is to choose the node with lowest objective value, if it has been solved, or lowest parent objective value if it is unsolved. By default the branching variable chosen is that with the smallest index in $x$, selected from those integer variables taking non-integer values at the solution of the sub-problem being branched from. Details of the available options are given in Section 10.2.
These choices can help to improve the efficiency of the BB algorithm since they particularly influence how quickly the first integer feasible solution is obtained and its quality. A good integer solution obtained early in the search can eliminate a large portion of the remaining tree, by means of the bounding operation described in Section 11.1). Unfortunately, there is no single strategy for making such choices which can be applied successfully to all IP problems – the best strategy is highly problem dependent and is usually obtained by experimentation.

### 11.3  Further Reducing the Size of the BB Search Tree

In addition to considering variations in the node and variable selection strategies, you may also consider setting some other arguments to help to reduce the number of nodes searched. Recall from Section 11.1) that once the algorithm has found an IP solution, the objective function value associated with this is used as a bound to eliminate parts of the tree. Similarly, if you know from the outset a strict upper bound on the optimal solution, perhaps as a result of solving a related, more constrained problem, or obtained through analytical means, this may be supplied to nag_ip_bb (h02bbc) as the optional argument ${\mathbf{options}}\mathbf{.}{\mathbf{int_obj_bound}}$. This will be used by nag_ip_bb (h02bbc) in the same way as a bound obtained by finding an IP solution except that it can be used to eliminate parts of the tree even before an integer solution is found.
Another argument which you might consider setting to reduce the size of the tree is ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$. Again this is related to the bounding process, and applies when an integer solution has been found. When searching the remainder of the tree, instead of setting the bound to $f\left({x}^{+}\right)$, the objective function value associated with the integer solution most recently found, nag_ip_bb (h02bbc) sets the bound to $f\left({x}^{+}\right)-{\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$. This means that integer solutions with objective values within ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$ of any integer solution already found, cannot themselves be found. The idea here is to allow you to avoid further search for solutions which are not substantially better (as measured by ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$) than the best solution found so far. Of course, a sensible choice for the value of ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$ relies on your knowledge of the problem and requirements on the solution.
Further details of the optional arguments ${\mathbf{options}}\mathbf{.}{\mathbf{int_obj_bound}}$ and ${\mathbf{options}}\mathbf{.}{\mathbf{soln_tol}}$ are given in Section 10.2.
Finally, a very important factor which can have a large impact on the size of the search tree is the way the problem is modelled. Often, there is more than one way to formulate a problem as an IP model. A general aim is that the feasible region of the relaxed IP problem should be as close as possible to that of the IP problem itself. This has the effect of generating tight bounds in the BB procedure. Note that in order to achieve this aim, it may be necessary to introduce further constraints, which do not alter the IP solution but which help to reduce the feasible region of the sub-problems. This is in contrast to standard LP, for example, in which fewer constraints are generally considered to be associated with an easier problem. There is of course a balance to be struck since adding constraints to an IP problem will make the sub-problems harder to solve, despite, it is hoped, reducing the size of the tree. See Williams (1993) for more information on formulating IP models.