Optimization: principles and algorithms, by Michel Bierlaire
incidenceMatrix.m
Go to the documentation of this file.
1 %> \file
2 %> Provide the incidence matrix of the network for the teanshipment problem
3 %>
4 %> @note Calls \ref prepareNetwork
5 %> @note Called by \ref transhipment
6 %>
7 %> @author Michel Bierlaire
8 %> @date Wed Jul 23 09:43:15 2014
9 %> @ingroup Algorithms
10 %> @ingroup chap22
11 
12 %> Provide the incidence matrix a a network
13 %> @param adj the adjacency matrix of the network
14 %> @return A
15 function A = incidenceMatrix(adj)
16 
17  addpath("../chap21") ;
18  nnodes = rows(adj) ;
19  narcs = max(max(adj)) ;
20  if (columns(adj) != nnodes)
21  error("Adjacency matrix must be square") ;
22  endif
23 
24  arcs = prepareNetwork(adj) ;
25 
26  A = zeros(nnodes,narcs) ;
27  for m=1:narcs
28  i = arcs(m,1) ;
29  j = arcs(m,2) ;
30  A(i,m) = 1 ;
31  A(j,m) = -1 ;
32  endfor
33 endfunction
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.
function prepareNetwork(in adj)
Identifies the upstream and downstream nodes of each arc.
Copyright 2015-2018 Michel Bierlaire