I have a vector A
, that is
A = [300; 165; 150; 150; 400; 300; 80; 250; 165; 80; 200]
I am trying to find a set of vectors that are composed of the elements of this vector A
so that their elements sum up to a value as close as possible to 400 and so that all elements of vector A
are included in the disjoint set of vectors.
For example, 400 is already 400, so this is first set of vectors without a slack.
Another set would be the vector of [250 150]
, their sum is 400.
Another two can be two sets of the vector [300 80]
, their sum is 380, so a slack of 20 is compromised.
Another would be [165 165]
, they sum up to 330, with a slack of 70. The last one would be 200 and 150, with a slack of 50. The total slack is 20+20+70+50=160.
I'm trying to find a heuristic or an algorithm (not a programming model) that would minimize the slack. I'm coding in Matlab.