You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/user_guide/8_advanced_usage.rst
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,14 @@ PyReason allows you to reason over the graph multiple times. This can be useful
20
20
and add facts that were not available before. To reason over the graph multiple times, you can set ``again=True`` in ``pr.reason(again=True)``.
21
21
To specify additional facts or rules, you can add them as you normally would using ``pr.add_fact`` and ``pr.add_rule``.
22
22
23
+
You can also clear the rules to use completely different ones with ``pr.clear_rules()``. This can be useful when you
24
+
want to reason over the graph with a new set of rules.
25
+
26
+
When reasoning multiple times, the time is reset to zero. Therefore any facts that are added should take this into account.
27
+
It is also possible to continue incrementing the time by running ``pr.reason(again=True, restart=False)``
28
+
23
29
.. note::
24
-
When reasoning multiple times, the time continues to increment. Therefore any facts that are added should take this into account.
30
+
When reasoning multiple times with ``restart=False``, the time continues to increment. Therefore any facts that are added should take this into account.
25
31
The timestep parameter specifies how many additional timesteps to reason. For example, if the initial reasoning converges at
26
32
timestep 5, and you want to reason for 3 more timesteps, you can set ``timestep=3`` in ``pr.reason(timestep=3, again=True)``.
27
33
If you are specifying new facts, take this into account when setting their ``start_time`` and ``end_time``.
"""Function to start the main reasoning process. Graph and rules must already be loaded.
638
644
639
645
:param timesteps: Max number of timesteps to run. -1 specifies run till convergence. If reasoning again, this is the number of timesteps to reason for extra (no zero timestep), defaults to -1
640
646
:param convergence_threshold: Maximum number of interpretations that have changed between timesteps or fixed point operations until considered convergent. Program will end at convergence. -1 => no changes, perfect convergence, defaults to -1
641
647
:param convergence_bound_threshold: Maximum change in any interpretation (bounds) between timesteps or fixed point operations until considered convergent, defaults to -1
642
648
:param queries: A list of PyReason query objects that can be used to filter the ruleset based on the query. Default is None
643
649
:param again: Whether to reason again on an existing interpretation, defaults to False
644
-
:param facts: New facts to use during the next reasoning process when reasoning again. Other facts from file will be discarded, defaults to None
650
+
:param restart: Whether to restart the program time from 0 when reasoning again, defaults to True
645
651
:return: The final interpretation after reasoning.
646
652
"""
647
653
globalsettings, __timestamp
@@ -662,10 +668,10 @@ def reason(timesteps: int = -1, convergence_threshold: int = -1, convergence_bou
0 commit comments