Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit 5755f55

Browse files
authored
added precisions for solver to use (#13)
1 parent f22cee5 commit 5755f55

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,33 @@ julia> f = multiroute_flow(points, 1.5, valueonly = true)
7373

7474
julia> f, F, labels = multiroute_flow(flow_graph, 1, 8, capacity_matrix, algorithm = BoykovKolmogorovAlgorithm(), routes = 2) # Run multiroute flow algorithm using Boykov-Kolmogorov algorithm as maximum_flow routine
7575
```
76+
77+
## Mincost flow
78+
79+
Mincost flow is solving a linear optimization problem and thus requires a LP solver
80+
defined by [MathProgBase.jl](http://mathprogbasejl.readthedocs.io).
81+
82+
```julia
83+
using Clp: ClpSolver
84+
g = lg.DiGraph(6)
85+
lg.add_edge!(g, 5, 1)
86+
lg.add_edge!(g, 5, 2)
87+
lg.add_edge!(g, 3, 6)
88+
lg.add_edge!(g, 4, 6)
89+
lg.add_edge!(g, 1, 3)
90+
lg.add_edge!(g, 1, 4)
91+
lg.add_edge!(g, 2, 3)
92+
lg.add_edge!(g, 2, 4)
93+
w = zeros(6,6)
94+
w[1,3] = 10.
95+
w[1,4] = 5.
96+
w[2,3] = 2.
97+
w[2,4] = 2.
98+
# v2 -> sink have demand of one
99+
demand = spzeros(6,6)
100+
demand[3,6] = 1
101+
demand[4,6] = 1
102+
capacity = ones(6,6)
103+
104+
flow = mincost_flow(g, capacity, demand, w, ClpSolver(), 5, 6)
105+
```

src/mincost.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ consumption respectively. All other nodes must respect the flow conservation
99
property.
1010
1111
- The problem can be seen as a linear programming problem and uses a LP
12-
solver under the hood.
12+
solver under the hood. We use Clp in the examples and tests.
1313
1414
Returns a flow matrix, flow[i,j] corresponds to the flow on the (i,j) arc.
1515
1616
### Usage Example:
1717
1818
```julia
19+
julia> using Clp: ClpSolver # use your favorite LP solver here
1920
julia> g = lg.DiGraph(6) # Create a flow-graph
2021
julia> lg.add_edge!(g, 5, 1)
2122
julia> lg.add_edge!(g, 5, 2)

0 commit comments

Comments
 (0)