Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ os:
# - osx

julia:
- 0.6
- 0.7
- 1.0
- nightly

matrix:
Expand All @@ -15,13 +16,13 @@ matrix:
notifications:
email: false
# uncomment the following lines to override the default test script
script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd()); Pkg.build("LightGraphsExtras"); Pkg.test("LightGraphsExtras"; coverage=true)'
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("LightGraphsExtras"); Pkg.test("LightGraphsExtras"; coverage=true)'

# cache:
# directories:
# - $HOME/.julia/v0.4/JuMP/
# - $HOME/.julia/v0.5/JuMP/
after_success:
- julia -e 'cd(Pkg.dir("LightGraphsExtras")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
- julia -e 'cd(using Pkg; Pkg.dir("LightGraphsExtras")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
10 changes: 6 additions & 4 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
julia 0.6
LightGraphs 0.9.0
JuMP 0.13.2
julia 0.7
LightGraphs 1.1.0
JuMP 0.18.3
MatrixDepot
GLPKMathProgInterface 0.3.2
GLPKMathProgInterface 0.4.4
MathProgBase 0.7.6
LightGraphsFlows
3 changes: 1 addition & 2 deletions src/datasets/datasets.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
__precompile__(true)
module Datasets

using ...LightGraphs
using LightGraphs
using MatrixDepot

# matrixdepot
Expand Down
4 changes: 2 additions & 2 deletions src/datasets/matrixdepot.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function MDGraph(a::AbstractString, x...)
a in matrixdepot("symmetric") || error("Valid matrix not found in collection")
external = a in matrixdepot("data")
m = external? matrixdepot(a, x..., :read) : matrixdepot(a, x...)
m = external ? matrixdepot(a, x..., :read) : matrixdepot(a, x...)
m == nothing && error("Invalid matrix parameters specified")

return Graph(m)
Expand All @@ -10,7 +10,7 @@ end
function MDDiGraph(a::AbstractString, x...)
a in matrixdepot("all") || error("Valid matrix not found in collection")
external = a in matrixdepot("data")
m = external? matrixdepot(a, x..., :read) : matrixdepot(a, x...)
m = external ? matrixdepot(a, x..., :read) : matrixdepot(a, x...)
m == nothing && error("Invalid matrix parameters specified")

