I have been looking at a lot of graph searches -both informed and uninformed. I have also looked at and coded some optimization problems such as hill-climbing. My question is, how can I relate the two types of algorithms?
To be a little more clear, here is an example:
Let's say I run a graph algorithm like Depth first Iterative Deepening. I run it for one depth and get a goal node, then I run it again at a different depth and find a goal node and so on. So now, I have a set of possible goal nodes. Could I run an optimization algorithm like hill climbing to find which one is "optimal" according to different limitations?
One of the notions you encounter in graph search algorithms is optimality. You should consider that here optimality is just about the algorithm and not about the goal. Meaning that, if an algorithm is optimal it should return the minimum cost solution.
Now, if you want to optimize something it's completely a different problem. In this case the quality of the solution is of most importance not the way you achieve it.
Algorithms like Genetic Algorithms, PSO, ... and many more optimization methods exists to address this issue.
BTW, sometimes we combine a graph search method like A* with an optimization algorithm to gain better results from the optimization algorithm.
Note: The term Graph Optimization is not related to the topic Graph Search that I think is your main topic according to your question.
Related
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!
I've been looking for an algorithm to efficiently compute an edit path between two trees, a path that does not have to correspond to shortest edit distance but preferably a relatively short one.
The case is that I have two directory trees, consisting of directories and files, and want to compute a sequence of deletes, inserts and renames that will transform one to the other.
I have tried searching both stackoverflow and the wild web but all I find is algorithms for computing shortest edit distance, but they all have high scaling factors.
So my question is, is there any more efficient way then for example "Zhang and Shasha" when I don't need the optimum distance?
Kind regards
There is the Klein algorithm that performs slightly better than "Zhang and Sasha", however it remains of very high complexity in both space and time for practical purpose.
There is an algorithm here that is in fact an heuristic, since the authors misused the term approximation.
It reduces the problem to a series of maximum weighted cliques for which it exists several approximation and heuristics, even a greedy approach could here perform reasonably well.
What is true for graphs is true for trees, you could therefore use a graph kernel convolution approach.
If you are looking for an off the shelf implementation (of an unspeficied algorithm, I woudl guess Zhang or Klein), you can check here
I want to find a low-cost path between two vertices on a directed graph where the cost of each edge is the same. Ease of implementing the algorithm and performance time are very important, so I am willing to sacrifice an optimal solution for one that is near-optimal, if the algorithm is simpler and quicker.
An edge can be blocked by an obstacle. The probability that an edge is blocked is known beforehand. Blockages are independent of each other. An edge is found to be unblocked or blocked when the vertex at the head of the edge is reached.
My problem is similar to the Canadian Traveller Problem, but my understanding is that solutions for stochastic programming problems are relatively difficult to implement, and the time taken to find an optimal policy can be relatively high.
At the moment, I am thinking of converting the problem into a deterministic one so that it can be solved using a search algorithm like A*. Is this a good approach, and if so, how can I do this?
This problem is a partially observable Markov decision process (POMDP). POMDPs can be solved deterministically, but usually use a randomized algorithm to find an approximately-optimal solution. Finding the true optimum policy does not have a polynomial time solution, and even approximate solutions can be slow. On the upside, once you've found the policy, following it is fast.
Some of the available solvers:
ZMDP
Symbolic Perseus
APPL
pomdp-solve
SPUDD
I'm working on making some code using metaheuristics for finding good solutions to the Fixed Charge Transportation Problem (FCTP).
The problem I'm having is to generate a starting solution, based on finding a spanning tree for the underlying bipartite graph.
I want it to be a random spanning tree, so that I can run the procedure on the same problem multiple times, possibly getting different solutions.
I'm having some difficulties doing this. The approach I've gone for so far is to make a random permutation of the arcs, then iterate through this list, sequentially putting them into basis if it won't create a cycle.
I need to find a fast method to check if including an arc will create a cycle. I don't want to "brute force" it, since this approach could take a large amount of time, given big problem instances.
Given that A is an array with a random permutation of the arcs, how would you go around making a selection procedure?
I've been working on this for a couple of hours now, and nothing I've tried has worked, most of it being nonsensical when it came to application...
Kruskals Algorithm is used for finding the minimum spanning tree. The fast-cycle detection is not actually part of Kruskals algorithm. The algorithm will work with a data structure that is able to find cycles fast as well as with a slow naive attempt (however the complexity will be different).
However Kruskals Algorithm is on track here, since it usually uses a so called union-find or disjoint-set datastructure for fast detection of cycles. This is the part of the Kruskals Algorithm page on wikipedia that you will need for your algorithm. This is also linked on wikipedia: http://en.wikipedia.org/wiki/Disjoint-set_data_structure
I found Kruskal's algorithm after long hours of research. I only needed to randomize the order in which I investigated the nodes of the graph.
I'm coding a simple game and currently doing the AI part. NPC gets a list of his 'interest points' which he needs to visit. Each point has a coordinate on the map. I need to find a fastest path for the character to visit all of the given points.
As far as I understand it, the task could be described as 'finding fastest traverse path in a strongly connected weighted undirected graph'.
I'd like to get either the name of some algorithm to calculate that or if there is no name - some keypoints on programming it myself.
Thanks in advance.
This is very similar to the Travelling Salesman problem, although I'm not going to try to prove equivalency offhand. The TSP is NP-complete, which means that solving the problem exactly may be impractical, depending on the number of interest points. There are approximation algorithms that you may find more useful.
See previous post regarding tree traversals:
Tree traversal algorithm for directory structures with a lot of files
I would use algorithm like: ant algorithm.
Not directly on point but what I did in an MMO emulator was to store waypoint indices along with the rest of the pathing data. If your requirement is to demonstrate solutions to TSP then ignore this. If not, it's worth consideration IMO.
In my case it was the best solution as otherwise the server could have potentially hundreds of mobs (re)spawning and along with all the other AI logic, would have to burn cycles computing route logic.