Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #7

Merged
merged 12 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
using TSPLIB
  • Loading branch information
chkwon committed Feb 25, 2021
commit d0bd316575fbd88a9e21bf216335bdf9653697b7
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ version = "0.1.0"
[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
TSPLIB = "b1c258e7-59ae-4b06-a547-f10871db1548"

[compat]
julia = "1"
Expand Down
3 changes: 3 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Libdl

import Pkg
Pkg.add(url="https://github.com/matago/TSPLIB.jl")

const QSOPT_LOCATION = Dict(
"Darwin" => [
"https://www.math.uwaterloo.ca/~bico/qsopt/beta/codes/mac64/qsopt.a",
Expand Down
9 changes: 7 additions & 2 deletions src/Concorde.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Concorde

using Random, LinearAlgebra
using TSPLIB

include("../deps/deps.jl")
include("dist.jl")
Expand Down Expand Up @@ -29,7 +30,7 @@ end


function cleanup(name)
exts = ["mas", "pul", "sav", "sol", "tsp"]
exts = ["mas", "pul", "sav", "sol", "tsp", "res"]
for ext in exts
file = "$(name).$(ext)"
rm(file, force=true)
Expand Down Expand Up @@ -142,8 +143,12 @@ function solve_tsp(tsp_file::String)

sol_filepath = name * ".sol"
opt_tour = read_solution(sol_filepath)
opt_len = - 1 # Need to implement the calculation of the obj function
# opt_len = - 1 # Need to implement the calculation of the obj function

tsp = TSPLIB.readTSP(filepath)
M = Int.(tsp.weights)
opt_len = tour_length(opt_tour, M)

cleanup(name)

return opt_tour, opt_len
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using Test

@testset "Input File" begin
opt_tour, opt_len = solve_tsp("gr17.tsp")
@test opt_len == -1
# @test opt_len == 2085
# @test opt_len == -1
@test opt_len == 2085
end
end