logical operators - Boolean Expression Optimization For All AND Conditions -
i trying solve boolean expression optimization problem simple rule engine.
here trying do, lets if have following 5 conditions (where a,b,c,d,e,f complex boolean expressions)
if (a , b , c , d , e , f) do-1 if (a , b , c , d , e) do-2 if (a , b , c , d) do-3 if (a , b , c) do-4 if (a , b) do-5
in case when execute these conditions in linear order
- evaluate "a" 5 times - evaluate "b" 5 times - evaluate "c" 4 times - evaluate "d" 3 times - evaluate "e" 2 times - evaluate "f" 1 time
i make expression execution tree each expression (a,b,c,d,e,f) evaluated minimum number of times. perfect solution each expression evaluated once. think can achieved tree creation these conditions part of tree.
the tree may
if(a , b) do-5 { if(c) do-4 { if(d) do-3 { if(e) do-2 { if(f) do-1 } } } }
my questions - how can make tree set of boolean expressions listed above?
related questions:
algorithm evaluating nested logical expression
Comments
Post a Comment