minimum quadratic cost flow
[c,phi,flag] = min_qcost_flow(eps,g)
scalar, precision
value of cost
row vector of the value of flow on the arcs
feasible problem flag (0 or 1)
min_qcost_flow
computes the minimum quadratic
cost flow in the network g
. It returns the
total cost of the flows on the arcs c
and the
row vector of the flows on the arcs
phi
. eps
is the precision
of the iterative algorithm. If the problem is not feasible
(impossible to find a compatible flow for instance),
flag
is equal to 0, otherwise it is equal to
1.
The bounds of the flow are given by the
g.edges.data.min_cap
and
g.edges.data.max_cap
fields of the graph.
The value of the minimum capacity and of the maximum capacity must be non negative. The value of the maximum capacity must be greater than or equal to the value of the minimum capacity.
If the value of min_cap
or
max_cap
is not given it is assumed to be
equal to 0 on each edge.
The costs on the edges are given by the elements
g.edges.data.q_orig
and
g.edges.data.q_weight
of the fields of the
graph. These values must be non negative. If the value of
q_orig
or q_weight
is not
given, it is assumed to be equal to 0 on each edge. The cost on
arc u
is given by:
(1/2)*q_weight[u](phi[u]-q_orig[u])^2
If the min_cap
or max_cap
or q_orig
or q_weight
data
fields are not present in the graph structure they can be added
and set using the add_edge_data function.
This function uses an algorithm due to M. Minoux.
ta=[1 1 2 2 2 3 4 4 5 6 6 6 7 7 7 8 9 10 12 12 13 13 13 14 15 14 9 11 10 1 8]; he=[2 6 3 4 5 1 3 5 1 7 10 11 5 8 9 5 8 11 10 11 9 11 15 13 14 4 6 9 1 12 14]; g=make_graph('foo',1,15,ta,he); g.nodes.graphics.x=[155,153,85,155,237,244,244,334,338,346,442,440,439,333,438]; g.nodes.graphics.y=[45,177,253,254,253,114,171,257,174,101,172,64,264,350,351]; show_graph(g); ma=edge_number(g) g=add_edge_data(g,'min_cap',[0,1,5,5,0,3,3,5,4,1,4,3,3,1,3,1,1,4,1,3,1,4,5,4,4,2,1,4,2,3,2]); g=add_edge_data(g,'max_cap',[38,37,42,41,34,49,35,36,43,43,43,48,37,.. 36,42,48,44,36,30,31,30,41,32,42,34,48,32,36,36,36,30]); g=add_edge_data(g,'q_weight',ones(1,ma)); [c,phi,flag]=min_qcost_flow(0.001,g);flag g.edges.graphics.foreground(find(phi<>0))=color('red'); g=add_edge_data(g,'flow',phi) g.edges.graphics.display='flow'; show_graph(g); | ![]() | ![]() |