genetic algorithm tool GA(tool) for all possible (or shortest ) paths found in topology
Show older comments
i want ga function to find all possible paths found in any topology
for example for this topology if the source (1) and destination (6) where 1 & 6 is nodes and L is link . can be represent the L1 as 1 and L2 as 2 ...etc.
all possible paths =( 4,8) &(1,2,7) &(4,3,7)&(1,5,9)&(1,2,3,8)......etc
or any help about this function...
with my thanks.
14 Comments
Walter Roberson
on 7 Jan 2013
We cannot see images that are stored on your computer.
Walter Roberson
on 7 Jan 2013
There are an infinite number of possible paths unless you exclude loops.
mohammed sportman
on 7 Jan 2013
Walter Roberson
on 7 Jan 2013
1-2-3-4-1-2-3-6-4-1-2-3-4-1-2-3-4-....
mohammed sportman
on 7 Jan 2013
mohammed sportman
on 7 Jan 2013
Walter Roberson
on 7 Jan 2013
One of the possible paths starts
L1 L2 L3 L4 L1 L2 L7 L8 L4 L1 L2 L3 L4 L1 L2 L3 L4
and keeps going for another 23454935674398923479332881 steps.
mohammed sportman
on 7 Jan 2013
Walter Roberson
on 7 Jan 2013
GA functions need an output, a "fitness". What would be the fitness function in this case?
GA is for attempting to minimize something. A minimization is a single output (though other sets of inputs might have the same output.) GA is not suitable for finding all possibilities -- not unless the fitness function is somehow "number of possibilities not explored".
mohammed sportman
on 7 Jan 2013
Walter Roberson
on 7 Jan 2013
Your paths have no weight, so by convention the weight of each link is 1. Then since any number of nodes are allowed in the path, the shortest path will be to connect any two (allowed) nodes together and use that. More correctly, the shortest path will be to start at any node and go no-where in no steps, for a path length of 0.
mohammed sportman
on 8 Jan 2013
Walter Roberson
on 8 Jan 2013
Your question does not impose any restrictions on where the paths must start or end: your question asks for "all possible paths" found in the topology.
mohammed sportman
on 8 Jan 2013
Answers (1)
Walter Roberson
on 8 Jan 2013
Edited: Walter Roberson
on 8 Jan 2013
0 votes
It is unfortunate that your version of ga() does not have IntCon.
One technique that can be used:
Let your ga have as many virtual variables as there are nodes. Let the virtual variables represent nodes in a path. To evaluate any particular list of values, start from the beginning of it. If the first value is not the desired first node, then assign a high cost and return. If the value after that is not reachable from the first node, assign a high cost and return. If the value is the destination node, assign a low cost that is lower for shorter paths, and return. If the value is a destination node that has already occurred along the path, assign a high cost and return. Keep evaluating along the path like this, verifying topology first then whether the destination has been reached then whether a loop was found. If you get to the end of the virtual variables and have not reached the destination and have not had a loop then there must have been a programming error.
Note that the final returned path will have values that have been ignored, as the examination stops when the destination has been reached. This is not a problem.
Now as you do not have IntCon in your version of ga(), instead encode each virtual variable by a series of bits sufficiently wide to hold the maximum node number. Be sure to add a step to verify the decoded values are in range for node numbers as you go along (it does not matter if you get invalid node numbers after you have reached the destination.)
Now what you might want to consider is whether all those cases of "high cost" should be the same "high cost", or if some of them should be considered to be worse than others.
2 Comments
mohammed sportman
on 9 Jan 2013
Edited: Walter Roberson
on 9 Jan 2013
mohammed sportman
on 11 Jan 2013
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!