I have a DAG with N nodes, i.e., 1, 2, ..., N
, and each node has a weight (we can call it time) x_1, x_2, ..., x_N
. I want to do a topological sorting but the difficulty is that I have an objective function when sorting. My objective function is to minimize the total time between several pairs of nodes.
For example, I have a DAG with 6 nodes, and I want a specific topological sorting such that (1,3) + (2,4)
is minimized, where (A,B)
denotes the time between two nodes A and B. For instance, if we have a sort [1, 6, 3, 2, 5, 4, 7]
, (1,3) = x_6
and (2,4) = x_5
. Based on the DAG, I want to find a sorting that minimizes (1,3) + (2,4)
.
I have been thinking this problem for a while. Generate all possible topological sorts (reference link) and calculate the objective function one by one is always a possible solution but it takes too much time if N is large. I was also suggested to use branch-bound pruning when generating all possible sorts (I am not very familiar branch-bound but I think that won't dramatically reduce the complexity).
Any (optimal or heuristic) algorithm for this kind of problem? It would be perfect if the algorithm can also be applied to other objective functions such as minimizing the total starting time for some nodes. Any suggestion is appreciated.
PS: Or alternatively, is it possible to formulate this problem as a linear integer optimization problem?
(u,v)
to the objective function to be minimised); ... – Trichinosis(1,3)
or(2,4)
in your example) to be multiplied by a separate weight, then you can reduce the NP-hard Quadratic Assignment Problem to this problem in the same way. It may be that even the special case of the QAP where every weight is 1 is still NP-hard -- that would imply that your problem is too -- but I wasn't able to confirm this with a few googles. – Trichinosis