# NAG FL InterfaceH (Mip)Operations Research

## 1Scope of the Chapter

This chapter provides routines to solve certain integer programming, transportation and shortest path problems. Additionally ‘best subset’ routines are included.

## 2Background to the Problems

General linear programming (LP) problems (see Dantzig (1963)) are of the form:
• find $x={\left({x}_{1},{x}_{2},\dots ,{x}_{n}\right)}^{\mathrm{T}}$ to maximize $F\left(x\right)=\sum _{j=1}^{n}{c}_{j}{x}_{j}$
• subject to linear constraints which may have the forms:
 $∑j=1naijxj=bi, i=1,2,…,m1 (equality) ∑j=1naijxj≤bi, i=m1+1,…,m2 (inequality) ∑j=1naijxj≥bi, i=m2+1,…,m (inequality) xj≥lj, j=1,2,…,n (simple bound) xj≤uj, j=1,2,…,n (simple bound)$
This chapter deals with integer programming (IP) problems in which some or all the elements of the solution vector $x$ are further constrained to be integers. For general LP problems where $x$ takes only real (i.e., noninteger) values, refer to Chapter E04.
IP problems may or may not have a solution, which may or may not be unique.
Consider for example the following problem:
 $minimize 3x1 + 2x2 subject to 4x1 + 2x2≥5 2x2≤5 0x1 - 0x2≤2 and 0x1 ≥ 0,x2≥0.$
The hatched area in Figure 1 is the feasible region, the region where all the constraints are satisfied, and the points within it which have integer coordinates are circled. The lines of hatching are in fact contours of decreasing values of the objective function $3{x}_{1}+2{x}_{2}$, and it is clear from Figure 1 that the optimum IP solution is at the point $\left(1,1\right)$. For this problem the solution is unique.
However, there are other possible situations.
1. (a)There may be more than one solution; e.g., if the objective function in the above problem were changed to ${x}_{1}+{x}_{2}$, both $\left(1,1\right)$ and $\left(2,0\right)$ would be IP solutions.
2. (b)The feasible region may contain no points with integer coordinates, e.g., if an additional constraint
 $3x1≤2$
were added to the above problem.
3. (c)There may be no feasible region, e.g., if an additional constraint
 $x1+x2≤ 1$
were added to the above problem.
4. (d)The objective function may have no finite minimum within the feasible region; this means that the feasible region is unbounded in the direction of decreasing values of the objective function, e.g., if the constraints
 $4x1+2x2≥5, x1≥0, x2≥0,$
were deleted from the above problem. Figure 1
Algorithms for IP problems are usually based on algorithms for general LP problems, together with some procedure for constructing additional constraints which exclude noninteger solutions (see Beale (1977)).
The Branch and Bound (B&B) method is a well-known and widely used technique for solving IP problems (see Beale (1977) or Mitra (1973)). It involves subdividing the optimum solution to the original LP problem into two mutually exclusive sub-problems by branching an integer variable that currently has a fractional optimal value. Each sub-problem can now be solved as an LP problem, using the objective function of the original problem. The process of branching continues until a solution for one of the sub-problems is feasible with respect to the integer problem. In order to prove the optimality of this solution, the rest of the sub-problems in the B&B tree must also be solved. Naturally, if a better integer feasible solution is found for any sub-problem, it should replace the one at hand.
A common method for specifying IP and LP problems in general is the use of the MPSX file format (see IBM (1971)). A full description of this file format is provided in the routine document for h02buf.
The efficiency in computations is enhanced by discarding inferior sub-problems. These are problems in the B&B search tree whose LP solutions are lower than (in the case of maximization) the best integer solution at hand.
The B&B method may also be applied to convex quadratic programming (QP) problems and nonlinear programming (NLP) problems using sequential convex QP approximations.
Routines have been introduced into this chapter to formally apply the technique to dense general QP problems and to sparse LP, QP or NLP problems. Section 2.6 in the E04 Chapter Introduction describes the virtues of having a well-scaled problem. The imposition that a variable be integer makes this more difficult and some practical common sense might be required to make the problem tractable. If a variable is expected to have a large value at the minimum, say $100000$ for instance, then in practical terms it might be better to forget the integer constraint and simply round off the final answer. To do otherwise forces a high level of computation accuracy on the underlying optimiser that might be impossible to achieve.
A special type of linear programming problem is the transportation problem in which there are $p×q$ variables ${y}_{kl}$ which represent quantities of goods to be transported from each of $p$ sources to each of $q$ destinations.
The problem is to minimize
 $∑k=1p∑l=1qcklykl$
