algorithm - All possible combinations from a matrix such that sum of all numbers equals to a fixed value -
suppose have q
vectors follows:
a_1 = [x_1,x_2,...,x_m]; a_2 = [y_1,y_2,...,y_n]; . . . a_q = [z_1,z_2,...,z_q];
basically, m,n,q
positive integers , not equivalent. each vector element x,y,z
number between (0,1).
1 possible combination of these vectors can be:
b_1 = [x_1,y_1,...,z_1];
in each combination, 1 element of each vector should included. therefore, can have m*n*...*q
different combinations. now, want find combinations such mean of elements equals specific number w
, i.e, mean(b_1)=w.
note w
number between (0,1).
inefficient way compute permutations , compare w
mean of elements. however, q,m,n,q
increase, computer (matlab) can't handle it, obvious.
would please me find efficient approach solve problem in reasonable time?
one can there may not vector, mean of elements equals w.
yes, that's true. then, possible find combinations such mean of elements between (w-t,w+t),
t
between (0,1)
?
many in advance.
Comments
Post a Comment