Note that there are some explanatory texts on larger screens.

plurals
  1. PONumber of combinations in configurator
    primarykey
    data
    text
    <p>I have been asked to program a routine to decide the number of possible combinations in a product configurator.</p> <p>The configurator is really simple. Even though it has more features than this, it can be modeled as several "radio groups" (like the UI control) where one of n options has to be selected.</p> <p>The only kind of constraints that can be used is rules that says if one option is selected another option can not be selected.</p> <p>So what I want to do is to calculate the number of different products that can be configured, given a set of option groups and constraints.</p> <p>I made a naive approach to solve this using the <a href="http://en.wikipedia.org/wiki/Inclusion-exclusion_principle" rel="nofollow noreferrer">Inclusion-exclusion principle</a>. However as far as I can see, any algorithm based on this method should run in O(2^n) which won't work. There are of course several possible optimizations that should give decent runtimes but there are still easily constructed worst case scenarios.</p> <p>Thats pretty much where I am right now. Any suggestions?</p> <p><strong>Update</strong></p> <p>I realize I haven't explained how the rules applies well enough.</p> <p>There are several groups with options. One and only one option must be selected in each group. There can be one or more of options in a group.</p> <p>There is only one type of constraints. If option A in some group is selected, then option B in some other group can't be selected. There can be any number of constraints, there is no limit how many constraints/rules apply to a option group or an option itself.</p> <p>So an example would be:</p> <p><strong>Group 1:</strong><br/> x1 x2 x3 x4 x5</p> <p><strong>Group 2:</strong><br/> y1 y2 y3</p> <p><strong>Group 3:</strong><br/> z1 z2 z3 z4</p> <p><strong>Constraints:</strong><br/> x1 &lt;-> y2 *<br/> x1 &lt;-> z4<br/> y2 &lt;-> z2<br/></p> <p><code>*</code> If option x1 is selected in group1, then option y2 in group 2 can not be selected.</p> <p>Using inclusion-exclusion I would calculate the number of combinations as</p> <p>Combinations = C<sub>no rules</sub> - C<sub>r</sub><code>[1]</code> - C<sub>r</sub>[2] - C<sub>r</sub>[3] + C<sub>r</sub>[1,2] + C<sub>r</sub>[1,3] + C<sub>r</sub>[2,3] - C<sub>r</sub>[1,2,3]</p> <p>Where </p> <p>C<sub>no rules</sub> = 5 * 3 * 4</p> <p>C<sub>r</sub>[a,b,c] = Number of combinations that violates rule a, b and c.</p> <p>The method unfortunately requires 2^|rules| calculations.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload