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

Commit

Permalink
Mathprog (#8)
Browse files Browse the repository at this point in the history
* added mincost func

* added default solver

* added tests for mincost, export function

* default sink and source, circulation tests

* changed LP solver, added doc, conservation tests

* added mincost docs

* replace JuMP with basic MathProg

* removed JuMP from require

* changed mincost signature, removing default GLPK solver

* moved required solver to tests

* remove GLPK dep

* newline
  • Loading branch information
matbesancon authored Jan 13, 2018
1 parent 1f95fe2 commit 2158d81
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/mincost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ julia> demand = spzeros(6,6)
julia> demand[3,6] = 1
julia> demand[4,6] = 1
julia> capacity = ones(6,6)
julia> flow = mincost_flow(g, capacity, demand, w, GLPKSolverLP(), 5, 6)
julia> flow = mincost_flow(g, capacity, demand, w, ClpSolver(), 5, 6)
```
"""
function mincost_flow(g::lg.DiGraph,
Expand Down
3 changes: 1 addition & 2 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
GLPK
GLPKMathProgInterface
Clp
10 changes: 5 additions & 5 deletions test/mincost.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GLPKMathProgInterface: GLPKSolverLP
using Clp: ClpSolver

@testset "Minimum-cost flow" begin

Expand All @@ -24,7 +24,7 @@ using GLPKMathProgInterface: GLPKSolverLP
demand[4,6] = 1
capacity = ones(6,6)

flow = mincost_flow(g, capacity, demand, w, GLPKSolverLP(), 5, 6)
flow = mincost_flow(g, capacity, demand, w, ClpSolver(), 5, 6)
@test flow[5,1] == 1
@test flow[5,2] == 1
@test flow[3,6] == 1
Expand All @@ -42,7 +42,7 @@ using GLPKMathProgInterface: GLPKSolverLP

# no demand => null flow
d2 = spzeros(6,6)
flow = mincost_flow(g, capacity, d2, w, GLPKSolverLP(), 5, 6)
flow = mincost_flow(g, capacity, d2, w, ClpSolver(), 5, 6)
for idx in 1:6
for jdx in 1:6
@test flow[idx,jdx] 0.0
Expand All @@ -62,7 +62,7 @@ using GLPKMathProgInterface: GLPKSolverLP
demand = spzeros(6,6)
demand[1,2] = 1
costs = ones(6,6)
flow = mincost_flow(g, capacity, demand, costs, GLPKSolverLP())
flow = mincost_flow(g, capacity, demand, costs, ClpSolver())
active_flows = [(1,2), (2,5), (5,6),(6,1)]
for s in 1:6
for t in 1:6
Expand All @@ -79,7 +79,7 @@ using GLPKMathProgInterface: GLPKSolverLP
end
# higher short-circuit cost
costs[2,5] = 10.
flow = mincost_flow(g, capacity, demand, costs, GLPKSolverLP())
flow = mincost_flow(g, capacity, demand, costs, ClpSolver())
active_flows = [(1,2),(2,3),(3,4),(4,5),(5,6),(6,1)]
for s in 1:6
for t in 1:6
Expand Down

0 comments on commit 2158d81

Please sign in to comment.