TransWikia.com

Is finding the optimal ordering of predicates NP?

Theoretical Computer Science Asked by Bernardo Sulzbach on March 8, 2021

Assume we want to find the elements from a set of elements $mathscr{E}$ for which all predicates from a set of $n$ predicates $mathscr{P}$ evaluate to true.
In programming terms, we want to compute filter(E, P).

For each predicate $p_i$, let $P(p_i)$ be the probability of it evaluating to true on a random element from $mathscr{E}$ and $C(p_i)$ as the constant cost of its evaluation.
Assume there is no correlation between the predicate probabilities.

After a predicate fails for an element, no subsequent predicates are going to be evaluated for that element.

To me, it seems that ordering the predicates by nonincreasing $C(p_i)/(1 – P(p_i))$ and evaluating them in that order will be optimal, as it would be using the most efficient predicates first. Semantically, $C(p_i)/(1 – P(p_i))$ can be interpreted as the cost per element removed.

However, I not only don’t know whether or not this assessment is correct (and the problem is $O(n log n)$), but I also don’t know how one would rigorously prove that this ordering is an optimal ordering for minimizing the overall evaluation cost.


As requested in the comments, I came across this problem when thinking about the optimal order of filters over a collection of elements. I wondered if I could compute the optimal order if I knew fairly well the probability of the predicates being true and the cost of evaluating each one of them in order to write a more efficient combined filter.

My question already has a good answer in the CS SE. I didn’t know we had two SEs for CS, so I assumed, wrongfully, that TCS (cstheory) was the right board to search for and post my question.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP