NAG Library Chapter Introduction
h – Operations Research
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:
- find to maximize
- subject to linear constraints which may have the forms:
This chapter deals with integer programming
(IP) problems in which some or all the elements of the solution vector
are further constrained to be integers
. For general LP problems where
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:
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
, and it is clear from Figure 1
that the optimum IP solution is at the point
. For this problem the solution is unique.
However, there are other possible situations.
||There may be more than one solution; e.g., if the objective function in the above problem were changed to , both and would be IP solutions.
||The feasible region may contain no points with integer coordinates, e.g., if an additional constraint
were added to the above problem.
||There may be no feasible region, e.g., if an additional constraint
were added to the above problem.
||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
were deleted from the above problem.
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.
A special type of linear programming problem is the transportation problem in which there are variables which represent quantities of goods to be transported from each of sources to each of destinations.
The problem is to minimize
is the unit cost of transporting from source
. The constraints are:
Note that the availabilities must equal the requirements:
and if all the
are integers, then so are the optimal
The best subsets problem assumes a scoring mechanism and a set of features. The problem is one of choosing the best subsets of size . It is addressed by two functions in this chapter. The first of these uses reverse communication; the second direct communication.
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 arguments 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 , 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
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
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 1||Declare a structure of type Nag_H02_Opt.|
|step 2||Initialize the structure using nag_ip_init (h02xxc).|
|step 3||Assign values to the structure.|
|step 4||Pass the address of the structure to the optimization function.|
|step 5||Call 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
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
selects the best
subsets of size
using a reverse communication branch and bound algorithm.
selects the best
subsets of size
using a direct communication branch and bound algorithm.
4 Functionality Index
|Integer programming problem (dense):|| |
5 Auxiliary Functions Associated with Library Function Arguments
6 Functions Withdrawn or Scheduled for Withdrawal
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