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:     KOST(LDKOST,MB) – 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:     K15(M) – 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:     K7(M) – INTEGER arrayWorkspace
9:     K9(M) – INTEGER arrayWorkspace
10:   NUMIT – INTEGEROutput
On exit: the number of iterations performed.
11:   K6(M) – INTEGER arrayOutput
On exit: K6k, for k=1,2,,ma+mb-1, contains the source indices of the optimal solution (see K11).
12:   K8(M) – INTEGER arrayOutput
On exit: K8k, for k=1,2,,ma+mb-1, contains the destination indices of the optimal solution (see K11).
13:   K11(M) – 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:   K12(M) – 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.

7  Accuracy

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

8  Further Comments

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

9  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.

9.1  Program Text

Program Text (h03abfe.f90)

9.2  Program Data

Program Data (h03abfe.d)

9.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. 2012