Trace the algorithm : Graph theory problem - algorithm

Graph theory Algorithm problem
Consider a set of, say p single-core processors which have been assigned q programs is given
along with:
– start times for the programs
– end times for the programs
– Total processing time to complete a program
Programs can be stopped, restarted, and moved between processors without any penalty.
i. Device an algorithm to schedule the running of programs on processors such that
the deadlines are met.
ii. Trace the algorithm for a set of values of your choice
I don't know which algorithm to use bellman-ford or floyd warshall or ford-fulkerson or dijksta's or kruskal's or prim's algorithm.
What algorithms could be used here, and what would be the correct way to formulate this problem using graph theory language?

You can use Dijkstra to find the critical path, if you set the edge costs to the reciprocal of the task duration. Then always choose to run a ready task if it is on the critical path, otherwise choose a non critical task at random.
This is the bare bones of the algorithm. Lots of details to sort out. You can see all the details at https://github.com/JamesBremner/TaskGraphScheduler

Related

How do I minimize the runtime of a parallelized computation?

Assume that there is a function f that determines the results of a set of n embarrassingly parallel computations, and immediately terminates upon finding the answer to the last problem. Each of the n processes takes some non-negligable amount of time unique to that process, and there is a perfect linear correlation between time spent on a computation and work done during that computation.
In more math-y terms, every ith parallelized subproblem n_i takes time t_i to terminate, and each t_i is unique to each parallelized subproblem.
Given those conditions and an infinite number of processors, it is easy to see that the total runtime of the algorithm is exactly max(t). However, the computers people program on have a bounded number of processors p, after which introducing any more subprocesses overwhelms the realistic system and actually increases the total running time of f.
My question is - given this practical scenario where the number of subprocesses is bounded by p - what is the fastest algorithm that can determine how to optimally schedule the set of parallelized subproblems n across the p processors in order to minimize the total runtime of the function f?
Thanks to stark's comment about the bin packing problem, I found that this problem actually has a name! It's called, quite sensibly, the Multiprocessor Scheduling Problem. As I suspected, it's in NP, which means there's no efficient algorithm for solving it. That's quite unfortunate news in the context of the application I'm programming at the moment, but useful to know nonetheless!

Running time for algorithms that solve graph problems

When people talk about algorithms to solve graph problems, which input is taken into account for the running time - the number of vertices, number of edges, both or either? Put differently, could O(|V|), O(|E|) and O(|V||E|) all be valid polynomial running times for graphing algorithms? Does it matter if one of |V| or |E| is bigger than the other?
Both may be relevant, depending on the algorithm. Only the input(s) that has a significant impact is used to compute the complexity.
You can have a look at his link for a few examples of complexity of known graph algorithms: http://bigocheatsheet.com/. You can see that sometimes either one of |V| or |E| appears, sometimes both.

All pairs shortest path - warm restart?

Is it possible to warm start any of the well known algorithms (Dijkstra/Floyd-Warshall etc) for the APSP problem so as to be able to reduce the time complexity, and potentially the computation time?
Let's say the graph is represented by a NxN matrix. I am only considering changes in one or more matrix entries( << N), i.e. distance between the corresponding vertices, between any 2 calls to the algorithm procedure. Can we use the solution from the first call and just the incremental changes to the matrix to speed up the calculation on the second call to the algorithm? I am primarily looking at dense matrices, but if there are known methods for sparse matrices, please feel free to share. Thanks.
I'm not aware of an incremental algorithm for APSP. However, there is an incremental version of A* for solving SSSP called Lifelong Planning A* (aka 'LPA*,' rarely also called 'Incremental A*'), which seems to be what you're asking about in the second paragraph.
Here is a link to the original paper. You can find more information about it in this post about A* variations.
An interesting study paper is: Experimental Analysis of Dynamic All Pairs Shortest Path Algorithms [Demetrescu, Emiliozzi, Italiano]:
We present the results of an extensive computational study on dynamic algorithms for all pairs shortest path problems. We describe our
implementations of the recent dynamic algorithms of King [18] and of
Demetrescu and Italiano [7], and compare them to the dynamic algorithm
of Ramalingam and Reps [25] and to static algorithms on random,
real-world and hard instances. Our experimental data suggest that some
of the dynamic algorithms and their algorithmic techniques can be
really of practical value in many situations.
Another interesting distributed algorithm is Engineering a New Algorithm for Distributed Shortest Paths on Dynamic Networks [Cicerone, D’Angelo, Di Stefano, Frigioni, Maurizio]:
We study the problem of dynamically updating all-pairs shortest paths in a distributed network while edge update operations occur to the
network. We consider the practical case of a dynamic network in which
an edge update can occur while one or more other edge updates are
under processing.
You can find more resources searching for All Pairs Shortest Paths on Dynamic Networks.

