{"id":235,"date":"2015-02-08T00:53:06","date_gmt":"2015-02-07T19:53:06","guid":{"rendered":"https:\/\/learnsf.wordpress.com\/?p=235"},"modified":"2015-02-08T00:53:06","modified_gmt":"2015-02-07T19:53:06","slug":"trying-to-resolve-the-travelling-salesman-problem-in-salesforce","status":"publish","type":"post","link":"https:\/\/blog.felineflock.com\/index.php\/2015\/02\/08\/trying-to-resolve-the-travelling-salesman-problem-in-salesforce\/","title":{"rendered":"Trying to resolve the Travelling Salesman Problem in Salesforce"},"content":{"rendered":"<p>Below is a screen showing one attempt at finding the best route to visit several accounts using the Artificial Bee Colony algorithm. The best route is defined as the route with minimal\u00a0total sum\u00a0of the distances between accounts. In other words, the route to spent the least amount of time and gas.<\/p>\n<p>I am not sure anyone has ever had that problem to resolve in a\u00a0Salesforce application but I found it was a good way to test my implementation of the Artificial Bee Colony (ABC) optimization algorithm, which could be used in many other optimization problems.<\/p>\n<p>This implementation offers a fairly good approximation of the best route &#8211; definitely not the best route as you can see below: \u00a0you would go from Plano to Richardson before Garland and then from Garland to Mesquite to save a few miles\/gallons.<\/p>\n<figure id=\"attachment_237\" aria-describedby=\"caption-attachment-237\" style=\"width: 762px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-08-16-pm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-237\" src=\"http:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-08-16-pm.png?w=300\" alt=\"Travelling Salesman Problem in the DFW\" width=\"762\" height=\"479\" \/><\/a><figcaption id=\"caption-attachment-237\" class=\"wp-caption-text\">Travelling Salesman Problem in the DFW<\/figcaption><\/figure>\n<p>The implementation is split into 2 main classes: \u00a0the Hive, which implements the ABC algorithm, and the\u00a0TravellingSalesmanProblem class,\u00a0which\u00a0is in charge of storing the accounts latitude\/longitude, calculate the distances between accounts and getting the next best route.<\/p>\n<p>Another interesting part is the Javascript code that uses the Google Map API to plot the route.<\/p>\n<figure id=\"attachment_239\" aria-describedby=\"caption-attachment-239\" style=\"width: 755px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-54-56-pm.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-239\" src=\"http:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-54-56-pm.png?w=300\" alt=\"Plotting using the Google Map API\" width=\"755\" height=\"410\" srcset=\"https:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-54-56-pm.png 1678w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-54-56-pm-300x163.png 300w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-54-56-pm-1024x558.png 1024w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-54-56-pm-768x418.png 768w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2015\/02\/screen-shot-2015-02-07-at-1-54-56-pm-1536x837.png 1536w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><\/a><figcaption id=\"caption-attachment-239\" class=\"wp-caption-text\">Plotting using the Google Map API<\/figcaption><\/figure>\n<p>Other potential applications of the Travelling Salesman Problem could be:<\/p>\n<ul>\n<li>deciding the different routes each truck should follow in a delivery\/courier company fleet<\/li>\n<li>wiring together memory elements in digital circuits in a sequence to minimize length of wire<\/li>\n<li>finding a sequence of advertising spots where ads from one company would not be shown immediately after its competitor (say, keep a Coke\u00a0ad away from an Pepsi\u00a0ad)<\/li>\n<li>in robotic welding, find a good sequence of tasks and path for the robot arm to weld the seams faster<\/li>\n<li>likewise, find the optimum path for a CNC machine to drill multiple holes<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Below is a screen showing one attempt at finding the best route to visit several accounts using the Artificial Bee Colony algorithm. The best route is defined as the route with minimal\u00a0total sum\u00a0of the distances between accounts. In other words, the route to spent the least amount of time and gas. I am not sure [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":237,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[13],"tags":[20,21,23],"class_list":["post-235","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-no-category","tag-artifical-bee-colony","tag-optimization","tag-travelling-salesman-problem"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/comments?post=235"}],"version-history":[{"count":0,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/posts\/235\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/media\/237"}],"wp:attachment":[{"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}