-3

I am using neural network algorithm to search optimal tour in multiple locations in longitude and latitude. I am using 2D Euclidean space.

Output for result of tsp distance

How to convert this TSP distance to real distance like meter or kilometer in python?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Dave
  • 1
  • 2
  • This question is not very clear. Maybe you want to get the formula to calculate the distance between two points in (long,lat) format and do all the algorithm in meters. But computing the distance between these points by using Pythagoras and then trying to convert the resulting number to a distance will not work. – rodrigo May 29 '17 at 17:06
  • And please, do not post images of text, copy-paste the relevant text into your question. – rodrigo May 29 '17 at 17:07
  • No, i am already get solution to calculate. But, the results is using tsp distance unit. The distance not in kilometer or meter. I am confused how to get the real distance @rodrigo – Dave May 29 '17 at 17:08
  • 2
    What is a tsp distance unit? – rodrigo May 29 '17 at 17:22
  • Use eucledian distance 2D @rodrigo – Dave May 29 '17 at 17:30
  • @rodrigo: tsp == Traveling Salesman Problem (although that still doesn't explain much) – martineau May 29 '17 at 17:34
  • See question [**_Calculate distance between two latitude-longitude points? (Haversine formula)_**](https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula). Also see [info about Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula). – martineau May 29 '17 at 17:41
  • I'm guessing that you are using the euclidean distance (ie. Pythagoras theorem) using as X and Y the latitude and longitude directly. That is wrong: lat. and long. measure angles, not distances so to compute those distances you cannot use Pythagoras, you need a different formula (see martineau comment). – rodrigo May 30 '17 at 07:37

1 Answers1

0

You can use the haversine distance, see the Haversine formula on Wikipedia. That still presumes your vehicles can fly as the crow flies.


I've done a number of experiments to compare the impact of using eucledian distance, real road distances and real road times, using OptaPlanner on the Vehicle Routing Problem with the Belgium datasets. It matters for about 4%.

enter image description here

PS: To search optimal tour in multiple locations, use Local Search, not Neural Nets (and visa versa for image recognition). Use the right tool for the job. See academic challenges for proof.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120