opennars / OpenNARS-4

MIT License
27 stars 8 forks source link

Working Cycle Metric #87

Closed ccrock4t closed 6 months ago

ccrock4t commented 10 months ago

This one adds time metrics for the working cycle, to solve #58

I will also try to determine the time complexity of the current code, since we want to ensure a small upper bound.

ccrock4t commented 10 months ago

image Top level function

To verify: consider() [VERIFIED] To verify: observe() [VERIFIED]

ccrock4t commented 10 months ago

image

consider() function

ccrock4t commented 10 months ago

image

observe() function

ccrock4t commented 10 months ago

image

memory.accept()

ccrock4t commented 10 months ago

After a rough analysis, the code seems to check out for running with a short-time upper bound

ccrock4t commented 10 months ago

Cycle metrics are now computed, and stored in the Reasoner object

They should probably be added to the GUI in #82

ccrock4t commented 10 months ago

The metric can be displayed in ConsolePlus using a new command /cycles

maxeeem commented 10 months ago

@ccrock4t is this pr ready or you still plan on pushing more changes?

ccrock4t commented 10 months ago

it's ready, I have just found some issues in self-reviewing

github-actions[bot] commented 10 months ago

dev.txt - DEV BRANCH: FAILED (failures=54, errors=13) pr.txt - PR BRANCH: FAILED (failures=58, errors=13)

--- dev.txt 2024-05-03 23:47:41.441223917 +0000
+++ pr.txt  2024-05-03 23:47:41.441223917 +0000
@@ -27,7 +27,7 @@
 test_backward_inference (test_NAL2.TEST_NAL2)
 'Backward inference ... ok
 test_comparison (test_NAL2.TEST_NAL2)
-'Comparison ... ok
+'Comparison ... FAIL
 test_conversions_between_inheritance_and_similarity (test_NAL2.TEST_NAL2)
 'Conversions between inheritance and similarity ... ok
 test_conversions_between_inheritance_and_similarity_0 (test_NAL2.TEST_NAL2)
@@ -138,9 +138,9 @@
 test_conditional_analogy (test_NAL5.TEST_NAL5)
 'Detachment ... ok
 test_conditional_deduction_0 (test_NAL5.TEST_NAL5)
-'Detachment ... ok
+'Detachment ... FAIL
 test_conditional_deduction_compound_eliminate_0 (test_NAL5.TEST_NAL5)
-'conditional deduction ... ok
+'conditional deduction ... FAIL
 test_conditional_deduction_compound_eliminate_1 (test_NAL5.TEST_NAL5)
 'conditional deduction ... ok
 test_conditional_deduction_compound_replace_0 (test_NAL5.TEST_NAL5)
@@ -226,7 +226,7 @@
 test_multiple_variables_introduction_0 (test_NAL6.TEST_NAL6)
 'Multiple variables introduction ... FAIL
 test_multiple_variables_introduction_1 (test_NAL6.TEST_NAL6)
-'Multiple variables introduction ... ok
+'Multiple variables introduction ... FAIL
 test_nlp1 (test_NAL6.TEST_NAL6)
 <(\,REPRESENT,_,CAT) --> cat>. %1.00;0.90% ... ok
 test_nlp2 (test_NAL6.TEST_NAL6)
@@ -260,7 +260,7 @@
 test_unification_4 (test_NAL6.TEST_NAL6)
 'Variable unification ... ok
 test_unification_5 (test_NAL6.TEST_NAL6)
-'Variable unification ... ok
+'Variable unification ... ERROR
 test_unification_5_1 (test_NAL6.TEST_NAL6)
 'Variable unification ... ok
 test_unification_6 (test_NAL6.TEST_NAL6)
@@ -353,7 +353,7 @@
 test_1_13_var (test_NAL8.TEST_NAL8)
 nal8.1.13.nal ... ERROR
 test_1_14 (test_NAL8.TEST_NAL8)
-nal8.1.14.nal ... FAIL
+nal8.1.14.nal ... ok
 test_1_16 (test_NAL8.TEST_NAL8)
 nal8.1.16.nal ... FAIL
 test_1_2 (test_NAL8.TEST_NAL8)
@@ -361,7 +361,7 @@
 test_1_3 (test_NAL8.TEST_NAL8)
 nal8.1.3.nal ... ok
 test_1_3_var (test_NAL8.TEST_NAL8)
-nal8.1.3.nal ... ERROR
+nal8.1.3.nal ... FAIL
 test_1_4 (test_NAL8.TEST_NAL8)
 nal8.1.4.nal ... ok
 test_1_4_var (test_NAL8.TEST_NAL8)
maxeeem commented 10 months ago

@ccrock4t I think the calculations aren't quite correct. I keep getting Cycles per second is 1. every time. Should we be keeping a running average, similarly to what I did with the inference metrics? https://github.com/bowen-xu/PyNARS/pull/17#issuecomment-1910650589

ccrock4t commented 10 months ago

@ccrock4t I think the calculations aren't quite correct. I keep getting Cycles per second is 1. every time. Should we be keeping a running average, similarly to what I did with the inference metrics? #17 (comment)

You're right, I'm sorry, this was not the behavior I got earlier. I will look into it. I also agree that a running average will be nice

ccrock4t commented 10 months ago

I see, it is because 1 second minimum has to elapse before a metric is recorded. So some sort of avg or extrapolation will be necessary