Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update time projection formula #106

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pynars/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions pynars/NAL/Functions/TemporalFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 0.5
else: s = min(abs(t_source - t_current),abs(t_target-t_current))

$$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)


Expand Down
Loading