Algorithm to find possible combinations in Matlab with one constraint? -
a simple illustration :
a=[100 250 300]
how find possible combinations long each combination has sum of less 500 ?
this simple code
a=[100 250 300]; p = perms(a); nn = 1:numel(a) p(sum(p(:,1:nn), 2) < 500, 1:nn) end
gives next output
ans = 300 300 250 250 100 100 ans = 300 100 250 100 100 250 100 300
if want remove duplicates, [300 100] , [100 300], utilize sort
command sort values , can remove duplicates using unique
matlab combinations linear-programming
No comments:
Post a Comment