A
A
Alexander2021-10-29 18:08:40
Mathematics
Alexander, 2021-10-29 18:08:40

How to classify/group the elements of a number series so that the sum of the elements in each group is approximately the same?

There is a number series: 2717, 1995, 1633, 1244, 978, 745, 588 (there are many more numbers).

It is necessary to divide these numbers into groups so that the sum of the elements of the group is as equal as possible.
The number of groups is given (not a constant).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-10-29
@wataru

This is the optimal subsetting problem and is NP-hard. There is no simple and fast algorithm here.
Full enumeration, branch and bound method, all sorts of annealing methods and genetic algorithms to help you.
In some cases (the sum is not very large and there are only 2 sets; the numbers are very small) fast algorithms based on dynamic programming are possible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question