This commit is contained in:
Thomas (Tom) C. Gorordo 2024-05-22 02:34:34 -07:00
parent 98da744bf0
commit 0cee74ff54
Signed by: tgorordo
GPG key ID: 0CBED22BB0D94490
3 changed files with 6 additions and 19 deletions

3
.gitignore vendored
View file

@ -1 +1,4 @@
index.html index.html
LAVegas.osm
traveling-tommys.html
traveling-tommys.pdf

File diff suppressed because one or more lines are too long

View file

@ -202,7 +202,8 @@ function build_tsp_model(m)
model = Model(GLPK.Optimizer) model = Model(GLPK.Optimizer)
@variable(model, x[1:n, 1:n], Bin, Symmetric) @variable(model, x[1:n, 1:n], Bin, Symmetric)
@objective(model, Min, sum(m .* x) / 2) @objective(model, Min, sum(m .* x) / 2)
@constraint(model, [i in 1:n], sum(x[i, :]) == 2) @constraint(model, [i in 1:n], sum(x[i, [j for j in 1:n if j != i]]) == 1)
@constraint(model, [j in 1:n], sum(x[[i for i in 1:n if i != j], j]) == 1)
@constraint(model, [i in 1:n], x[i, i] == 0.) @constraint(model, [i in 1:n], x[i, i] == 0.)
return model return model
end end