4 %> @note Tested with runTransportationTrans.m
5 %> @note Tested with runMaxFlowTrans.m
6 %> @note Tested with runAssignmentTrans.m
11 %> @author Michel Bierlaire
12 %> @date Sat Apr 11 11:46:00 2015
13 %> @ingroup Algorithms
17 %> @param adj the adjacency matrix of the network (dim m x m)
18 %> @param cost the cost vector (dim n)
19 %> @param lb the vector of lower bounds (dim n)
20 %> @param ub the vector of upper bounds (dim n)
21 %> @param supply the vector of supply (dim m)
22 %> @param useGlpk
if not 0, solve the linear problem
using the glpk routine from Octave. (Default: 0)
23 %> @
return cycle flow a simple cycle flow
24 function [x,copt] =
transhipment(adj,cost,lb,ub,supply,useGlpk=0)
25 addpath(
"../chap16") ;
27 narcs = max(max(adj)) ;
28 if (columns(adj) != nnodes)
29 error(
"Adjacency matrix must be square") ;
31 if (length(cost) != narcs)
32 error(
"cost vector has incorrect size") ;
34 if (length(lb) != narcs)
35 error(
"lb vector has incorrect size") ;
38 if (length(ub) != narcs)
39 error(
"ub vector has incorrect size") ;
44 error(
"Incompatible bounds") ;
47 if (length(supply) != nnodes)
48 error(
"supply vector has incorrect size") ;
51 if (sum(supply) != 0.0)
52 error(
"Infeasible supply/demand vector. Must sum up to 0") ;
58 ctype = repmat(
'S',1,nconstraints) ;
59 [x, copt, errnum, extra] = glpk(cost,
incidenceMatrix,supply,lb,ub,ctype) ;
67 printf(
"Problem is infeasible\n") ;
71 printf(
"Problem is unbounded\n") ;
function twoPhasesSimplex(in A, in b, in c)
Solve a linear optimization problem in standard form using the tableau simplex with two phases subje...
function transhipment(in adj, in cost, in lb, in ub, in supply, in useGlpk)
Solve the transhipment problem with bound constraints.
function incidenceMatrix(in adj)
Provide the incidence matrix a a network.