Skip to content

Commit

Permalink
Merge pull request #106 from bowen-xu/time_projection
Browse files Browse the repository at this point in the history
Update time projection formula
  • Loading branch information
ccrock4t authored May 13, 2024
2 parents c8b8604 + c34e06e commit 3bd6316
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
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

0 comments on commit 3bd6316

Please sign in to comment.