NAG FL Interface
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 <nag.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)
The routine may be called by the names h03abf or nagf_mip_transportation.

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 array Input
On entry: the coefficients cij, for i=1,2,,ma and j=1,2,,mb.
2: ldkost Integer Input
On entry: the first dimension of the array kost as declared in the (sub)program from which h03abf is called.
Constraint: ldkostma.
3: ma Integer Input
On entry: the number of sources, ma.
Constraint: ma1.
4: mb Integer Input
On entry: the number of destinations, mb.
Constraint: mb1.
5: m Integer Input
On entry: the value of ma+mb.
6: k15m Integer array Input/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 Integer Input
On entry: the maximum number of iterations allowed.
Constraint: maxit1.
8: k7m Integer array Workspace
9: k9m Integer array Workspace
10: numit Integer Output
On exit: the number of iterations performed.
11: k6m Integer array Output
On exit: k6k, for k=1,2,,ma+mb-1, contains the source indices of the optimal solution (see k11).
12: k8m Integer array Output
On exit: k8k, for k=1,2,,ma+mb-1, contains the destination indices of the optimal solution (see k11).
13: k11m Integer array Output
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 array Output
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 Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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 computations maxit has been exceeded.
ifail=3
On entry, maxit=value.
Constraint: maxit>0.
ifail=4
On entry, m=value, ma=value and mb=value.
Constraint: m=ma+mb.
On entry, ma=value.
Constraint: ma>0.
On entry, ma=value and ldkost=value.
Constraint: maldkost.
On entry, mb=value.
Constraint: mb>0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface 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)