I want to retrace maps from google earth these maps would then be used for calculating fastest route from A to B as well as location probability defined by some factors. How would i go about doing these? My first thought is pygame and using some already made ones or using them as a template.
I've worked on a routing application for a while. The most common algorithm for this is to start on both ends (start and finish) and move towards each other, traversing all possible methods of travel. The branches that meet in the middle will be your ideal path.
You can weight things appropriately, like speed limit, by setting checks in the code to only move x distance every time step.
These should do you:
Good graph traversal algorithm
Link
http://en.wikipedia.org/wiki/A*_search_algorithm/
Map Routing, a la Google Maps?
Have you looked at Google Maps, rather than Google Earth? This has roads and a routing engine.
Related
I am using the Google OR Tools vehicle routing implementation and am trying to incorporate traffic times into my time matrix by using the Google Maps API. However, the Google Maps API has limitations on how big of time matrices it can build, how many requests can be done in certain amounts of time, etc.
I know that the Google OR Tools VRP expects this time matrix, but I don't need the travel times between all combinations of all origins and destinations. For example, I am inputting pickup/dropoff pairs, for which it does not make sense to calculate the travel time from each dropoff to its assigned pickup. Additionally, perhaps I could also not calculate the travel time between locations that are far away (I'd establish some maximum distance) from one another. It would reduce the computational complexity to not have to call the API for these combinations and instead have certain constants as placeholders in the time matrix for these combinations.
Can this routing model be run in loops, such that for the first iteration I only calculate the travel times between the most likely assignments and inside each loop each driver gets assigned a pickup/dropoff pair and then in the next loop the travel times between already made assignments don't need to be calculated anymore? I don't even know if this would change the computation time.
Has anyone else had this problem before? I'd be interested in hearing any advice and/or additional heuristics to use.
VRP travel matrix required input is all the possible distance between visit location. You can reduce the complexity of the problem by assuming the distance between A to B is equal to B to A, this will also reduce the API call to the Google Map API. To be noted, the travel matrix shape must always be symmetrical.
The distance between locations is required for the VRP solving heuristic to find the next optimal nodes to be visited.
If you are certain that there are some locations that will not be visited after visiting some location, you can set the distance between those locations as Big M (i.e, sys.maxsize()). However, be careful with the direction constraint (pickup dropoff constraints), if you set Big M between the 2 locations that are linked by the constraint, the solver will definitely fail.
I'm producing an ugv prototype. The goal is to perform the desired actions to the targets set within the maze. When I surf the Internet, the mere right to navigate in the labyrinth is usually made with a distance sensor. I want to consult more ideas than the question.
I want to navigate the labyrinth by analyzing the image from the 3d stereo camera. Is there a resource or successful method you can suggest for this? As a secondary problem, the car must start in front of the entrance of the labyrinth, see the entrance and go in, and then leave the labyrinth after it completes operations in the labyrinth.
I would be glad if you suggest a source for this problem. :)
The problem description is a bit vague, but i'll try to highlight some general ideas.
An useful assumption is that labyrinth is a 2D environment which you want to explore. You need to know, at every moment, which part of the map has been explored, which part of the map still needs exploring, and which part of the map is accessible in any way (in other words, where are the walls).
An easy initial data structure to help with this is a simple matrix, where each cell represents a square in the real world. Each cell can be then labelled according to its state, starting in an unexplored state. Then you start moving, and exploring. Based on the distances reported by the camera, you can estimate the state of each cell. The exploration can be guided by something such as A* or Q-learning.
Now, a rather subtle issue is that you will have to deal with uncertainty and noise. Sometimes you can ignore it, sometimes you don't. The finer the resolution you need, the bigger is the issue. A probabilistic framework is most likely the best solution.
There is an entire field of research of the so-called SLAM algorithms. SLAM stands for simultaneous localization and mapping. They build a map using some sort of input from various types of cameras or sensors, and they build a map. While building the map, they also solve the localization problem within the map. The algorithms are usually designed for 3d environments, and are more demanding than the simpler solution indicated above, but you can find ready to use implementations. For exploration, something like Q-learning still have to be used.
I am creating an appEngine application in python that will need to perform efficient geospatial queries on datastore data. An example use case would be, I need to find the first 20 posts within a 10 mile radius of the current user. Having done some research into my options, I have found that currently what seems like the 2 best approaches for achieving this type of functionality would be:
Indexing geoHashed geopoint data using Python's GeoModel library
Creating/deleting documents of structured data using Google's newer SearchAPI
It seems from a high level perspective that indexing geohashes and performing queries on them directly would be less costly and much faster than having to create and delete a document for every geospatial query, however i've also read that geohashing can be very inaccurate along the equator or along 'faultlines' created by the hashing algorithm. I've seen very few posts contrasting the best methods in detail, and I think stack is a good place to have this conversation, so my questions are as follows:
Has anyone implemented similar features and had positive experiences with either methods?
Which method would be the cheaper alternative?
Which would be the faster alternative?
Is there another important method I'm leaving out?
Thanks in advance.
Geohashing does not have to be inaccurate at all. It's all in the implementation details. What I mean is you can check the neighbouring geocells as well to handle border-cases, and make sure that includes neighbours on the other side of the equator.
If your use case is finding other entities within a radius as you suggest, I would definitely recommend using the Search API. They have a distance function tailored for that use.
Search API queries are more expensive than Datastore queries yes, but if you weigh in the computation time to do these calculations in your instance and probably iterating through all entities for each geohash to make sure the distance is actually less than the desired radius, then I would say Search API is the winner. And don't forget about the implementation time.
You can have a look at this post, it can be another great alternative.
I have used this within my app and it works great for my requirement to find my app users with-in provided radius .
We are working on a project which involves running a shortest path algorithm on a big map.
We are using AStar with the Air Distance heaurstic for now.
Our project involves receiving updates to links in the database.
Currently we restart the search for each link update or at every predefined interval.
Is there a way to update the AStar algorithm to update the search without restarting the search on every update received? Is there a better algorithm suited for this task?
Disclosure: This is part of students project.
Thank you.
You might be looking for a routing algorithm (that by nature deals with constantly changing graphs).
One way to achieve it is with Distance Vector Routing Protocol (which is a distributed version of Bellman Ford algorithm) and works as follows1:
periodically, every vertex sends its "distances vector" to its
neighbors [the vector indicates how much it 'costs' to travel from the sending vertex, to each other vertex.
Its neighbors try to update their routing tables [through which edge is it best to move to the each target]
for your case, each node knows what is the fastest way to get to its neighbors (1 if the graph is unweighted) and it (the vertex) adds this number to each entree in the distance vector, in order to know how to and how much time it will take, to get to the destination. Every time a modification arrives, the relevant node will invoke a new iteration of the protocol until it re-converges.
Note however, that this algorithm is uninformed (but deals well with changing graphs, with certain limitations, there is still the count to infinity problem)
(1) The explanation of the algorithm is based on an explanation I provided some time back in this thread, with some modifications. (It is the same suggested algorithm after all).
I'm working on an adventure game in Python using Pygame. My main problem is how I am going to define the boundaries of the room and make the main character walk aroud without hitting a boundary every time. Sadly, I have never studied algorithms so I have no clue on how to calculate a path. I know this question is quite general and hard to answer but a point in the right direction would be very appreciated. Thanks!
There are two easy ways of defining your boundaries which are appropriate for such a game.
The simpler method is to divide your area into a grid, and use a 2D array to keep track of which squares in the grid are passable. Usually, this array stores your map information too, so in each position, there is a number that indicates whether that square contains grass or wall or road or mountain etc. (and therefore what picture to display). To give you a rough picture:
######
#.# #
# ## #
# #
######
A more complex method which is necessary if you want a sort of "maze" look, with thin walls, is to use a 2D array that indicates whether there is a vertical wall in between grid squares, and also whether there is a horizontal wall between grid squares. A rough picture (it looks a stretched in ASCII but hopefully you'll get the point):
- - - -
| | |
- -
| |
- - - -
The next thing to decide is what directions your character may move in (up/down/left/right is easiest, but diagonals are not too much harder). Then the program basically has to "mentally" explore the area, starting from your current position, hoping to come across the destination.
A simple search that is easy to implement for up/down/left/right and will find you the shortest path, if there is one, is called Breadth-First search. Here is some pseudocode:
queue = new Queue #just a simple first-in-first-out
queue.push(startNode)
while not queue.empty():
exploreNode = queue.pop()
if isWalkable(exploreNode): #this doesn't work if you use
#"thin walls". The check must go
#where the pushes are instead
if isTarget(exploreNode):
#success!!!
else:
#push all neighbours
queue.push( exploreNode.up )
queue.push( exploreNode.down )
queue.push( exploreNode.left )
queue.push( exploreNode.right )
This algorithm is slow for large maps, but it will get you used to some graph-search and pathfinding concepts. Once you've verified that it works properly, you can try replacing it with A* or something similar, which should give the same results in less time!
A* and many other searching algorithms use a priority queue instead of a FIFO queue. This lets them consider "more likely" paths first, but get around to the roundabout paths if it turns out that the more direct paths are blocked.
I recommend you read up on the A* search algorithm as it is commonly used in games for pathing problems.
If this game is two dimensional (or 2.5) I suggest you use a tile system as checking for collisions will be easier. Theres lots of information online that can get you started with these.
Sadly, I have never studied algorithms so I have no clue on how to calculate a path.
Before you start writing games, you should educate yourself on those. This takes a little more effort at the beginning, but will save you much time later.
I am not familiar with pygame, but many applications commonly use bounding volumes to define the edge of some region. The idea is that as your character walks, you will check if the characters volume intersects with the volume of a wall. You can then either adjust the velocity or stop your character from moving. Use differing shapes to get a smooth wall so that your character doesn't get stuck on the pointy edges.
These concepts can be used for any application which requires quick edge and bounds detection.