How to calculate the distance between X and Y with Intersection points

Asked

Viewed 231 times

2

inserir a descrição da imagem aqui

In the image above I have mapped the separation positions within the warehouse where I work. I need to calculate how far the person you’re separating travels inside the warehouse. For example if the person is separating in the position 1AF-001-10 and moves to the position 1AD-013-10 if I calculate only X and Y he will calculate in a straight line but it will be wrong I need him to go through the points of intersection there is the problem. I don’t know how I’m gonna get him to understand which points he needs to pick up to calculate the right route when he gets off the streets he’s been searing. I placed the points of intersection that would be these links... and the right I just couldn’t figure out how to make him understand which points he needs to take. For example in this case the above should be calculated as follows:

    De           Para
1AF-001-10 || 1AD-013-10 = soma(valor1,valor2,valor3)

That is to say :

   De            Para
1AF-001-10  || interseçãoE = valor1

    De            Para
interseçãoE || interseçãoD = valor2

    De            Para
interseçãoD || 1AD-013-10 = valor3

1 answer

3

A brief response that will require certain research by the AP.

Model your problem as a graph and apply the algorithm A*. The nodes of your graph are their positions (1AF...). Each edge of your graph is the existing link between two locations. If there is no connection, it means that position X is not connected with position Y. The edge will also carry the distance information between each node.

The moment you have this graph mounted, just implement a smaller path algorithm (I indicated A*, but it may be the Dijkstra pure) and pass the initial and final node as parameters. The algorithm will return the shortest path between two locations, passing through all intermediate positions.

As I said, it will require an initial research effort, but it has so much example of graph on the Internet and so much tutorial that it will be worth, because it will solve the problem definitively.

  • Hello, good morning... first thank you for the answer, the problem is that I do not have access to all tools in our bank and there are things like this that you suggest I do not have access to do, I can only select and some functions this makes it difficult enough

  • If you have access to the database to select, nothing prevents you from creating a small program that queries that database, creates the graph and applies the algorithm.

  • 1

    Mr Cantoni is absolutely right. If you have the De-for individual and the distance between each, you can take the data and build such a program. Unfortunately, you’ll need to study some of the references he gave you. But one problem you will certainly have is that making this calculation every query can become computationally unfeasible (especially if many queries occur). Assuming that the locations do not change (because they are fixed in the warehouse), the ideal would be for you to pre-calculate the possible routes and store them in another table. Then your query becomes trivial. :)

  • Poxa now I felt like a donkey with you talking that is easy kkkkk. I will start searching why I am beginner in sql. but thank you so much for the tips, I’ll see what I can do

  • @Arielgonçalves, your challenge will not be in SQL, but in programming it in some language. There is a lot of support on the Internet. When I say it’s not complicated, it’s from my point of view. I completely understand your difficulty, but I can say that if you persist, you will get exactly what you want and with several more things that you will think about halfway through. If you like algorithms, it’s a great way to go. A tip: There are already frameworks and ready-made graph libraries. Mount the graph with database information and choose the algorithm.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.