Quantcast
Channel: Search Results for “maps”– R-bloggers
Viewing all articles
Browse latest Browse all 589

The Traveling Salesman with Simulated Annealing, R, and Shiny

$
0
0

(This article was first published on Category: R | Todd W. Schneider, and kindly contributed to R-bloggers)

Make your own tour with the interactive Shiny app

Here’s the Shiny app that lets you pick up to 30 cities on the map, set some parameters of the annealing schedule, then run the actual simulated annealing process (or just click ‘solve’ if you’re lazy). Give it a shot below! Bonus points if you recognize where the default list of cities comes from…

The app is hosted at ShinyApps.io, which is currently in alpha testing, so I’m not entirely sure how reliable it will be. If you want to run the app on your local machine, it’s very easy, all you need to do is paste the following into your R console:

1
2
3
install.packages(c(&ldquo;shiny&rdquo;, &ldquo;maps&rdquo;, &ldquo;geosphere&rdquo;), repos=&ldquo;<a href="http://cran.rstudio.com/">http://cran.rstudio.com/</a>&rdquo;)
library(shiny)
runGitHub(&ldquo;shiny-salesman&rdquo;, &ldquo;toddwschneider&rdquo;)

Code on GitHub

The full code is available at https://github.com/toddwschneider/shiny-salesman

Around the World in 80,000 Miles

Here’s another animated gif using a bunch of world capitals. The “solution” here is almost certainly not the global optimum, but it’s still fun to watch!

To leave a comment for the author, please follow the link and comment on his blog: Category: R | Todd W. Schneider.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

Viewing all articles
Browse latest Browse all 589

Trending Articles