Skip to content

Commit

Permalink
[ALL TESTS PASS] Fixed solo B activations not being included after th…
Browse files Browse the repository at this point in the history
…e final A scan.

Note: Impossible to make a data test as Succession would never be mined due to the requirement of having a lone A AND a lone B.  A lone B would previously not be considered as an activation, but would have violated anyway, so wouldn't be easily detectable. Regardless, the behaviour is now logically sound.
  • Loading branch information
SamuelAppleby committed Aug 14, 2023
1 parent ea236e6 commit a76c43a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/knobab/mining/bolt2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,8 @@ Bolt2Branching(const KnowledgeBase &kb, bool only_precise_temporal_patterns,
not_a_activated_and_not_b_activated += (b_beginend.first == b_beginend.second)
? (ntraces - a_trace_id - 1) : (b_trace_id - a_trace_id - 1);

//TODO Here be dragons
if((b_beginend.first != b_beginend.second) && (branch == branch_type::LEFT)) {
b_trace_id = b_beginend.first->entry.id.parts.trace_id;

TRACE_SET_ADD(data.r_activation_traces.second, b_trace_id);
TRACE_SET_ADD(data.p_activation_traces.second, b_trace_id);
}
Expand Down Expand Up @@ -427,11 +426,6 @@ Bolt2Branching(const KnowledgeBase &kb, bool only_precise_temporal_patterns,

if ((a_beginend.first == a_beginend.second) || ((b_beginend.first != b_beginend.second) && (a_beginend.first->entry.id.parts.trace_id >= b_beginend.first->entry.id.parts.trace_id))) {
not_a_activated_and_not_b_activated += ((b_beginend.first == b_beginend.second) ? (ntraces - a_trace_id - 1) : (b_beginend.first->entry.id.parts.trace_id - a_trace_id - 1));

if((a_beginend.first == a_beginend.second) && (b_beginend.first != b_beginend.second)) {
b_trace_id = b_beginend.first->entry.id.parts.trace_id;
SoloBCompute(branch, data, b_trace_id);
}
}
else if ((a_beginend.first != a_beginend.second) && ((b_beginend.first == b_beginend.second) || (a_beginend.first->entry.id.parts.trace_id < b_beginend.first->entry.id.parts.trace_id))) {
not_a_activated_and_not_b_activated += (a_beginend.first->entry.id.parts.trace_id - a_trace_id - 1);
Expand All @@ -440,14 +434,17 @@ Bolt2Branching(const KnowledgeBase &kb, bool only_precise_temporal_patterns,

/* We may have broke early (i.e. we're still not at the end of the As), don't compute unless required */
if ((a_beginend.first == a_beginend.second) && (b_beginend.first != b_beginend.second)) {
b_trace_id++;
for (; b_trace_id < ntraces; b_trace_id++) {
b_trace_id = b_beginend.first->entry.id.parts.trace_id;
SoloBCompute(branch, data, b_trace_id);

for (uint32_t current = (b_trace_id + 1); current++ < ntraces; current++) {
if (count_table.resolve_length(B, b_trace_id) == 0) {
not_b_activated++;
not_a_activated_and_not_b_activated++;
}
else {
SoloBCompute(branch, data, b_trace_id);
b_trace_id = current;
}
}
}
Expand Down

0 comments on commit a76c43a

Please sign in to comment.