h Chapter Contents
h Chapter Introduction (PDF version)
NAG Library Manual

NAG Library Chapter Introduction

h – Operations Research

 Contents

1  Scope of the Chapter

This chapter provides functions to solve certain integer programming, transportation. Additionally ‘best subset’ functions are included.

2  Background to the Problems

General linear programming (LP) problems (see Dantzig (1963)) are of the form:
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 + 2x25 2x25 0x1 - 0x22 and 0x1 0,x20.  
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 3x1+2x2, and it is clear from Figure 1 that the optimum IP solution is at the point 1,1. For this problem the solution is unique.
However, there are other possible situations.
(a) There may be more than one solution; e.g., if the objective function in the above problem were changed to x1+x2, both 1,1 and 2,0 would be IP solutions.
(b) The feasible region may contain no points with integer coordinates, e.g., if an additional constraint
3x12  
were added to the above problem.
(c) There may be no feasible region, e.g., if an additional constraint
x1+x2 1  
were added to the above problem.
(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+2x25,  x10,  x20,  
were deleted from the above problem.
Figure 1
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 function document for nag_ip_mps_read (h02buc).
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.
Functions 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.5 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 ykl which represent quantities of goods to be transported from each of p sources to each of q destinations.
The problem is to minimize
k=1pl=1qcklykl  
where ckl is the unit cost of transporting from source k to destination l. The constraints are:
l=1qykl=Ak availabilities k=1pykl=Bl requirements ykl0.  
Note that the availabilities must equal the requirements:
k= 1pAk=l= 1qBl=k= 1pl= 1qykl  
and if all the Ak and Bl are integers, then so are the optimal ykl.
The best 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 functions in this chapter. The first of these uses reverse communication; the second direct communication (see Section 3.2.2 in the Essential Introduction for a description of the difference between these two conventions).

3  Recommendations on Choice and Use of Available Functions

3.1  Integer Programming

The IP function in Chapter h provides a range of optional facilities: these offer the possibility of fine control over many of the algorithmic parameters and the means of adjusting the level and nature of the printed results. The MPSX reading function also offers some optional facilities.
Control of these optional facilities is exercised by a structure of type Nag_H02_Opt, the members of the structure being optional input or output arguments to the function. After declaring the structure variable, which is named options in this manual, you must initialize the structure by passing its address in a call to the utility function nag_ip_init (h02xxc). Selected members of the structure may then be set to your required values and the address of the structure passed to the NAG function. Any member which has not been set by you will indicate to the function that the default value should be used for this argument. A more detailed description of this process is given below in Section 3.1.4.
Examples of arguments which may be altered from their default value are options.feas_tol and options.int_tol (these control the accuracy to which the constraints are satisfied in the B&B sub-problems and the accuracy of the final objective function value, respectively), and options.max_iter (which limits the number of iterations the algorithm will perform at each sub-problem). Certain members of options supply further details concerning the final results, for example on exit from the IP solver the member pointers options.state and options.lambda give the status of the constraints and the final values of the Lagrange multipliers respectively. Another use of the options structure is to allow additional information read in by the MPSX reader (such as the MPSX row and column names) to be communicated to the IP solver for use in its printout.

3.1.1  Control of Printed Output

Results from the IP solution process are printed by default on the stdout (standard output) stream. These include the results after each node of the B&B search tree and the final results at termination of the search process. The amount of detail printed out may be increased or decreased by setting the optional argument print_level, i.e., the structure member options.print_level. This member is an enum type, Nag_PrintType, and an example value is Nag_Soln which when assigned to options.print_level will cause the IP function to print only the final result; all intermediate results printout is suppressed.
If the results printout is not in the desired form then it may be switched off, by setting options.print_level=Nag_NoPrint, or alternatively you can supply your own function to printout or make use of both the intermediate and final results. Such a function would be assigned to the pointer to function member options.print_fun; the user-defined function would then be called in preference to the NAG print function.
In addition to the results, the values of the arguments to the optimization function are printed out when the function is entered; the Boolean member options.list may be set to Nag_FALSE if this listing is not required.
Printing may be output to a named file rather than to stdout by providing the name of the file in the options character array member outfile. Error messages will still appear on stderr, if fail.print=Nag_TRUE or the fail argument is supplied as NAG_DEFAULT (see Section 3.6 in the Essential Introduction for details of error handling within the library). The level of output provided by the MPSX reading function may also be controlled. In this case, control is provided by the optional argument output_level.

3.1.2  Memory Management

The options structure contains a number of pointers for the input of data and the output of results. The NAG functions will manage the allocation of memory to these pointers; when all calls to these functions have been completed then a utility function nag_ip_free (h02xzc) can be called by your program to free the NAG allocated memory which is no longer required.
If the calling function is part of a larger program then this utility function allows you to conserve memory by freeing the NAG allocated memory before the options structure goes out of scope. nag_ip_free (h02xzc) can free all NAG allocated memory in a single call, but it may also be used selectively. In this case the memory assigned to certain pointers may be freed leaving the remaining memory still available; pointers to this memory and the results it contains may then be passed to other functions in your program without passing the structure and all its associated memory.
Although the NAG C Library functions will manage all memory allocation and deallocation, it may occasionally be necessary for you to allocate memory to the options structure from within the calling program before entering the optimization function.
An example of this is where you store information in a file from an optimization run and at a later date wish to use that information to solve a similar optimization problem or the same one under slightly changed conditions. The pointer options.state, for example, would need to be allocated memory by you before the status of the constraints could be assigned from the values in the file.
If you assign memory to a pointer within the options structure then the deallocation of this memory must also be performed by you; the utility function nag_ip_free (h02xzc) will only free memory allocated by NAG C Library optimization functions. When user allocated memory is freed using the standard C library function free() then the pointer should be set to NULL immediately afterwards; this will avoid possible confusion in the NAG memory management system if a NAG function is subsequently entered.

3.1.3  Reading Optional Argument Values From a File

Optional argument values may be placed in a file by you and the function nag_ip_read (h02xyc) used to read the file and assign the values to the options structure. This utility function permits optional argument values to be supplied in any order and altered without recompilation of the program. The values read are also checked before assignment to ensure they are in the correct range for the specified option. Pointers within the options structure cannot be assigned to using nag_ip_read (h02xyc).

3.1.4  Method of Setting Optional Arguments

The method of using and setting the optional arguments is:
step 1Declare a structure of type Nag_H02_Opt.
step 2Initialize the structure using nag_ip_init (h02xxc).
step 3Assign values to the structure.
step 4Pass the address of the structure to the optimization function.
step 5Call nag_ip_free (h02xzc) to free any memory allocated by the optimization function.
If after step 4, you wish to re-enter the optimization function, then step 3 can be returned to directly, i.e., step 5 need only be executed when all calls to the optimization function have been made.
At step 3, values can be assigned directly and/or by means of the option file reading function nag_ip_read (h02xyc). If values are only assigned from the options file then step 2 need not be performed as nag_ip_read (h02xyc) will automatically call nag_ip_init (h02xxc) if the structure has not been initialized.

3.2  Transportation Problem

nag_transport (h03abc) 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.3  Feature Selection – Best Subset Problem

nag_best_subset_given_size_revcomm (h05aac) selects the best n subsets of size p using a reverse communication branch and bound algorithm.
nag_best_subset_given_size (h05abc) selects the best n subsets of size p using a direct communication branch and bound algorithm.

4  Functionality Index

Convert data to arrays for use with nag_ip_bb (h02bbc) or nag_opt_lp (e04mfc) nag_ip_mps_read (h02buc)
Feature selection, 
    best subset, 
        Given size, 
            direct communication nag_best_subset_given_size (h05abc)
            reverse communication nag_best_subset_given_size_revcomm (h05aac)
Integer programming problem (dense): 
    free NAG allocated memory from option structure nag_ip_free (h02xzc)
    initialize option structure nag_ip_init (h02xxc)
    print solution with specified names nag_ip_mps_free (h02bvc)
    read optional argument values nag_ip_read (h02xyc)
    solve LP problem using branch and bound method nag_ip_bb (h02bbc)
    solve nonlinear problem SQP nag_mip_sqp (h02dac)
Service functions, 
    optional argument getting function for use with nag_mip_sqp (h02dac) nag_mip_opt_get (h02zlc)
    optional argument setting function for use with  nag_mip_sqp (h02dac) nag_mip_opt_set (h02zkc)
Transportation problem nag_transport (h03abc)
Travelling Salesman Problem, simulated annealing nag_mip_tsp_simann (h03bbc)

5  Auxiliary Functions Associated with Library Function Arguments

None.

6  Functions Withdrawn or Scheduled for Withdrawal

None.

7  References

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

h Chapter Contents
h Chapter Introduction (PDF version)
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015