where ${c}_{kl}$ is the unit cost of transporting from source $k$ to destination $l$. The constraints are:
 $∑l=1qykl=Ak availabilities ∑k=1pykl=Bl requirements ykl≥0.$
Note that the availabilities must equal the requirements:
 $∑k= 1pAk=∑l= 1qBl=∑k= 1p∑l= 1qykl$
and if all the ${A}_{k}$ and ${B}_{l}$ are integers, then so are the optimal ${y}_{kl}$.
The shortest path problem is that of finding a path of minimum length between two distinct vertices ${n}_{s}$ and ${n}_{e}$ through a network. Suppose the vertices in the network are labelled by the integers $1,2,\dots ,n$. Let $\left(i,j\right)$ denote an ordered pair of vertices in the network (where $i$ is the origin vertex and $j$ the destination vertex of the arc), ${x}_{ij}$ the amount of flow in arc $\left(i,j\right)$ and ${d}_{ij}$ the length of the arc $\left(i,j\right)$. The LP formulation of the problem is thus given as
 $minimize ∑∑dijxijsubject to ​Ax=b, 0≤x≤1,$ (1)
where
 $aij= + 1 if arc ​ j​ is directed away from vertex ​ i, -1 if arc ​ j​ is directed towards vertex ​ i, 0 otherwise$
and
 $bi= +1 for ​i=ns, -1 for ​i=ne, 0 otherwise.$
The above formulation only yields a meaningful solution if ; that is, $\mathrm{arc}\left(i,j\right)$ forms part of the shortest route only if ${x}_{ij}=1$. In fact since the optimal LP solution will (in theory) always yield , (1) can also be solved as an IP problem. Note that the problem may also be solved directly (and more efficiently) using a variant of Dijkstra's algorithm (see Ahuja et al. (1993)).
The travelling salesman problem is that of finding a minimum distance route round a given set of cities. In the classical travelling salesman problem the salesperson must visit each city only once before returning to his or her city of origin. It can be formulated as an IP problem in a number of ways. One such formulation is described in Williams (1993). Such IP problems could be solved directly by a mixed integer nonlinear programming solver; however, there are currently no routines in the Library that directly solve such IP problems. However, an acceptable solution to symmetric distance problems may be sought using the probabilistic optimization method known as simulated annealing for which a routine is available. Asymmetric problems can be tackled by the introduction of shadow cities with zero distance between an original city and its shadow. Incomplete problems, where bidirectional travel between each pair of cities is not possible, can be tackled by attributing very large distances to unavailable journeys. For example, a salesperson might not mind backtracking through a previously visited city if this produced the shortest route. This problem is known as the practical travelling salesman problem.
The best $\mathbit{n}$ subsets problem assumes a scoring mechanism and a set of $m$ features. The problem is one of choosing the best $n$ subsets of size $p$. It is addressed by two routines in this chapter. The first of these uses reverse communication; the second direct communication (see Section 7 in How to Use the NAG Library for a description of the difference between these two conventions).

## 3Recommendations on Choice and Use of Available Routines

