Some files for talk about Productivity Hacks.
Last active
February 19, 2018 12:36
-
-
Save datawookie/d2863c14354a894a56dc22d4b7fd2f1f to your computer and use it in GitHub Desktop.
Files for Productivity Hacks talk.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for method in nearest_insertion farthest_insertion cheapest_insertion arbitrary_insertion nn repetitive_nn two_opt | |
do | |
sed "s/# \(.*${method}\)/\1/" travelling-salesman.R | R --slave & | |
done | |
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for method in nearest_insertion farthest_insertion cheapest_insertion arbitrary_insertion nn repetitive_nn two_opt | |
do | |
sed "s/# \(.*${method}\)/\1/" travelling-salesman.R | R --slave | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CONFIGURATION ------------------------------------------------------------------------------------------------------- | |
# METHOD = 'nearest_insertion' | |
# METHOD = 'farthest_insertion' | |
# METHOD = 'cheapest_insertion' | |
# METHOD = 'arbitrary_insertion' | |
# METHOD = 'nn' | |
# METHOD = 'repetitive_nn' | |
# METHOD = 'two_opt' | |
# Conversion factor. Set this to 1.60934 for length in km. | |
# | |
CONVERSION = 1.0 | |
# --------------------------------------------------------------------------------------------------------------------- | |
library(TSP) | |
# Distances between 312 cities in the USA and Canada. | |
# | |
data(USCA312) | |
solution = solve_TSP(USCA312, method = METHOD) | |
cat(sprintf("%-19s -> tour length = %d\n", METHOD, tour_length(solution) * CONVERSION)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment