NAG CL Interface
h03abc (transportation)

Settings help

CL Name Style:

1 Purpose

h03abc solves the classical transportation (‘Hitchcock’) problem.

2 Specification

#include <nag.h>
void  h03abc (const double cost[], Integer tdcost, const double avail[], Integer navail, const double req[], Integer nreq, Integer maxit, Integer *numit, double optq[], Integer source[], Integer dest[], double *optcost, double unitcost[], NagError *fail)
The function may be called by the names: h03abc, nag_mip_transportation or nag_transport.

3 Description

h03abc solves the transportation problem by minimizing
z = i m a j m b c ij x ij .  
subject to the constraints
j m b x ij = A i (availabilities) i m a x ij = B j (requirements)  
where the x ij can be interpreted as quantities of goods sent from source i to destination j , for i=1,2,, m a and j=1,2,, m b , at a cost of c ij per unit, and it is assumed that i m a A i = j m b B j and x ij 0 .
h03abc uses the ‘stepping stone’ method, modified to accept degenerate cases.

4 References

Hadley G (1962) Linear Programming Addison–Wesley

5 Arguments

1: cost[navail×tdcost] const double Input
On entry: cost[(i-1)×tdcost+j-1] contains the coefficients c ij , for i=1,2,, m a and j=1,2,, m b .
2: tdcost Integer Input
On entry: the stride separating matrix column elements in the array cost.
Constraint: tdcostnreq .
3: avail[navail] const double Input
On entry: avail[i-1] must be set to the availabilities A i , for i=1,2,, m a ;
On entry: the number of sources, m a .
Constraint: navail1 .
5: req[nreq] const double Input
On entry: req[j-1] must be set to the requirements B j , for j=1,2,, m b .
6: nreq Integer Input
On entry: the number of destinations, m b .
Constraint: nreq1 .
7: maxit Integer Input
On entry: the maximum number of iterations allowed.
Constraint: maxit1 .
8: numit Integer * Output
On exit: the number of iterations performed.
9: optq[navail+nreq] double Output
On exit: optq[k-1] , for k=1,2,, m a + m b - 1, contains the optimal quantities x ij which, when sent from source i = source[k-1] to destination j = dest[k-1] , minimize z .
10: source[navail+nreq] Integer Output
On exit: source[k-1] , for k=1,2,, m a + m b - 1, contains the source indices of the optimal solution (see optq above).
11: dest[navail+nreq] Integer Output
On exit: dest[k-1] , for k=1,2,, m a + m b - 1, contains the destination indices of the optimal solution (see optq above).
12: optcost double * Output
On exit: the value of the minimized total cost.
13: unitcost[navail+nreq] double Output
On exit: unitcost[k-1] , for k=1,2,, m a + m b - 1, contains the unit cost c ij associated with the route from source i = source[k-1] to destination j = dest[k-1] .
14: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

On entry, tdcost=value while nreq=value . These arguments must satisfy tdcostnreq .
Dynamic memory allocation failed.
On entry, maxit=value.
Constraint: maxit1.
On entry, navail=value.
Constraint: navail1.
On entry, nreq=value.
Constraint: nreq1.
The relative difference between the sum of availabilities and the sum of requirements is greater than machine precision. relative difference =value , machine precision=value .
Too many iterations (value)

7 Accuracy

The computations are stable.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
h03abc is not threaded in any implementation.

9 Further Comments

An a priori estimate of the run time for a particular problem is difficult to obtain.

10 Example

A company has three warehouses and three stores. The warehouses have a surplus of 12 units of a given commodity divided between 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:
1 2 3
Warehouse 1 8 8 11
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 (h03abce.c)

10.2 Program Data


10.3 Program Results

Program Results (h03abce.r)