Skip to content

Commit c793a3a

Browse files
committed
Add IsPurelyDisjunctive/IsPurelyConjunctive() helpers to ActivationCondition.
1 parent 942d190 commit c793a3a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

ift/encoder/activation_condition.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ namespace ift::encoder {
1414

1515
/*
1616
* The conditions under which a patch should be laoded.
17+
*
18+
* The condition is encoded as a monotonic CNF (Conjunctive Normal Form) boolean
19+
* expression:
20+
*
21+
* (s_1_1 OR s_1_2 OR ...) AND (s_2_1 OR ...) ...
1722
*/
1823
class ActivationCondition {
1924
public:
@@ -101,6 +106,28 @@ class ActivationCondition {
101106
return conditions().size() == 1 && conditions().at(0).size() == 1;
102107
}
103108

109+
// Returns true if the condition is of the form
110+
// a OR b f OR c ... with no conjunction.
111+
bool IsPurelyDisjunctive() const {
112+
return conditions().size() == 1;
113+
}
114+
115+
// Returns true if the condition is of the form
116+
// a AND b AND c ... with no disjunction.
117+
bool IsPurelyConjunctive() const {
118+
if (conditions().size() == 1) {
119+
return false;
120+
}
121+
122+
for (const auto& segments : conditions()) {
123+
if (segments.size() > 1) {
124+
return false;
125+
}
126+
}
127+
128+
return true;
129+
}
130+
104131
// Compute and return the probability that this condition will be activated
105132
// based on the provided individual segment probabilities.
106133
//

0 commit comments

Comments
 (0)