Genetic Algorithm for Path Finding - Crossover and Mutation - graph

I want to use a Genetic Algorithm for finding the shortest path within an undirected graph. I have two questions about this regarding Crossover and Mutation. I've been researching how crossover can be performed in similar situations to this, and the most popular algorithm out there seems to be PMX, my understanding of this is a partial path is swapped between 2 parent chromosomes to make the offspring. The issue I'm having with this is, there is massive scope for almost all of the offspring to become invalid isn't there? I was wondering if you could confirm this for me, and if I'm wrong, please correct me and explain it.
On separate but relevant note; I did have an idea for how to do this, but I don't know if its a good idea, simply select 2 parents where they share the same node in their path and crossover at that point, so all of the offspring remain valid.
My second issue is with Mutation; I have a general idea for how this can be done; would it be wise to select one node and remove it, and relink the path by an alternative means?
Thanks :)!

First of all you study about the cross over and mutation, because you said that you may loss some efficient parent, but it the concept of " Elitism " in genetic algorithm. that you should overcome by your proposed cross over method. because in cross over itself we are having n method to do, i suggest you to do second variation cross over order. This is not murphy's law, so try hard you will achieve.

Related

Linear programming to find a graph circuit

The question itself is pretty simple... This is a vechicle routing problem.
I have a directed graph
I need to get a linear programming model that will somehow tell me the shortest circuit that visits all nodes, and starts and ends at the star. You are allowed to go over an edge more than once. A node is any crossing on the image.
We had like 4 hours of this in class, I have no idea where to even start...
I'm not expection anyone to give me the full model, but I was hoping someone would tell a strategy so I could do this.
Thank you in advance.
I would start from Dijkstra's algorithm for undirected graphs. There are some variants with similar or better performance. Take a look at https://en.wikipedia.org/wiki/Shortest_path_problem#Undirected_graphs, pick a choice, and keep us informed ... :)
The answer here seems to be very easy. (That is, very easy in theory, very hard and a lot of work to code in practice).
This seems like a straight-forward TSP (Travelling Salesperson Problem). Read about some general literature on TSP. You need to set up and solve a TSP where your nodes are the "cities" in a TSP. You also need to include your star as a city in the TSP.
The Dijkstra algorithm will not give you a solution. The Dijkstra algorithm is used for finding fastest/shortest paths between a node and other nodes in a (typically road-) network. However, distance-wise your problem is super-simple: Getting the cheapest travel cost (and path) from one node to another node in your problem is (almost) trivial.
If you are to solve this problem "for real" (not just discuss it), you need to acquire a TSP solver that is able to take your network (both edges and nodes) as input. Your input needs to specify which edges are directed and which are uni-directed. A lot of work in practice: Even if you use a tool, you still need to familiarize yourself with the tool.

Grouping 1-12 in groups of 4 with the least number of duplicates

Consider 12 people who want to meet up to play a game every week.
They meet in groups of 4. They want to play each other an even number of times.
After 4 weeks there doesn't seem to be any combination that allows each player to have played with all 11 opponents. I haven't been able to prove it, but I've yet to find a solution.
So what is the smallest value of N such that after (N*4) weeks every player can be guaranteed to have played with all other players at least N times? Can it be done for N=2?
This is very similar to the Social Golfer Problem -- an unsolved problem in mathematics. Here's a relevant post from math.stackexchange which discusses what you're looking at. If your concern is focused on the math behind it, you may want to repost it there, since that's not really suited for stackoverflow.
If you're just concerned about an algorithm to attempt to solve it (and don't want to just brute force it), this paper presents a bunch approaches to solving problems of this type. It's a pretty dense read, but it's a place to start. There's also a list of explicit solutions to some cases, but I don't know how useful it will be to you (since the problem is slightly different).
If you really just want to prove a lower bound for N, since its discrete and the cases you're examining are relatively small, your best bet would probably be to throw together a brute force search algorithm, and increment N until it works.
Finally, here's a few other links that may or may not be useful:
http://www.bridgeguys.com/Conventions/movements_for_bridge.html
http://www.jdawiseman.com/papers/tournaments/individual-pairs/individual-pairs.html
http://www.csplib.org/Problems/prob010/
https://www.metalevel.at/sgp/
Thanks for the pointers - they gave me the answer that I was looking for.
In simple terms, for N=1 there is no solution, as you said.
Solutions exist for 12 players over 11 rounds, eg http://www.jdawiseman.com/papers/tournaments/individual-pairs/ip-pure_12.html - this actually goes one stage further and asserts that each player partners once with each other player, and opposes them twice. That effectively covers the case of N=3
The existence of a solution for N=3 and the lack of a solution for N=1 pretty much eliminates the possibility of a solution for N=2.

