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.
Related
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.
I am studying graph databases (Neo4J).
I know graph databases come from graph theory, which has basis on Euler paper to solve the 7 bridges problem.. eulerian path/eulerian circuit.
I am trying to find an example, something, to show how graph databases use the Eulerian path to solve some problem.
Ideally I would need a real example from a source, but even any help to understand this better.. thanks!
I believe you have a misimpression. Even though Euler wrote a paper based on the 7 bridges problem (which was probably the first paper on graph theory), that does not mean that the design of neo4j uses his solution to that specific problem in any way.
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.
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.
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.