better heuristic then A*

I am enrolled in Stanford's ai-class.com and have just learned in my first week of lecture about a* algorithm and how it's better used then other search algo.
I also show one of my class mate implement it on 4x4 sliding block puzzle which he has published at: http://george.mitsuoka.org/StanfordAI/slidingBlocks/
While i very much appreciate and thank George to implement A* and publishing the result for our amusement.
I (and he also) were wondering if there is any way to make the process more optimized or if there is a better heuristic A*, like better heuristic function than the max of "number of blocks out of place" or "sum of distances to goals" that would speed things up?
and Also if there is a better algo then A* for such problems, i would like to know about them as well.
Thanks for the help and in case of discrepancies, before down grading my profile please allow me a chance to upgrade my approach or even if req to delete the question, as am still learning the ways of stackoverflow.
It depends on your heuristic function. for example, if you have a perfect heuristic [h*], then a greedy algorithm(*), will yield better result then A*, and will still be optimal [since your heuristic is perfect!]. It will develop only the nodes needed for the solution. Unfortunately, it is seldom the case that you have a perfect heuristic.
(*)greedy algorithm: always develop the node with the lowest h value.
However, if your heuristic is very bad: h=0, then A* is actually a BFS! And A* in this case will develop O(B^d) nodes, where B is the branch factor and d is the number of steps required for solving.
In this case, since you have a single target function, a bi-directional search (*) will be more efficient, since it needs to develop only O(2*B^(d/2))=O(B^(d/2)) nodes, which is much less then what A* will develop.
bi directional search: (*)run BFS from the target and from the start nodes, each iteration is one step from each side, the algorithm ends when there is a common vertex in both fronts.
For the average case, if you have a heuristic which is not perfect, but not completely terrbile, A* will probably perform better then both solutions.
Possible optimization for average case: You also can run bi-directional search with A*: from the start side, you can run A* with your heuristic, and a regular BFS from the target side. Will it get a solution faster? no idea, you should probably benchmark the two possibilities and find which is better. However, the solution found with this algorithm will also be optimal, like BFS and A*.
The performance of A* is based on the quality of the expected cost heuristic, as you learned in the videos. Getting your expected cost heuristic to match as closely as possible to the actual cost from that state will reduce the total number of states that need to be expanded. There are also a number of variations that perform better under certain circumstances, like for instance when faced with hardware restrictions in large state space searching.

What is the simplest augmentation to reference counting that will collect cycles?

Reference counting alone does not collect cycles but there are additional techniques that can collect cycles as well. What is the simplest such technique?
I'd like to compare the complexity of augmented referencing counting with tracing GC.
It's better to code be cycle free but in the case of cycles if you want find isolated cycle in graph with E and V, it will takes O(|E| + |V|), It's similar to finding connected component algorithm and then run finding all cycle of graph with BFS, and if you just think about |V| it can be very heavy (in compiled assembly) So It's better to prevent from this, and because of this they left them to developers.

Resources