Solving the TSP in a maze using ACO - algorithm

I'm writing an algorithm which includes a Traveling salesman problem (TSP) and a maze solving problem. Basically there are points inside the maze and we need to find the most optimal path to all those points and eventually exit the maze.
We started using an ACO algorithm to find the exit of the maze which works fine. But how would one integrate the TSP into it.
Our first guess would be reinforcement learning. Any ideas?

We figured out a way to do it. We decided to use a genetic algorithm where we encoded the order of each point in a chromosome. During each generation we ran the ACO algorithm for each chromosome and looked for the smalles amount of steps taken to reach the end goal.
It eventually converged or an iteration limit was hit.

Related

Greedy Algorithm vs Nearest Neighbor Algorithm

I'm doing an assignment on Travelling Salesman and I want to know the difference between the Greedy Algorithm and the Nearest Neighbor algorithm. I looked it up and they seemed almost the same to me. And there weren't any good resources tha compared them. What is their difference?
Actually, I'm having a hard time finding the similarity :) You talk about two very different algorithms here, for different kinds of problems.
Greedy algorithm is being used mainly for graphs, as it's supposed to solve staged-problems, when each stage requires us to make a decision. For example, when trying to find the shortest way from one point to another, it would choose each time the closest point to the current point it stands at.
K-NN is a lazy classification algorithm, being used a lot in machine learning problems. It calculates the class for a value depending on its distance from the k closest points in the set.
Thinking about it, you can actually say that each stage of the greedy algorithm uses a 1-Nearest-Neighbours algorithm to find the closest point, but it's pretty ridiculous... :)
Hope it's understandable!

Algorithm to visit all nodes in an un-directed graph with greatest efficiency?

So I have the following layout:
graph representation
The objective is to collect all the yellow blocks by moving the white ball around. I'm trying to come up with an algorithm that will calculate an efficient path however I'm not too sure where to start.
Initially I thought about path finding algorithms like Djikstra and A* but they don't seem to fit with my goal. I've also thought about hamiltonian paths which is closer to what I want but still doesn't seem to solve the problem.
Any suggestions on what sort of algorithm can be used would be appreciated.
Your problem has a classic name in the litterature, it is the minimum hamiltonian walk problem. Beware not to mistake it with the minimum hamiltonian path problem, its 'cousin', because it is much more famous, and much, much harder (finding a hamiltonian walk can be done in polynomial time, finding a hamiltonian path is NP-complete). The traveling salesman problem is the other name of the minimum hamiltonian path problem (path, not walk).
There are very few ressources on this problem, but nevertheless you can have a look at an article called 'An algorithm for finding a short closed spanning walk in a graph' by Takamizawa, Nishizeki and Saito from 1980. They provide a polynomial algorithm to find such a path.
If the paper is a bit hard to read, or the algorithm too complex to implement, then I'll suggest that you go for the christofides algorithm, because it runs in polynomial time, and is somehow efficient (it is a 2-approximation if I remember well).
Another possible approach would be to go for a greedy algorithm, like a nearest unvisited neigbor algorithm (start somewhere, go to the nearest node that is not in the walk yet, repeat until everyone is in the walk).
Acutally, I think the easiest and maybe best simple solution is to go greedy.

Travelling salesman (with predefined edges) heuristics?

I'm looking for an algorithm that is faster than exponential which will find ANY cycle in a traveling salesman problem. It doesn't matter how bad the cycle is, it just needs to be a cycle. What I'm really looking for, then, is an algorithm for a hamiltonian circuit. Something that will start at a point, reach all other points, and then end at the starting point on a graph like this: http://neogen.amdusers.com/wikipics/projects/tsp.png
So far I have found this random algorithm which did not seem to work for my example case:
http://www.princeton.edu/~achaney/tmve/wiki100k/docs/Hamiltonian_path_problem.html
And "Palmer's algorithm" which I'm having trouble understanding:
Palmer's Algorithm for Hamiltonian cycles
Are there more than these 2 algorithms for doing this?

Travelling salesman tips

I'm developing an application in which I have to face the travelling salesman problem. I did my own tries but the times I'm getting are really bad. I was searching some optimization solutions but I'm not getting anything clear.
Any tips to start a optimization of this process or algorythms? My current algorithm is the basic backtracking one.
My graph satisfy all the typical conditions in a TSP graph (no directional, simetric, conex)...
Thanks
If your metric satisfy the triangle inequality I can suggest you to look for the christofides algorithm. It has a guarantee to be within the optimum solution. IMO the difficult part about christofides algorithm is the perfect matching. If you don't care about a guarantee you can look for the google map tsp solver. It uses the Ant Colony Optimization for large route. If you want really fast solving and less accuracy you can look for a monster curve for example a hilbert curve or a moore curve.

Algorithm: shortest path between all points

Suppose I have 10 points. I know the distance between each point.
I need to find the shortest possible route passing through all points.
I have tried a couple of algorithms (Dijkstra, Floyd Warshall,...) and they all give me the shortest path between start and end, but they don't make a route with all points on it.
Permutations work fine, but they are too resource-expensive.
What algorithms can you advise me to look into for this problem? Or is there a documented way to do this with the above-mentioned algorithms?
Have a look at travelling salesman problem.
You may want to look into some of the heuristic solutions. They may not be able to give you 100% exact results, but often they can come up with good enough solutions (2 to 3 % away from optimal solutions) in a reasonable amount of time.
This is obviously Travelling Salesman problem. Specifically for N=10, you can either try the O(N!) naive algorithm, or using Dynamic Programming, you can reduce this to O(n^2 2^n), by trading space.
Beyond that, since this is an NP-hard problem, you can only hope for an approximation or heuristic, given the usual caveats.
As others have mentioned, this is an instance of the TSP. I think Concord, developed at Georgia Tech is the current state-of-the-art solver. It can handle upwards of 10,000 points within a few seconds. It also has an API that's easy to work with.
I think this is what you're looking for, actually:
Floyd Warshall
In computer science, the Floyd–Warshall algorithm (sometimes known as
the WFI Algorithm[clarification needed], Roy–Floyd algorithm or just
Floyd's algorithm) is a graph analysis algorithm for finding shortest
paths in a weighted graph (with positive or negative edge weights). A
single execution of the algorithm will find the lengths (summed
weights) of the shortest paths between all pairs of vertices though it
does not return details of the paths themselves
In the "Path reconstruction" subsection it explains the data structure you'll need to store the "paths" (actually you just store the next node to go to and then trivially reconstruct whichever path is required as needed).

Resources