/* nag_transport(h03abc) Example Program. * * Copyright 1992 Numerical Algorithms Group. * * Mark 3, 1992. * * Mark 5 revised, 1998. * */ #include #include #include #include #define NAVAIL 3 #define NREQ 3 #define M NAVAIL+NREQ #define TDCOST 5 int main(void) { double cost[NAVAIL][TDCOST]; double avail[NAVAIL], req[NREQ], optq[M]; Integer source[M], dest[M]; double unitcost[M]; Integer tdcost, navail, nreq, m; Integer maxit, numit; double optcost; Integer i; static NagError fail; Vprintf("h03abc Example Program Results\n"); tdcost = TDCOST; navail = NAVAIL; nreq = NREQ; m = M; cost[0][0] = 8.0; cost[0][1] = 8.0; cost[0][2] = 11.0; cost[1][0] = 5.0; cost[1][1] = 8.0; cost[1][2] = 14.0; cost[2][0] = 4.0; cost[2][1] = 3.0; cost[2][2] = 10.0; avail[0] = 1.0; avail[1] = 5.0; avail[2] = 6.0; req[0] = 4.0; req[1] = 4.0; req[2] = 4.0; maxit = 200; h03abc(&cost[0][0], tdcost, avail, navail, req, nreq, maxit, &numit, optq, source, dest, &optcost, unitcost, &fail); if (fail.code == NE_NOERROR) { Vprintf("\nGoods From To Number Cost per Unit\n"); for (i=0; i < m-1; i++) Vprintf(" %ld %ld %8.3f %8.3f\n", source[i], dest[i], optq[i], unitcost[i]); Vprintf("\nTotal Cost %8.4f\n", optcost); return EXIT_SUCCESS; } else { Vprintf("%s\n", fail.message); return EXIT_FAILURE; } }