User split problem

Can anyone help me solve this problem.

We are given a set S with k number of elements in it.

Now we need to split the set S into x subsets, so that the difference in the number of elements in each subset is at most 1, and the sum of each subset should be as close to each other as possible.

Example 1: {10, 20, 90, 200, 100} should be divided into 2 subsets

Solution: {10200} {20,90,100}

the amount is 210 and 210

Example 2: {1, 1, 2, 1, 1, 1, 1, 1, 1, 6}

Solution: {1,1,1,1,6} {1,2,1,1,1}

The sum is 10 and 6.

+5
source share
3 answers

I see a possible solution in two stages.

Stage 1

N. , . N S 1 N . N S , N 1. , .

S, S ( ) .

N , 1 .

. , L , M. L, M, , . . . . swap .

, ; , . , , ; .

, .

+2

.

, , 2 . NP-Complete, .

, , , .

:

, k - .

{a1 ... ak} is your set

For i = 2 to k:

   try to solve the following program:
        xjl = 1 if element j of set is in set number l (l <= i) and 0 otherwise

        minimise max(Abs(sum(apxpn) -sum(apxpm)) for all m,n) // you minimise the max of the difference between 2 sets.

        s.t 
        sum(xpn) on n = 1
        (sum(xkn) on k)-(sum(xkm) on k) <= 1 for all m n // the number of element in 2 list are different at most of one element.
        xpn in {0,1}

  if you find a min less than one    then stop
  otherwise continue

end for

, .

, , P = NP, , .


EDIT

, , ( , ) , , . sryy


2

, , . .

, , .

+1

, :

, "" , , ;

:

  • , .
  • Encoding the resulting sets appropriately and attempting to use genetic algorithms.
0
source

All Articles