0
$\begingroup$

The problem is to find the minimum number of stages in which we can finish a set of processes, where we have a maximum number of processes we can do per stage, and there are prerequisites for the processes. Given a directed acyclic graph, the nodes of the graph represent processes, and the directed edges represent a prerrequisite ($A \rightarrow B$ means $A$ must be processed before $B$); there is a constant $M$ that represent the max number of processes that can be done per stage.

I tried this algorithm:

(The graph is assumed to be acyclic)

compute the in-degree of all nodes

Start a queue with all the nodes of in-degree 0

While the queue is not empty {

Dequeue up to M nodes

For each dequeued node, decrease the in-degree of each neighbor node by one, and if the in-degree becomes 0, enqueue that node.

}

This algorithm gives me a way in which I can finish all the processes, but it is not always the optimal way.

Consider this example: Nodes: A,B,C,D,E,F Prerequisites: D -> E, C -> E, E -> F

The algorithm may give different answers depending if we enqueue B,C,D in the first iteration (Optimal) or if we enqueue A,B,C.

I want to know if there is an "optimal" algorithm for doing this. At this point I could only think to check all possible ways. Is there a more optimal way?

$\endgroup$
1
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$ Commented Jul 6 at 13:36

1 Answer 1

2
$\begingroup$

This sounds equivalent to parallel processing of unit size jobs with precedence constraints, or $P|prec;p_j=1|C_{max}$. You can enter this into the scheduling zoo for some references.

The problem is strongly NP-hard in general, so you can't hope for a fast exact algorithm. There are approximation algorithms, though, and for some precedence graphs the problem is in P (see, e.g., Wang and Bellenguez 2021, Table 1). Moreover, the problem is in P if $M = 2$ (in the usual parlance, $M$ is the number of machines). I am unaware of any positive results for constant $M > 2$.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.