Problem description
There are n separate tasks, assigned to m the same processor for processing, each task takes a time of t[i], i = 1..N, each task independent, indivisible, non-interruptible. Question: What is the shortest time it takes for these processors to handle these tasks?
Problem solving
The problem is also NP-like, similar to the boxing problem in the previous blog: http://blog.csdn.net/nisxiya/article/details/45533811
Packing problem, is a given capacity of the box, ask at least a few boxes to meet the conditions.
Multiprocessor scheduling problem is given a fixed number of processors, each processor is asked to process as soon as possible, the longest need to process how long. Similar to a given fixed box, but the box capacity can vary, ask these same box maximum capacity design, can meet the conditions, and maximum capacity to be as small as possible.
The most idle adaptive algorithm
This kind of multiprocessor problem, also has not found the relatively good polynomial solution, at present uses the greedy algorithm, gives the comparison approximate optimal solution the answer.
1) Sort tasks according to time spent from long to short, time complexity is O (n log n)
2) Assign task one by one to the most idle of M machines. The so-called most idle, refers to the current task he has to deal with the total time and minimum. How to quickly find the machine with the smallest number of tasks in the M machine? The use of balanced binary tree, minimum heap, etc. can be resolved in good condition, the time complexity of O (log m). So in the second step, the total time complexity is O (n log m)
Because M <= N, (otherwise it is not so laborious to solve, directly each processor assigned a task can be), t (n) = O (n log n) + O (n log m), that is, t (n) = O (n log n).
Examples
There are 7 independent tasks, 3 machines to complete processing, each task time is {2,14,4,16,6,5,3}, the specific solution is as follows:
Multiprocessor scheduling problem (NP)