Skip to content

Commit

Permalink
fixed bug in rule trace due to deletion of applied rules and changed …
Browse files Browse the repository at this point in the history
…version
  • Loading branch information
dyumanaditya committed Aug 9, 2023
1 parent 4447751 commit ad09721
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions pyreason/scripts/interpretation/interpretation.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def reason(interpretations_node, interpretations_edge, tmax, prev_reasoning_data
# If we are coming here from an immediate rule firing with delta_t=0 we have to apply that one rule. Which was just added to the list to_be_applied
if immediate_node_rule_fire and rules_to_be_applied_node[-1][4]:
i = rules_to_be_applied_node[-1]
idx = -1
idx = len(rules_to_be_applied_node) - 1

if i[0]==t:
comp, l, bnd, immediate = i[1], i[2], i[3], i[4]
Expand Down Expand Up @@ -417,6 +417,8 @@ def reason(interpretations_node, interpretations_edge, tmax, prev_reasoning_data
# Remove from rules to be applied and edges to be applied lists after coming out from loop
rules_to_be_applied_node[:] = numba.typed.List([rules_to_be_applied_node[i] for i in range(len(rules_to_be_applied_node)) if i not in rules_to_remove_idx])
edges_to_be_added_node_rule[:] = numba.typed.List([edges_to_be_added_node_rule[i] for i in range(len(edges_to_be_added_node_rule)) if i not in rules_to_remove_idx])
if atom_trace:
rules_to_be_applied_node_trace[:] = numba.typed.List([rules_to_be_applied_node_trace[i] for i in range(len(rules_to_be_applied_node_trace)) if i not in rules_to_remove_idx])

# Edges
rules_to_remove_idx.clear()
Expand All @@ -427,7 +429,7 @@ def reason(interpretations_node, interpretations_edge, tmax, prev_reasoning_data
# If we are coming here from an immediate rule firing with delta_t=0 we have to apply that one rule. Which was just added to the list to_be_applied
if immediate_edge_rule_fire and rules_to_be_applied_edge[-1][4]:
i = rules_to_be_applied_edge[-1]
idx = -1
idx = len(rules_to_be_applied_edge) - 1

if i[0]==t:
comp, l, bnd, immediate = i[1], i[2], i[3], i[4]
Expand Down Expand Up @@ -504,6 +506,8 @@ def reason(interpretations_node, interpretations_edge, tmax, prev_reasoning_data
# Remove from rules to be applied and edges to be applied lists after coming out from loop
rules_to_be_applied_edge[:] = numba.typed.List([rules_to_be_applied_edge[i] for i in range(len(rules_to_be_applied_edge)) if i not in rules_to_remove_idx])
edges_to_be_added_edge_rule[:] = numba.typed.List([edges_to_be_added_edge_rule[i] for i in range(len(edges_to_be_added_edge_rule)) if i not in rules_to_remove_idx])
if atom_trace:
rules_to_be_applied_edge_trace[:] = numba.typed.List([rules_to_be_applied_edge_trace[i] for i in range(len(rules_to_be_applied_edge_trace)) if i not in rules_to_remove_idx])

# Fixed point
# if update or immediate_node_rule_fire or immediate_edge_rule_fire or immediate_rule_applied:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name = 'pyreason',
version = '1.6.3',
version = '1.6.4',
author = 'Dyuman Aditya',
author_email = '[email protected]',
description = 'An explainable inference software supporting annotated, real valued, graph based and temporal logic',
Expand Down

0 comments on commit ad09721

Please sign in to comment.