I'm working in a scientific article about some algorithms that can solve a maze, the A* can do this job by modifying the original code. I tried to find goods references about it, without success. there are others algorithm that I found trustful references without so much difficult, but the A* modified to find the shortest-path in a maze is really hard to find...
This page is actually first page for on google when searching for A* references, so i've returned now I have found something. Eventually I came across its first description in an IEEE Journal.
Hart, P. E., N. J. Nilsson, and B. Raphael (1968) A Formal Basis for
the Heuristic Determination of Minimum Cost Paths in Graphs. IEEE
Trans. on Systems Science and Cybernetics, Vol. SSC-4, No. 2, pp
100-107.
Related
I am working on optimization using evolutionary algorithm, specifically SPEA-II. I was curious if there is any algorithm named SPEA-III. I tried googling but I could only find a proposed modification of the SPEA-II using reference search direction. Is it same as SPEA-III, in case of NSGA-III, this is the probably only difference from NSGA-II.
I was able find a reference paper on SPEA3, the authors have proposed what they called a generalization of SPEA2 algorithm and name it as SPEA3.
What are concrete examples (e.g. Alpha-beta pruning, example:tic-tac-toe and how is it applicable there) of heuristics. I already saw an answered question about what heuristics is but I still don't get the thing where it uses estimation. Can you give me a concrete example of a heuristic and how it works?
Warnsdorff's rule is an heuristic, but the A* search algorithm isn't. It is, as its name implies, a search algorithm, which is not problem-dependent. The heuristic is. An example: you can use the A* (if correctly implemented) to solve the Fifteen puzzle and to find the shortest way out of a maze, but the heuristics used will be different. With the Fifteen puzzle your heuristic could be how many tiles are out of place: the number of moves needed to solve the puzzle will always be greater or equal to the heuristic.
To get out of the maze you could use the Manhattan Distance to a point you know is outside of the maze as your heuristic. Manhattan Distance is widely used in game-like problems as it is the number of "steps" in horizontal and in vertical needed to get to the goal.
Manhattan distance = abs(x2-x1) + abs(y2-y1)
It's easy to see that in the best case (there are no walls) that will be the exact distance to the goal, in the rest you will need more. This is important: your heuristic must be optimistic (admissible heuristic) so that your search algorithm is optimal. It must also be consistent. However, in some applications (such as games with very big maps) you use non-admissible heuristics because a suboptimal solution suffices.
A heuristic is just an approximation to the real cost, (always lower than the real cost if admissible). The better the approximation, the fewer states the search algorithm will have to explore. But better approximations usually mean more computing time, so you have to find a compromise solution.
Most demonstrative is the usage of heuristics in informed search algorithms, such as A-Star. For realistic problems you usually have large search space, making it infeasible to check every single part of it. To avoid this, i.e. to try the most promising parts of the search space first, you use a heuristic. A heuristic gives you an estimate of how good the available subsequent search steps are. You will choose the most promising next step, i.e. best-first. For example if you'd like to search the path between two cities (i.e. vertices, connected by a set of roads, i.e. edges, that form a graph) you may want to choose the straight-line distance to the goal as a heuristic to determine which city to visit first (and see if it's the target city).
Heuristics should have similar properties as metrics for the search space and they usually should be optimistic, but that's another story. The problem of providing a heuristic that works out to be effective and that is side-effect free is yet another problem...
For an application of different heuristics being used to find the path through a given maze also have a look at this answer.
Your question interests me as I've heard about heuristics too during my studies but never saw an application for it, I googled a bit and found this : http://www.predictia.es/blog/aco-search
This code simulate an "ant colony optimization" algorithm to search trough a website.
The "ants" are workers which will search through the site, some will search randomly, some others will follow the "best path" determined by the previous ones.
A concrete example: I've been doing a solver for the game JT's Block, which is roughly equivalent to the Same Game. The algorithm performs a breadth-first search on all possible hits, store the values, and performs to the next ply. Problem is the number of possible hits quickly grows out of control (10e30 estimated positions per game), so I need to prune the list of positions at each turn and only take the "best" of them.
Now, the definition of the "best" positions is quite fuzzy: they are the positions that are expected to lead to the best final scores, but nothing is sure. And here comes the heuristics. I've tried a few of them:
sort positions by score obtained so far
increase score by best score obtained with a x-depth search
increase score based on a complex formula using the number of tiles, their color and their proximity
improve the last heuristic by tweaking its parameters and seeing how they perform
etc...
The last of these heuristic could have lead to an ant-march optimization: there's half a dozen parameters that can be tweaked from 0 to 1, and an optimizer could find the optimal combination of these. For the moment I've just manually improved some of them.
The second of this heuristics is interesting: it could lead to the optimal score through a full depth-first search, but such a goal is impossible of course because it would take too much time. In general, increasing X leads to a better heuristic, but increases the computing time a lot.
So here it is, some examples of heuristics. Anything can be an heuristic as long as it helps your algorithm perform better, and it's what makes them so hard to grasp: they're not deterministic. Another point with heuristics: they're supposed to lead to quick and dirty results of the real stuff, so there's a trade-of between their execution time and their accuracy.
A couple of concrete examples: for solving the Knight's Tour problem, one can use Warnsdorff's rule - an heuristic. Or for solving the Fifteen puzzle, a possible heuristic is the A* search algorithm.
The original question asked for concrete examples for heuristics.
Some of these concrete examples were already given. Another one would be the number of misplaced tiles in the 15-puzzle or its improvement, the Manhattan distance, based on the misplaced tiles.
One of the previous answers also claimed that heuristics are always problem-dependent, whereas algorithms are problem-independent. While there are, of course, also problem-dependent algorithms (for instance, for every problem you can just give an algorithm that immediately solves that very problem, e.g. the optimal strategy for any tower-of-hanoi problem is known) there are also problem-independent heuristics!
Consequently, there are also different kinds of problem-independent heuristics. Thus, in a certain way, every such heuristic can be regarded a concrete heuristic example while not being tailored to a specific problem like 15-puzzle. (Examples for problem-independent heuristics taken from planning are the FF heuristic or the Add heuristic.)
These problem-independent heuristics base on a general description language and then they perform a problem relaxation. That is, the problem relaxation only bases on the syntax (and, of course, its underlying semantics) of the problem description without "knowing" what it represents. If you are interested in this, you should get familiar with "planning" and, more specifically, with "planning as heuristic search". I also want to mention that these heuristics, while being problem-independent, are dependent on the problem description language, of course. (E.g., my before-mentioned heuristics are specific to "planning problems" and even for planning there are various different sub problem classes with differing kinds of heuristics.)
I am wondering whether the Wavefront algorithm (or any other navigation algorithm), can be modified from trying to reach a a specific goal location to navigate to all reachable locations.
Any other advice on different types of WaveFront algorithm would also be helpful.
I have visited your site. You stated that the robot can receive commands like "Go to ketchen". Well, I advice not to re-invent the wheel. Actually, you don't have to visit every cell, or "the hole area". Rather, you should select your shortest path to it, then walk through.
I believe Dijkstra's algorithm is much better for your robot path-finding.
An enhaced version of Dijkstra is A* algorithm, which takes less time in the average case.
Here you can find examples how do they work, efficiently.
EDIT:
I have visited your site, again. You stated that you want an algorithm for navigating all the erea. Well, as far as I know, repeating A* algorithm will be much better. A* uses BFS, which has a better performance in the average case. It's very efficient when compared whith wavefront. The pseudocode is as following:
A) Find the shortest path with A* algorithm between the location and the goal
B) If there is no way to the goal, specify a temp location and move to it. (Since you
indicated, it may find a way later). After arrived to temp location, Go to step A.
C) Otherwise, if you have found a way, navigate to the target.
This 1993 paper introduced a variant of the vanilla wave-front planner that achieves complete coverage, in addition to navigation from start to goal:
A. Zelinsky, R.A. Jarvis, J.C. Byrne, S. Yuta, "Planning paths of
complete coverage of an unstructured environment by a mobile robot,"
Proceedings of the International Conference on Advanced Robotics,
1993, pp. 533-538.
Also see the following review paper for more ideas on coverage path planning:
Enric Galceran, Marc Carreras, "A survey on coverage path planning for
robotics," Robotics and Autonomous Systems, Volume 61, Issue 12,
December 2013, Pages 1258-1276.
I am looking for a name for this problem or any leads on an algorithm or source code:
Example: You want to find the best route to visit the 100 largest cities in the US (classic TSP) but before you can visit any given city you must visit the capital of the state it is in.
Example: You are collecting permission slips from the students of several professors. You need to visit every student and every professor but you can't visit a professor until you have seen all of his students.
Some Googling turns up the sequential ordering problem or "SOP" but there is not so much literature that I am convinced that this is a widely accepted name.
I don't think these partial orderings can be represented within the classic TSP simply by choosing which edges to use in the graph (e.g. you can't initially go from New York to Chicago, but once you visit Springfield you can) or weights, but I may be wrong.
The Sequential Ordering Problem was first introduced by Escudero in 1988 in a paper entitled "An Inexact Algorithm for the Sequential Ordering Problem" (this appeared in the European Journal of Operational Research), so this is the original name for the problem. The abstract of the paper reads:
Given the directed G= (N, A) and the
penalty matrix C, the Sequential
Ordering Problem (hereafter, SOP)
consists of finding the permutation of
the nodes from the set N, such that it
minimizes a C-based function and does
not violate the precedence
relationships given by the set A.
Strong sufficient conditions for the
infeasibility of a SOP's instance are
imbedded in a procedure for the SOP's
preprocessing. Note that it is one of
the key steps in any algorithm that
attempts to solve SOP. By dropping the
constraints related to the precedence
relationships, SOP can be converted in
the classical Asymmetric Traveling
Salesman Problem (hereafter, ATSP).
The algorithm obtains (hopefully)
satisfactory solutions by modifying
the optimal solution to the related
Assignment Problem (hereafter, AP) if
it is not a Feasible Sequential
Ordering (hereafter, FSO). The new
solution 'patches' the subtours (if
any) giving preference to the patches
with zero reduced cost in the linking
arcs. The AP-based lower bound on the
optimal solution to ATSP is tightened
by using some of the procedures given
in [1]. In any case, a local search
for improving the initial FSO is
performed; it uses 3- and 4-change
based procedures. Computational
results on a broad set of cases are
reported.
Escudero and his collaborators have a number of papers on the subject, with references to even more. Searching for papers by him or that reference this paper may help you if you're looking through the literature.
SOP is a well-studied constrained version of the Asymmetric Travelling Salesman Problem, so much of the literature on ATSP may be related.
You could build a state machine that takes into account the ordering requirements, annotate the transitions with your weights, and solve the traveling salesman on that. Except you'd have a lot more nodes: 2^(number of capitals) times the original number of nodes.
Given a list of cities and the cost to fly between each city, I am trying to find the cheapest itinerary that visits all of these cities. I am currently using a MATLAB solution to find the cheapest route, but I'd now like to modify the algorithm to allow the following:
repeat nodes - repeat nodes should be allowed, since travelling via hub cities can often result in a cheaper route
dynamic edge weights - return/round-trip flights have a different (usually lower) cost to two equivalent one-way flights
For now, I am ignoring the issue of flight dates and assuming that it is possible to travel from any city to any other city.
Does anyone have any ideas how to solve this problem? My first idea was to use an evolutionary optimisation method like GA or ACO to solve point 2, and simply adjust the edge weights when evaluating the objective function based on whether the itinerary contains return/round-trip flights, but perhaps somebody else has a better idea.
(Note: I am using MATLAB, but I am not specifically looking for coded solutions, more just high-level ideas about what algorithms can be used.)
Edit - after thinking about this some more, allowing "repeat nodes" seems to be too loose of a constraint. We could further constrain the problem so that, although nodes can be repeatedly visited, each directed edge can only be visited at most once. It seems reasonable to ignore any itineraries which include the same flight in the same direction more than once.
I haven't tested it myself; however, I have read that implementing Simulated Annealing to solve the TSP (or variants of it) can produce excellent results. The key point here is that Simulated Annealing is very easy to implement and requires minimal tweaking, while approximation algorithms can take much longer to implement and are probably more error prone. Skiena also has a page dedicated to specific TSP solvers.
If you want the cost of the solution produced by the algorithm is within 3/2 of the optimum then you want the Christofides algorithm. ACO and GA don't have a guaranteed cost.
Solving the TSP is a NP-hard problem for its subcycles elimination constraints, if you remove any of them (for your hub cities) you just make the problem easier.
But watch out: TSP has similarities with association problem in the meaning that you could obtain non-valid itineraries like:
Cities: New York, Boston, Dallas, Toronto
Path:
Boston - New York
New York - Boston
Dallas - Toronto
Toronto - Dallas
which is clearly wrong since we don't go across all cities.
The subcycle elimination constraints serve just to this purpose. Including a 'hub city' sounds like you need to add weights to the point and make an hybrid between flux problems and tsp problems. Sounds pretty hard but the first try may be: eliminate the subcycles constraints relative to your hub cities (and leave all the others). You can then link the subcycles obtained for the hub cities together.
Good luck
Firstly, what is approximate number of cities in your problem set? (Up to 100? More than 100?)
I have a fair bit of experience with GA (not ACO), and like epitaph says, it has a bit of gambling aspect. For some input, it might stop at a brutally inefficient solution. So, what I have done in the past is to use GA as the first option, compare the answer to some lower bound, and if that seems to be "way off", then run a second (usually a less efficient) algorithm.
Of course, I used plenty of terms that were not standard, so let us make sure that we agree what they would be in this context:
lower bound - of course, in this case, MST would be a lower bound.
"Way Off" - If triangle inequality holds, then an upper bound is UB = 2 * MST. A good "way off" in this context would be 2 * UB.
Second algorithm - In this case, both a linear programming based approach and Christofides would be good choices.
If you limit the problem to round-trips (i.e. the salesman can only buy round-trip tickets), then it can be represented by an undirected graph, and the problem boils down to finding the minimum spanning tree, which can be done efficiently.
In the general case I don't know of a clever way to use efficient algorithms; GA or similar might be a good way to go.
Do you want a near-optimal solution, or do you want the optimal solution?
For the optimal solution, there's still good ol' brute force. Due to requirement 1 involving repeat nodes, you'll have to make sure you search breadth-first, not dept-first. Otherwise you can end up in an infinite loop. You can slowly drop all routes that exceed your current minimum until all routes are exhausted and the minimal route is discovered.