Skip to content

Commit

Permalink
Fix #6; add compat; test on more platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson committed Sep 6, 2019
1 parent 5b1a9fc commit 56698bf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/Manifest.toml
/docs/build/
/docs/site/
/dev
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ language: julia
os:
- linux
- osx
- windows
julia:
- 1.0
- 1.1
- 1.2
- nightly
branches: # build master branch + PRs
only:
- master
matrix:
allow_failures:
- julia: nightly
Expand Down
10 changes: 8 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ version = "0.3.2"

[deps]
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[compat]
julia = "1"
UnicodePlots = "1"
MathOptInterface = "0.8"
JuMP = "0.19"

[extras]
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
Expand Down
4 changes: 2 additions & 2 deletions src/TravelingSalesmanExact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function _get_optimal_tour(cost::AbstractMatrix, with_optimizer, symmetric, verb
if verbose
@info "Optimization finished; adaptively disallowed $tot_cycles cycles."
@info "Final path has length $(objective_value(model))."
@info "Final problem has $(length(model.variable_to_zero_one)) binary variables, $(num_constraints(model, GenericAffExpr{Float64,VariableRef}, MOI.LessThan{Float64})) inequality constraints, and $(num_constraints(model, GenericAffExpr{Float64,VariableRef}, MOI.EqualTo{Float64})) equality constraints."
@info "Final problem has $(num_constraints(model, VariableRef, MOI.ZeroOne)) binary variables, $(num_constraints(model, GenericAffExpr{Float64,VariableRef}, MOI.LessThan{Float64})) inequality constraints, and $(num_constraints(model, GenericAffExpr{Float64,VariableRef}, MOI.EqualTo{Float64})) equality constraints."
end
return find_cycle(value.(tour_matrix)), objective_value(model)
end
Expand All @@ -270,4 +270,4 @@ function simple_parse_tsp(filename; verbose = true)
return cities
end

end # module
end # module
19 changes: 10 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ function test_tour(input, opt = TravelingSalesmanExact.get_default_optimizer();
return t, c
end

@testset "att48.tsp" begin
cities = simple_parse_tsp(joinpath(@__DIR__, "att48.tsp"))
sym_tour, sym_cost = test_tour(cities; distance = TravelingSalesmanExact.ATT, verbose = true)
@test sym_cost 10628

asym_tour, asym_cost = test_tour(cities; distance = TravelingSalesmanExact.ATT, symmetric = false)
@test asym_cost 10628
end

@testset "Small random asymmetric" begin
# chosen via rand(5,5)
Expand Down Expand Up @@ -91,4 +83,13 @@ end
TravelingSalesmanExact.reset_default_optimizer!()
@test_throws ArgumentError test_tour(cost)
set_default_optimizer!(with_optimizer(GLPK.Optimizer))
end
end

@testset "att48.tsp" begin
cities = simple_parse_tsp(joinpath(@__DIR__, "att48.tsp"))
sym_tour, sym_cost = test_tour(cities; distance = TravelingSalesmanExact.ATT, verbose = true)
@test sym_cost 10628

asym_tour, asym_cost = test_tour(cities; distance = TravelingSalesmanExact.ATT, symmetric = false)
@test asym_cost 10628
end

0 comments on commit 56698bf

Please sign in to comment.