Symmetric(or undirected) Hamiltonian Cycle data sets

I would like to test my recently created algorithm on large (50+ node) graphs. Preferrably, they would specifically be challenging graphs, and known tours would exist (for at least most of them).
Problem sets for this problem do not seem as easy to find as with the TSP. I am aware of the Flinder's challenge set available at http://www.flinders.edu.au/science_engineering/csem/research/programs/flinders-hamiltonian-cycle-project/fhcpcs.cfm
However, they seem to be directed. I can probably alter my algorithm to work for directed, but it will take time and likely induce bugs. I'd prefer to know if it can work for undirected first.
Does anyone know where problem sets are available? Thank you.
quick edit:
Now I am unsure if the flinder's set is directed or not.... It doesn't say. Examples make it seem like maybe it actually is undirected.
Check this video:
https://www.youtube.com/watch?v=G1m7goLCJDY
Also check the in depth sequel to the video.
You can determine yourself how many nodes you want to add to the graph.
It does require you to construct the data yourself, which should be deable.
One note: the problem is about a path, not a cycle, but you can overcome this by connecting the start and end node.

Heuristic function meaning

I've searched for meaning of heuristic function but everything I got is that it's function that ranks alternatives in search algorithms. But I suppose that it is not full definition of heuristics. As an example, heuristic of tree rank is used in Disjoint Union Set problem, but there's no searching!
I still don't understand, what does mean heuristic. Do you know any math definitions?
In its broadest sense, heuristics is the art of obtaining adequate results in short time from incomplete information.
As an example, the best known algorithms that solve the travelling salesman problem (i.e. finding the cheapest Hamiltonian cycle in a edge-weighted graph) have exponential time complexity. A heuristic algorithm to this problem is one that will often find a Hamiltonian cycle that is not much more expensive than the optimal solution, but will use only polynomial time.
A heuristic is a problem solving technique that comes from intuition,common sense,experience and is basically an easier and short method to solve problems.
It is applicable to human as well as machines.
Example: For example you choose to eat one of the fruits from the bucket because it looks fresh and ripe.(what you thought before picking up the fruit was an example of heuristic)
A heuristic function can be explained with an example of objective type question.
Suppose you are facing an objective test of 4 options of which only one is correct.
Now there is a question whose answer you do not know.
But then you look at the options and start thinking 1st is least probable and so is 3rd and so and so...
So basically you are rejecting least probable answers based on you experience and knwoledge related to those options
Thus it can be said that you are using a heuristic function.
Similarly for computers a heuristic function can be designed by keeping in mind the constraints of what you want from your program to do.

Graph data structures in LabVIEW

What's the best way to represent graph data structures in LabVIEW?
I'm doing some basic algorithm review over the holiday, and I'd prefer to not implement all of the storage and traversals myself, if possible.
(I'm aware that there was a thread a few years ago on LAVA, is that my best bet?)
I've never had a need to do this myself, so I never really looked into it, but there are some people who did do some work as far I know.
Brian K. has posted something over here, although it's been a long time since I looked at it:
https://decibel.ni.com/content/docs/DOC-12668
If that doesn't help, I would suggest you read this and then try sending a PM to Daklu there, as he's the most likely candidate to have something.
https://decibel.ni.com/content/thread/8179?tstart=0
If not, I would suggest posting a question on LAVA, as you're more likely to find the relevant people there.
Well you don't have that many options for graphs , from a simple point of view. It really depends on the types of algorithms you are doing, in order to choose the most convenient representation.
Adjacency matrix is simple, but can be slow for some tasks, and can be wasteful if the graph is not dense.
You can keep a couple of lists and hash maps of your edges and vertices. With each edge or vertex created assigned a unique index into the list,it's pretty simple to keep things under control. Each vertex could then be associated with a list of its neighbors. Depending on your needs you could divide that neighbors list into in and out edges. Also depending on your look up needs, you could choose to index edges by their in or out edge or both, or simple by a unique index number.
I had a glance at the LabView quick reference, and while it was not obvious from there how you would do that, as long as they have arrays of some sort, you can implement a graph. I'm sure you'll be fine.

Resources