Skip to content

Commit 02930a7

Browse files
committed
fixes #22 and fixes #23
1 parent c95034b commit 02930a7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pyreason/scripts/interpretation/interpretation.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,20 @@ def reason(interpretations_node, interpretations_edge, tmax, prev_reasoning_data
582582
# If there is an edge to add or the predicate doesn't exist or the interpretation is not static
583583
if len(edges_to_add[0]) > 0 or rule.get_target() not in interpretations_node[n].world or not interpretations_node[n].world[rule.get_target()].is_static():
584584
bnd = annotate(annotation_functions, rule, annotations, rule.get_weights())
585-
bnd = interval.closed(bnd[0], bnd[1])
585+
# Bound annotations in between 0 and 1
586+
bnd_l = min(max(bnd[0], 0), 1)
587+
bnd_u = min(max(bnd[1], 0), 1)
588+
bnd = interval.closed(bnd_l, bnd_u)
586589
max_rules_time = max(max_rules_time, t + delta_t)
587590
edges_to_be_added_node_rule.append(edges_to_add)
588591
rules_to_be_applied_node.append((numba.types.uint16(t + delta_t), n, rule.get_target(), bnd, immediate_rule, rule.is_static_rule()))
589592
if atom_trace:
590593
rules_to_be_applied_node_trace.append((qualified_nodes, qualified_edges, rule.get_name()))
591594

592595
# We apply a rule on a node/edge only once in each timestep to prevent it from being added to the to_be_added list continuously (this will improve performance
593-
nodes_to_skip[i].append(n)
596+
# It's possible to have an annotation function that keeps changing the value of a node/edge. Do this only for delta_t>0
597+
if delta_t != 0:
598+
nodes_to_skip[i].append(n)
594599

595600
# Handle loop parameters for the next (maybe) fp operation
596601
# If it is a t=0 rule or an immediate rule we want to go back for another fp operation to check for new rules that may fire
@@ -614,15 +619,20 @@ def reason(interpretations_node, interpretations_edge, tmax, prev_reasoning_data
614619
# If there is an edge to add or the predicate doesn't exist or the interpretation is not static
615620
if len(edges_to_add[0]) > 0 or rule.get_target() not in interpretations_edge[e].world or not interpretations_edge[e].world[rule.get_target()].is_static():
616621
bnd = annotate(annotation_functions, rule, annotations, rule.get_weights())
617-
bnd = interval.closed(bnd[0], bnd[1])
622+
# Bound annotations in between 0 and 1
623+
bnd_l = min(max(bnd[0], 0), 1)
624+
bnd_u = min(max(bnd[1], 0), 1)
625+
bnd = interval.closed(bnd_l, bnd_u)
618626
max_rules_time = max(max_rules_time, t+delta_t)
619627
edges_to_be_added_edge_rule.append(edges_to_add)
620628
rules_to_be_applied_edge.append((numba.types.uint16(t+delta_t), e, rule.get_target(), bnd, immediate_rule, rule.is_static_rule()))
621629
if atom_trace:
622630
rules_to_be_applied_edge_trace.append((qualified_nodes, qualified_edges, rule.get_name()))
623631

624632
# We apply a rule on a node/edge only once in each timestep to prevent it from being added to the to_be_added list continuously (this will improve performance
625-
edges_to_skip[i].append(e)
633+
# It's possible to have an annotation function that keeps changing the value of a node/edge. Do this only for delta_t>0
634+
if delta_t != 0:
635+
edges_to_skip[i].append(e)
626636

627637
# Handle loop parameters for the next (maybe) fp operation
628638
# If it is a t=0 rule or an immediate rule we want to go back for another fp operation to check for new rules that may fire

0 commit comments

Comments
 (0)