From b135959e74237a82fd8269b5ff8ad2fa0c0dc118 Mon Sep 17 00:00:00 2001 From: ccrock4t <15344554+ccrock4t@users.noreply.github.com> Date: Mon, 6 May 2024 15:59:29 -0400 Subject: [PATCH 1/2] Update time projection formula --- pynars/Config.py | 1 - pynars/NAL/Functions/TemporalFunctions.py | 27 ++++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pynars/Config.py b/pynars/Config.py index 93ac5a44..b5fd1047 100644 --- a/pynars/Config.py +++ b/pynars/Config.py @@ -81,7 +81,6 @@ class Config: n_sequence_attempts = 10 n_op_condition_attempts = 10 - projection_decay = 0.99 Td_decision_threshold = 0.51 # what this value represents was originally equal to the termlink record length (10), but we may want to adjust it or make it scaled according to duration since it has more to do with time than # of records. it can probably be increased several times larger since each item should remain in the recording queue for longer than 1 cycle diff --git a/pynars/NAL/Functions/TemporalFunctions.py b/pynars/NAL/Functions/TemporalFunctions.py index 1ce72293..f7044403 100644 --- a/pynars/NAL/Functions/TemporalFunctions.py +++ b/pynars/NAL/Functions/TemporalFunctions.py @@ -6,22 +6,23 @@ def project(truth: Truth, t_source: int, t_current: int, t_target: int): ''' Reference: - [1] OpenNARS 3.1.0 TruthFunctions.java line 492~495: - ``` - public static final float temporalProjection(final long sourceTime, final long targetTime, final long currentTime, Parameters param) { - final double a = 100000.0 * param.PROJECTION_DECAY; //projection less strict as we changed in v2.0.0 10000.0 slower decay than 100000.0 - return 1.0f - abs(sourceTime - targetTime) / (float) (abs(sourceTime - currentTime) + abs(targetTime - currentTime) + a); - } - ``` - [2] Hammer, Patrick, Tony Lofthouse, and Pei Wang. "The OpenNARS implementation of the non-axiomatic reasoning system." International conference on artificial general intelligence. Springer, Cham, 2016. + p.172 Non-Axiomatic Logic + — A Model of Intelligent Reasoning + (Second Edition) + ''' + v = abs(t_source - t_target) - Section 5. Projection and Eternalization + t_current_is_in_interval = False + if t_source < t_target: + if t_current >= t_source and t_current <= t_target: t_current_is_in_interval = True + else: + if t_current <= t_source and t_current >= t_target: t_current_is_in_interval = True - $$k_c = \frac{|tB - tT|}{|tB - tC| + |tT - tC|}$$ + if t_current_is_in_interval: s = min(abs(t_source - t_current),abs(t_target-t_current)) + else: s = 0.5 - $$c_{new} = (1 - k_c) * c_{old}$$ - ''' - c_new = truth.c * (Config.projection_decay ** (t_current - t_source)) + confidence_discount = 1 - v/(2*s + v) + c_new = truth.c * confidence_discount return Truth(truth.f, c_new, truth.k) From c34e06effdf77ee582e1ac4caefadcf0a31153bf Mon Sep 17 00:00:00 2001 From: ccrock4t <15344554+ccrock4t@users.noreply.github.com> Date: Mon, 6 May 2024 16:03:30 -0400 Subject: [PATCH 2/2] flip the order of if-else --- pynars/NAL/Functions/TemporalFunctions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pynars/NAL/Functions/TemporalFunctions.py b/pynars/NAL/Functions/TemporalFunctions.py index f7044403..d31b94f7 100644 --- a/pynars/NAL/Functions/TemporalFunctions.py +++ b/pynars/NAL/Functions/TemporalFunctions.py @@ -18,8 +18,8 @@ def project(truth: Truth, t_source: int, t_current: int, t_target: int): else: if t_current <= t_source and t_current >= t_target: t_current_is_in_interval = True - if t_current_is_in_interval: s = min(abs(t_source - t_current),abs(t_target-t_current)) - else: s = 0.5 + if t_current_is_in_interval: s = 0.5 + else: s = min(abs(t_source - t_current),abs(t_target-t_current)) confidence_discount = 1 - v/(2*s + v) c_new = truth.c * confidence_discount