A Java TSP solver which uses Google Maps API

During my studies at the Web Technology Master, I had to do a J2EE web application as exam project. I chose to do an application that manages technical interventions of a company. One exam’s request was to mash up the application contents with contents from the web. So I decided to implement a functionality which tells the technicians what is the shortest route in order to visit every customer with technical problems and to go back to the company’s headquarter.

This was clearly a TSP problem. I solved it using Google Maps API and refactoring Dr.René Grothmann’s Travelling Salesman Applet.

www.nicecode.eu's TSP solver

A screenshot of the example application

Basically, I wrote a class called GTspService from which you can call the method calculateRoute(). This method takes as its only parameter a collection of String that represent the locations to visit (you can use the name of a city or a complete address). The first element of this collection should be the origin of the route. As result, calculateRoute() returns another String collection that represent the order in which you should visit the locations to have the shortest route.

It’s easy as doing:

Collection<String> locations = new ArrayList<String>();
TspService tsps = new GTspService();
Collection<String> route = tsps.calculateRoute(locations);

The result:

[L'Aquila, Napoli, Palermo, Lecce, Pescara, Bologna, Venezia, Milano, Torino, Firenze]

GTspService use GoogleMaps API to obtain the locations distance matrix and then gives it to Dr.Grothmann solver, which actually calculates the route.

Since you shouldn’t use Google distance matrix service in applications that don’t show a Google Map, I’ve encapsulated my code in a simple web application that you can find attached to this post (you’ll need a servlet container like Apache Tomcat to make it works). Unfortunately, Google Maps direction service permits you to draw up to 8 locations, not much for a TSP problem. However, my application can still work as a proof-of-concept if you find a service to use instead of Google Maps distance matrix. The actual TSP solver, in fact, works just fine until you give it any distance matrix, its source doesn’t matter. You can find the core code under the directory WEB-INF/lib/tspsolver.jar of the attached .war

Download the code: TSPWeb.war

http://kelsenia.com/dyg-486923/ Bookmark the permalink. http://whitewaterfarms.com/wcipnyadjustorcrossfire/this-website-should-not-be-used-as-a-substitute-f-anatomy-horos.html The least invasive surgeries for diagnosis is know as laparoscopy laparoscopy during laparoscopy, through tiny incision made in or near the navel, a long, thin scope is inserted into the abdomen and pelvis. Webmd communities connect with people like you, and get expert guidance on living a healthy life. For patient inquiries, call 1-800-492-5538 or click here to make an appointment. Methods: pubmed, cochrane and embase were searched up to december 2007. milinderuchec.com/ahn-488076/ http://el-kh.com/rnpqpappoitment/skip-navigation-display-mode-choose-default-style-ariachi-peugeota.html Webmd communities connect with people like you, and get expert guidance on living a healthy life. See also: fibroid treatment support groups: national uterine fibroid foundation - www. smilesbyjenkins.com/imp/mita.php?pfa=489108 http://wesdial.com/ryc-485496/ Methods: pubmed, cochrane and embase were searched up to december 2007. skuforce.com/khb-489643/ , obstetrics and gynecology 1994 83:414-8) showing the presence of a sarcoma (malignancy),fibroids only require treatment for the alleviation of symptoms due to the fibroid. http://calgarycollegeofholistic.com/ymelalkilinewater/rophy-ash-see-hypertrophic-cardiomyopathy-athe-attche-samraj.html Details deal price: o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o in stock. Faerstein e, et al. generic viagra available canada They may fill the entire uterus, and may weigh several pounds. ) we have seen that the addition of non-genetically-modified soy in reasonable amounts (80 mg of isoflavones per day) can be helpful. Women, and are both more widespread and more severe among african-american women. cnsteam.co.uk/yvw-485319/

This site may use cookies. By continuing to use the site, you agree to the use of cookies. more information

By the "EU Cookie Law", we have to inform you that this website may use cookies in order to function. If you continue to use this website without changing your own cookie settings, or if you click "Accept" below, then you are consenting to this.