LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all possible subsets of the elements of an 1D-array

Solved!
Go to solution

The problem is that there are still duplicates, for example.

 

(60,40,30), (80,60,50,40), (90,80,10), (90,40,20), (90,80,50,20)

 

all give 7.20% but  the wonders of floating point math will not show them as duplicates. After a little bit weeding out the true duplicates, we do have 132 unique transmission values that can be achieved, so the number in the original post is correct.

 

So the question is if we want all possible filter combinations (256) or only all possible unique transmission values (132).

 

A better instrument would have a set of filters where each combination gives an unique total. 😄

Message 11 of 20
(1,770 Views)

Hi, Altenbach (Knight of NI). Yes, you're right. I already predicted multiple combinations leading to the same output power, as can be seen in the python code in the original post via the functions "powers(l, n)" that shows all possible combinations for each output power and "bestComb(l, n)" that shows the best combinations for each output power (i.e., the combinations that uses the least number of filters).

 

That is what I would like to have in labview: a VI whose input would be the available filters and the output would be the "best" possible combinations for each output power in increasing order of output power.

 

Thank you!

0 Kudos
Message 12 of 20
(1,736 Views)

Well, I used LabVIEW code to generate all possibilities. Easiest is to generate all combinations, then eliminate the duplicates after approrpiate rounding to a few decimal digits. Since there are often still several combinations that use the fewest number of filters, do you have any other criteria to select the "best" (e.g. based on the average grey value, smallest filter range, etc.).

0 Kudos
Message 13 of 20
(1,731 Views)

Hi, Darin. Thank you very much for the VI image. It seems much simpler than the one I received earlier and I suryely will try it.

0 Kudos
Message 14 of 20
(1,730 Views)

Well... if I get all possible combinations it will be great for me. It will be easy to check among the possible cominations what's the "best" for me.

 

Thank you.

0 Kudos
Message 15 of 20
(1,726 Views)

Well, the problem with Darin's code is that it uses a conditional tunnel, which is not avaiable in LabVIEW 7.1. However, It generates all valid 256 combinations.

 

You need to conditionally build the array in a shift register.

Message 16 of 20
(1,708 Views)

Hi, Altenbach. Can you tell me how to do this? I was trying to find an alternative way for the conditional tunel, but still didn't get a solution.

0 Kudos
Message 17 of 20
(1,699 Views)
Solution
Accepted by topic author blifo

LV will Save for Previous to remove the conditional tunnels, of course it does it in a silly way but your arrays are so small it doesn't matter.

 

I don't have an older version of LV on this machine but here is a LV14 snippet showing the code saved for LV8.6 which should be fine in LV7.1

 

GetFilterCombinations_old.png

Message 18 of 20
(1,689 Views)

Thank you very much, Darin! It seems to work perfectly!!

0 Kudos
Message 19 of 20
(1,679 Views)

You can eliminate some of the case structures in the big loop. Here's my version.

 

(Note that I multiply up and round to nearest integer to avoid spurios differences between combos with identical totals. Later I scale it all back.)

 

  

(It also uses two additional loops to remove duplicates and keep a random unique combo). You can keep the one with the fewest filters by looking at the existing variant attribute and keep the shorter one, for example).

0 Kudos
Message 20 of 20
(1,668 Views)