需要算法将不同大小的文件分组为大致相等的块

miC*_*inG 3 algorithm size grouping file np-complete

我正在试图找出一种算法,它可以帮助我将各种不同大小的文件分组成大小相等的'n'组.

关于如何实现这一点的任何想法?

Gun*_*iez 6

Find the target group size. This is the sum of all sizes divided by n.
Create a list of sizes.
Sort the files decreasing in size. 
for each group
    while the remaining space in your group is bigger than the first element of the list
        take the first element of the list and move it to the group
    for each element
        find the elemnet for which the difference between group size and target group size is minimal
    move this elemnt to the group
Run Code Online (Sandbox Code Playgroud)

这不会产生最佳结果,但易于实现并获得良好的结果.要获得最佳解决方案,您需要进行详尽的搜索,即NP完成.