return DiGraph(m)
Expand Down
20 changes: 10 additions & 10 deletions src/interdiction/bilevel_adaptive_arc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function init_first_level_arc(
# flow conservation constraints
for v in vertices(flow_graph)
if (v ≠ source && v ≠ target)
@constraint(first_level, sum{x[i, j], i = 1:n, j = 1:n;
capacity_matrix[i ,j] > 0} - sum{x[j, i], i = 1:n, j = 1:n;
capacity_matrix[j, i] > 0} == 0)
@constraint(first_level, sum(x[i, j] for i = 1:n, j = 1:n if
capacity_matrix[i ,j] > 0) - sum(x[j, i] for i = 1:n, j = 1:n if
capacity_matrix[j, i] > 0) == 0)
end
end

Expand Down Expand Up @@ -55,9 +55,9 @@ function init_second_level_arc(
@variable(second_level, ν[i = 1:n, j = 1:n] ≥ 0)

# set objective
@objective(second_level, Min, sum{
x_value[i, j] * δ[i, j] - x_value[i, j] * ν[i, j], i = 1:n, j = 1:n;
capacity_matrix[i, j] > 0})
@objective(second_level, Min, sum(
x_value[i, j] * δ[i, j] - x_value[i, j] * ν[i, j] for i = 1:n, j = 1:n if
capacity_matrix[i, j] > 0))

# constraints over the edges
for e in edges(flow_graph)
Expand Down Expand Up @@ -85,7 +85,7 @@ function init_second_level_arc(
end

# constraint on the upper bound for the number of attacks
@constraint(second_level, sum{μ[i, j], i = 1:n, j = 1:n} ≤ attacks)
@constraint(second_level, sum(μ[i, j] for i = 1:n, j = 1:n) ≤ attacks)

return second_level, δ, ν
end
Expand Down Expand Up @@ -130,9 +130,9 @@ function bilevel_adaptive_arc(
# Otherwise add the new cut to the first level
δ_value = getvalue(δ)
ν_value = getvalue(ν)
@constraint(first_level, z ≤ sum{
δ_value[i, j] * x[i, j] - ν_value[i, j] * x[i, j], i = 1:n, j = 1:n;
capacity_matrix[i, j] > 0})
@constraint(first_level, z ≤ sum(
δ_value[i, j] * x[i, j] - ν_value[i, j] * x[i, j] for i = 1:n, j = 1:n if
capacity_matrix[i, j] > 0))
end

# Return objective value and elapsed time
Expand Down
7 changes: 3 additions & 4 deletions src/interdiction/interdiction.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
__precompile__(true)
module Interdiction

using LightGraphs
using JuMP
using MathProgBase
using LightGraphsFlows

using GLPKMathProgInterface: GLPKSolverMIP

import MathProgBase.SolverInterface.AbstractMathProgSolver,
JuMP.UnsetSolver,
LightGraphs.DefaultCapacity
LightGraphsFlows.DefaultCapacity

export interdiction_flow, ⪷,
NetworkInterdictionProblem, AdaptiveFlowArcProblem, AdaptiveFlowPathProblem,
Expand Down Expand Up @@ -202,14 +202,13 @@ use of the solver keyword, as it is similar to the `Model()` method there.

All algorithms return a tuple with 1) a lower bound and 2) an upper bound.
For the Multilink Attack algorithm, it also returns the restriction values (to use with
the function maximum_flow in LightGraphs.jl) associated with 3-a) the lower bound and
the function maximum_flow in LightGraphsFlows.jl) associated with 3-a) the lower bound and
4-a) the upper bound. When the BMILP is used, the third element returned is 3-b) the
time used by the algorithm.

When the number of attacks is set to -1, an array with the results for any possible number of attacks will be output. Each result will be output as above.

"""

function interdiction_flow(
flow_graph::DiGraph, # the input graph
source::Int, # the source vertex
Expand Down
3 changes: 2 additions & 1 deletion test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Clp
Clp 0.5.0
LightGraphsFlows
4 changes: 4 additions & 0 deletions test/datasets/matrixdepot.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@testset "MatrixDepot" begin

println("*** Running MatrixDepot tests")
randstr = "LightGraphs/$(rand(1:10000))"
g = MDGraph("hilb", 4)
Expand All @@ -8,3 +10,5 @@ g = MDDiGraph("baart", 4)

@test_throws ErrorException MDGraph("baart", 4)
println("*** Finished MatrixDepot tests")

end
10 changes: 6 additions & 4 deletions test/datasets/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ tests = [
]


for t in tests
tp = joinpath(testdir,"$(t).jl")
println("running $(tp) ...")
include(tp)
@testset "datasets" begin
for t in tests
tp = joinpath(testdir,"$(t).jl")
println("running $(tp) ...")
include(tp)
end
end
7 changes: 6 additions & 1 deletion test/interdiction/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Base.Test
using Test
using LightGraphs
using LightGraphsExtras.Interdiction
using LightGraphsFlows: maximum_flow

@testset "interdiction" begin

#### Graphs for testing
graphs = [
Expand Down Expand Up @@ -83,3 +86,5 @@ for (nvertices, flow_edges, s, t) in graphs
interdiction_flow(flow_graph, s, t, capacity_matrix, 1)

end

end
13 changes: 7 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
include("../src/LightGraphsExtras.jl")
using LightGraphs
using LightGraphsExtras
using LightGraphsExtras.Datasets
using LightGraphsExtras.Interdiction
using Base.Test
using Test

testdir = dirname(@__FILE__)

Expand All @@ -12,8 +11,10 @@ tests = [
"interdiction"
]

for t in tests
tp = joinpath(testdir, t, "runtests.jl")
println("running $(tp) ...")
include(tp)
@testset "LightGraphsExtras" begin
for t in tests
tp = joinpath(testdir, t, "runtests.jl")
println("running $(tp) ...")
include(tp)
end
end