问题
I have 7 values and I need to split them into 5 groups. Each group should contain atleast one value. There are 15 ways to group those values into 5.
Mon- 13 Tue- 5 Wed- 4 Thu- 4 Fri- 11 Sat- 2 Sun- 1
When grouping, ordering of Mon, Tue, Wed, Thu, Fri, Sat, Sun should be preserved.
Suppose there is a function which decides how good a grouping is.
13, 5, 4, 4, 11, 2, 1
Function
Grouping 1 - 13, 5, [4,4], 11, [2,1]
13 added, 13 withdrawn, 0 remaining
5 added, 5 withdrawn, 0 remaining
[4,4] added, 4 withdrawn, 4 remaining
0 added, 4 withdrawn, 0 remaining
11 added, 11 withdrawn, 0 remaining
[2, 1] added, 2 withdrawn, 1 remaining
0 added, 1 withdrawn, 0 remaining
cost = sum of remainings at the end of the day = 4+1 = 5
I need to find the grouping with minimum cost. Is there a way(eg: heuristic approach) to avoid obvious costly combinations, so that I don't have to try all the groupings to find the grouping with minimum cost?
Example for obvious costly combination
13, [5,4], [4,11], 2, 1
Larger the sum remaining at the end of the day, costlier the grouping is
Actual prediction data for 2 weeks
prediction data
来源:https://stackoverflow.com/questions/51359719/algorithm-to-avoid-obvious-costly-combinations-when-splitting-n-values-to-m-grou