h02bbf solves dense integer programming problems using a branch and bound method.
h02bff solves dense integer or linear programming problems defined by a MPSX data file.
h02buf converts an MPSX data file defining an integer or a linear programming problem to the form required by e04mff/​e04mfa or h02bbf.
h02bvf prints the solution to an integer or a linear programming problem using specified names for rows and columns.
h02bzf supplies further information on the optimum solution obtained by h02bbf.
h02cbf solves dense integer general quadratic programming problems.
h02ccf reads optional parameter values for h02cbf from external file.
h02cdf supplies optional parameter values to h02cbf.
h02cef solves sparse integer linear programming or quadratic programming problems.
h02cff reads optional parameter values for h02cef from external file.
h02cgf supplies optional parameter values to h02cef.
h03abf solves transportation problems. It uses integer arithmetic throughout and so produces exact results. On a few machines, however, there is a risk of integer overflow without warning, so the integer values in the data should be kept as small as possible by dividing out any common factors from the coefficients of the constraint or objective functions.
h03adf solves shortest path problems using Dijkstra's algorithm.
h03bbf is a (symmetric) classical travelling salesman problem.
h02bbf, h02bff and h03abf treat all matrices as dense and hence are not intended for large sparse problems. For solving large sparse LP problems, use e04nqf or e04ugf/​e04uga.

### 3.1Transportation Problem

h03abf solves transportation problems. It uses integer arithmetic throughout and so produces exact results. On a few machines, however, there is a risk of integer overflow without warning, so the integer values in the data should be kept as small as possible by dividing out any common factors from the coefficients of the constraint or objective functions.

### 3.2Feature Selection – Best Subset Problem

h05aaf selects the best $n$ subsets of size $p$ using a reverse communication branch and bound algorithm.
h05abf selects the best $n$ subsets of size $p$ using a direct communication branch and bound algorithm.

## 4Functionality Index

 Mixed integer linear programming (MILP),
 dense,
 branch and bound method h02bbf
 sparse,
 branch and bound method h02cef
 Mixed integer quadratic programming (MIQP),
 dense,
 branch and bound method h02cbf
 sparse,
 branch and bound method h02cef
 Mixed integer nonlinear programming (MINLP),
 dense,
 mixed integer sequential quadratic programming (MISQP) h02daf
 Operations Research (OR),
 feature selection,
 best subset of given size,
 direct communication h05abf
 reverse communication h05aaf
 shortest path through directed or undirected network h03adf
 transportation problem h03abf
 travelling salesman problem, simulated annealing h03bbf
 Service routines,
 input and output (I/O),
 print solution of a dense MILP problem h02bvf
 read MILP problem from MPS file and solve it by branch and bound h02bff
 read MPS file defining dense MILP problem h02buf
 option setting routines,
 h02cbf,
 supply optional parameter values from a character string h02cdf
 supply optional parameter values from external file h02ccf
 h02cef,
 supply optional parameter values from a character string h02cgf
 supply optional parameter values from external file h02cff
 h02daf,
 supply optional parameter values from a character string h02zkf
 retrieve optional parameter values h02zlf
 miscellaneous,
 extract further information on the solution obtained from h02bbf h02bzf

## 5Auxiliary Routines Associated with Library Routine Arguments

 h02cbu nagf_mip_iqp_dense_dummy_monitSee the description of the argument monit in h02cbf. h02cey nagf_mip_iqp_sparse_dummy_monitSee the description of the argument monit in h02cef. h02ddm nagf_mip_sqp_dummy_confunSee the description of the argument confun in h02daf.

## 6 Withdrawn or Deprecated Routines

None.
Ahuja R K, Magnanti T L and Orlin J B (1993) Network Flows: Theory, Algorithms and Applications Prentice–Hall
Beale E M (1977) Integer programming The State of the Art in Numerical Analysis (ed D A H Jacobs) Academic Press
Dantzig G B (1963) Linear Programming and Extensions Princeton University Press
IBM (1971) MPSX – Mathematical programming system Program Number 5734 XM4 IBM Trade Corporation, New York
Mitra G (1973) Investigation of some branch and bound strategies for the solution of mixed integer linear programs Math. Programming 4 155–170
Williams H P (1993) Model Building in Mathematical Programming (3rd Edition) Wiley