perlquestion
Limbic~Region
All,
<br />
I would like to find a way to generate the [wp://powerset] such that all subsets below the current set can be skipped if a condition is met. I think a concrete example might better explain. Assume our set contains 'A' .. 'D';
<CODE>
A, B, C, D
AB, AC, AD, BC, BD, CD
ABC, ABD, ACD, BCD
ABCD
</CODE>
I omitted the empty set as it has no practical purposes for my problem. The following re-ordering is an example of the optimization I am hoping to use:
<CODE>
ABCD
ABC
AB
A
B
AC
C
BC
ABD
AD
D
BD
ACD
CD
BCD
</CODE>
So if the condition for 'ABCD' was true, I would skip the entire powerset. If 'ABC' was true I would skip to 'ABD'. If 'ABD' was false but 'AD' was true I would skip to 'BD'.
<p>
This exact ordering isn't necessary and I am not sure if it helped explain my desire at all. Ultimately the goal is to generate the powerset for a list of sets but avoid duplication where possible. Using another example:
</p>
<CODE>
Set1: A,B,C,D
Set2: A,B,C,E
set3: A,B,C,F,G
</CODE>
They share sets ABC, AB, AC, BC, A, B, and C so why generate them three times? I have used a similar [id://434517|technique] in the past with success but I can't seem to wrap my head around how to do it here. Your thoughts and insights are appreciated.
<p>
<b>Update:</b> It was suggested in a /msg that I be more specific about the rules and not assume the examples are sufficient.
<ul>
<li>If a set has previously been seen, all subsets of that set can be skipped</li>
<li>The powerset should be generated in a manner that maximizes the potential for optimization. In other words, A,B,C should be generated before A,C</li>
<li>No more sets should be generated than would otherwise be done using a [id://576122|straight forward iterative approach]. In other words, A, B, C should produce only 7 candidates (or less if optimization possible)</li>
</ul>
</p>
<div class="pmsig"><div class="pmsig-180961">
<p>
Cheers - [Limbic~Region|L~R]
</p>
</div></div>