H03ABF (PDF version)
H Chapter Contents
H Chapter Introduction
NAG Library Manual

NAG Library Routine Document

H03ABF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

H03ABF solves the classical Transportation (‘Hitchcock’) problem.

2  Specification

SUBROUTINE H03ABF ( KOST, LDKOST, MA, MB, M, K15, MAXIT, K7, K9, NUMIT, K6, K8, K11, K12, Z, IFAIL)
INTEGER  KOST(LDKOST,MB), LDKOST, MA, MB, M, K15(M), MAXIT, K7(M), K9(M), NUMIT, K6(M), K8(M), K11(M), K12(M), IFAIL
REAL (KIND=nag_wp)  Z

3  Description

H03ABF solves the Transportation problem by minimizing
z = i ma j mb cij xij .  
subject to the constraints
j mb x i j = A i   (Availabilities) i ma i x i j = B j   (Requirements)  
where the xij can be interpreted as quantities of goods sent from source i to destination j, for i=1,2,,ma and j=1,2,,mb, at a cost of cij per unit, and it is assumed that i ma Ai= j mb j Bj  and xij0.
H03ABF uses the ‘stepping stone’ method, modified to accept degenerate cases.

4  References

Hadley G (1962) Linear Programming Addison–Wesley

5  Parameters

1:     KOSTLDKOSTMB – INTEGER arrayInput
On entry: the coefficients cij, for i=1,2,,ma and j=1,2,,mb.
2:     LDKOST – INTEGERInput
On entry: the first dimension of the array KOST as declared in the (sub)program from which H03ABF is called.
Constraint: LDKOSTMA.
3:     MA – INTEGERInput
On entry: the number of sources, ma.
Constraint: MA1.
4:     MB – INTEGERInput
On entry: the number of destinations, mb.
Constraint: MB1.
5:     M – INTEGERInput
On entry: the value of ma+mb.
6:     K15M – INTEGER arrayInput/Output
On entry: K15i must be set to the availabilities Ai, for i=1,2,,ma; and K15ma+j must be set to the requirements Bj, for j=1,2,,mb.
On exit: the contents of K15 are undefined.
7:     MAXIT – INTEGERInput
On entry: the maximum number of iterations allowed.
Constraint: MAXIT1.
8:     K7M – INTEGER arrayWorkspace
9:     K9M – INTEGER arrayWorkspace
10:   NUMIT – INTEGEROutput
On exit: the number of iterations performed.
11:   K6M – INTEGER arrayOutput
On exit: K6k, for k=1,2,,ma+mb-1, contains the source indices of the optimal solution (see K11).
12:   K8M – INTEGER arrayOutput
On exit: K8k, for k=1,2,,ma+mb-1, contains the destination indices of the optimal solution (see K11).
13:   K11M – INTEGER arrayOutput
On exit: K11k, for k=1,2,,ma+mb-1, contains the optimal quantities xij which, sent from source i=K6k to destination j=K8k, minimize z.
14:   K12M – INTEGER arrayOutput
On exit: K12k, for k=1,2,,ma+mb-1, contains the unit cost cij associated with the route from source i=K6k to destination j=K8k.
15:   Z – REAL (KIND=nag_wp)Output
On exit: the value of the minimized total cost.
16:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry, the sum of the availabilities does not equal the sum of the requirements.
IFAIL=2
During computation MAXIT has been exceeded.
IFAIL=3
On entry,MAXIT<1.
IFAIL=4
On entry,MA<1,
orMB<1,
orMMA+MB,
orMA>LDKOST.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

All operations are performed in integer arithmetic so that there are no rounding errors.

8  Parallelism and Performance

Not applicable.

9  Further Comments

An accurate estimate of the run time for a particular problem is difficult to achieve.

10  Example

A company has three warehouses and three stores. The warehouses have a surplus of 12 units of a given commodity divided among them as follows:
Warehouse Surplus
1 1
2 5
3 6
The stores altogether need 12 units of commodity, with the following requirements:
Store Requirement
1 4
2 4
3 4
Costs of shipping one unit of the commodity from warehouse i to store j are displayed in the following matrix:
    Store
    1 2 3
  1 8 8 11
Warehouse 2 5 8 14
  3 4 3 10
It is required to find the units of commodity to be moved from the warehouses to the stores, such that the transportation costs are minimized. The maximum number of iterations allowed is 200.

10.1  Program Text

Program Text (h03abfe.f90)

10.2  Program Data

Program Data (h03abfe.d)

10.3  Program Results

Program Results (h03abfe.r)


H03ABF (PDF version)
H Chapter Contents
H Chapter Introduction
NAG Library Manual

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