Skip to content

Commit 85a2317

Browse files
simonschoellysbromberger
authored andcommitted
fixes for julia v1.0 (#33)
1 parent 6f70e89 commit 85a2317

File tree

11 files changed

+53
-39
lines changed

11 files changed

+53
-39
lines changed

.travis.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ os:
55
# - osx
66

77
julia:
8-
- 0.6
8+
- 0.7
9+
- 1.0
910
- nightly
1011

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

2223
# cache:
2324
# directories:
2425
# - $HOME/.julia/v0.4/JuMP/
2526
# - $HOME/.julia/v0.5/JuMP/
2627
after_success:
27-
- julia -e 'cd(Pkg.dir("LightGraphsExtras")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
28+
- julia -e 'cd(using Pkg; Pkg.dir("LightGraphsExtras")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'

REQUIRE

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
julia 0.6
2-
LightGraphs 0.9.0
3-
JuMP 0.13.2
1+
julia 0.7
2+
LightGraphs 1.1.0
3+
JuMP 0.18.3
44
MatrixDepot
5-
GLPKMathProgInterface 0.3.2
5+
GLPKMathProgInterface 0.4.4
6+
MathProgBase 0.7.6
7+
LightGraphsFlows

src/datasets/datasets.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
__precompile__(true)
21
module Datasets
32

4-
using ...LightGraphs
3+
using LightGraphs
54
using MatrixDepot
65

76
# matrixdepot

src/datasets/matrixdepot.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function MDGraph(a::AbstractString, x...)
22
a in matrixdepot("symmetric") || error("Valid matrix not found in collection")
33
external = a in matrixdepot("data")
4-
m = external? matrixdepot(a, x..., :read) : matrixdepot(a, x...)
4+
m = external ? matrixdepot(a, x..., :read) : matrixdepot(a, x...)
55
m == nothing && error("Invalid matrix parameters specified")
66

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

1616
return DiGraph(m)

src/interdiction/bilevel_adaptive_arc.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function init_first_level_arc(
1818
# flow conservation constraints
1919
for v in vertices(flow_graph)
2020
if (v source && v target)
21-
@constraint(first_level, sum{x[i, j], i = 1:n, j = 1:n;
22-
capacity_matrix[i ,j] > 0} - sum{x[j, i], i = 1:n, j = 1:n;
23-
capacity_matrix[j, i] > 0} == 0)
21+
@constraint(first_level, sum(x[i, j] for i = 1:n, j = 1:n if
22+
capacity_matrix[i ,j] > 0) - sum(x[j, i] for i = 1:n, j = 1:n if
23+
capacity_matrix[j, i] > 0) == 0)
2424
end
2525
end
2626

@@ -55,9 +55,9 @@ function init_second_level_arc(
5555
@variable(second_level, ν[i = 1:n, j = 1:n] 0)
5656

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

6262
# constraints over the edges
6363
for e in edges(flow_graph)
@@ -85,7 +85,7 @@ function init_second_level_arc(
8585
end
8686

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

9090
return second_level, δ, ν
9191
end
@@ -130,9 +130,9 @@ function bilevel_adaptive_arc(
130130
# Otherwise add the new cut to the first level
131131
δ_value = getvalue(δ)
132132
ν_value = getvalue(ν)
133-
@constraint(first_level, z sum{
134-
δ_value[i, j] * x[i, j] - ν_value[i, j] * x[i, j], i = 1:n, j = 1:n;
135-
capacity_matrix[i, j] > 0})
133+
@constraint(first_level, z sum(
134+
δ_value[i, j] * x[i, j] - ν_value[i, j] * x[i, j] for i = 1:n, j = 1:n if
135+
capacity_matrix[i, j] > 0))
136136
end
137137

138138
# Return objective value and elapsed time

src/interdiction/interdiction.jl

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
__precompile__(true)
21
module Interdiction
32

43
using LightGraphs
54
using JuMP
65
using MathProgBase
6+
using LightGraphsFlows
77

88
using GLPKMathProgInterface: GLPKSolverMIP
99

1010
import MathProgBase.SolverInterface.AbstractMathProgSolver,
1111
JuMP.UnsetSolver,
12-
LightGraphs.DefaultCapacity
12+
LightGraphsFlows.DefaultCapacity
1313

1414
export interdiction_flow, ,
1515
NetworkInterdictionProblem, AdaptiveFlowArcProblem, AdaptiveFlowPathProblem,
@@ -202,14 +202,13 @@ use of the solver keyword, as it is similar to the `Model()` method there.
202202
203203
All algorithms return a tuple with 1) a lower bound and 2) an upper bound.
204204
For the Multilink Attack algorithm, it also returns the restriction values (to use with
205-
the function maximum_flow in LightGraphs.jl) associated with 3-a) the lower bound and
205+
the function maximum_flow in LightGraphsFlows.jl) associated with 3-a) the lower bound and
206206
4-a) the upper bound. When the BMILP is used, the third element returned is 3-b) the
207207
time used by the algorithm.
208208
209209
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.
210210
211211
"""
212-
213212
function interdiction_flow(
214213
flow_graph::DiGraph, # the input graph
215214
source::Int, # the source vertex

test/REQUIRE

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Clp
1+
Clp 0.5.0
2+
LightGraphsFlows

test/datasets/matrixdepot.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@testset "MatrixDepot" begin
2+
13
println("*** Running MatrixDepot tests")
24
randstr = "LightGraphs/$(rand(1:10000))"
35
g = MDGraph("hilb", 4)
@@ -8,3 +10,5 @@ g = MDDiGraph("baart", 4)
810

911
@test_throws ErrorException MDGraph("baart", 4)
1012
println("*** Finished MatrixDepot tests")
13+
14+
end

test/datasets/runtests.jl

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ tests = [
33
]
44

55

6-
for t in tests
7-
tp = joinpath(testdir,"$(t).jl")
8-
println("running $(tp) ...")
9-
include(tp)
6+
@testset "datasets" begin
7+
for t in tests
8+
tp = joinpath(testdir,"$(t).jl")
9+
println("running $(tp) ...")
10+
include(tp)
11+
end
1012
end

test/interdiction/runtests.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
using Base.Test
1+
using Test
22
using LightGraphs
33
using LightGraphsExtras.Interdiction
4+
using LightGraphsFlows: maximum_flow
5+
6+
@testset "interdiction" begin
47

58
#### Graphs for testing
69
graphs = [
@@ -83,3 +86,5 @@ for (nvertices, flow_edges, s, t) in graphs
8386
interdiction_flow(flow_graph, s, t, capacity_matrix, 1)
8487

8588
end
89+
90+
end

test/runtests.jl

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
include("../src/LightGraphsExtras.jl")
21
using LightGraphs
32
using LightGraphsExtras
43
using LightGraphsExtras.Datasets
54
using LightGraphsExtras.Interdiction
6-
using Base.Test
5+
using Test
76

87
testdir = dirname(@__FILE__)
98

@@ -12,8 +11,10 @@ tests = [
1211
"interdiction"
1312
]
1413

15-
for t in tests
16-
tp = joinpath(testdir, t, "runtests.jl")
17-
println("running $(tp) ...")
18-
include(tp)
14+
@testset "LightGraphsExtras" begin
15+
for t in tests
16+
tp = joinpath(testdir, t, "runtests.jl")
17+
println("running $(tp) ...")
18+
include(tp)
19+
end
1920
end

0 commit comments

Comments
 (0)