NAG Library Routine Document

h03abf (transportation)

1
Purpose

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

2
Specification

Fortran Interface
Subroutine h03abf ( kost, ldkost, ma, mb, m, k15, maxit, k7, k9, numit, k6, k8, k11, k12, z, ifail)
Integer, Intent (In):: kost(ldkost,mb), ldkost, ma, mb, m, maxit
Integer, Intent (Inout):: k15(m), ifail
Integer, Intent (Out):: k7(m), k9(m), numit, k6(m), k8(m), k11(m), k12(m)
Real (Kind=nag_wp), Intent (Out):: z
C Header Interface
#include <nagmk26.h>
void  h03abf_ (const Integer kost[], const Integer *ldkost, const Integer *ma, const Integer *mb, const Integer *m, Integer k15[], const Integer *maxit, Integer k7[], Integer k9[], Integer *numit, Integer k6[], Integer k8[], Integer k11[], Integer k12[], double *z, Integer *ifail)

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
Arguments

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 argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

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

8
Parallelism and Performance

h03abf is not threaded in any implementation.

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)