Algorithm to avoid obvious costly combinations when splitting n values to m groups

梦想与她 提交于 2019-12-13 05:13:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!