Skip to content

Commit

Permalink
Merge branch 'dev' into GlobalEval
Browse files Browse the repository at this point in the history
  • Loading branch information
bowen-xu committed Dec 7, 2023
2 parents b57d487 + c09b5c6 commit 49e4b83
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions pynars/NARS/Control/Reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ..GlobalEval import GlobalEval



class Reasoner:

def __init__(self, n_memory, capacity, config='./config.json', nal_rules={1, 2, 3, 4, 5, 6, 7, 8, 9}) -> None:
Expand Down Expand Up @@ -97,34 +98,6 @@ def cycle(self):
+ (1 - Config.Config.r_top_level_attention_adjust) * \
self.u_top_level_attention

# temporal induction in NAL-7
if Enable.temporal_reasoning and task is not None and task.is_judgement and task.is_external_event:
concept_task: Concept = self.memory.take_by_key(
task.term, remove=False)
t1 = time()
tasks_derived.extend(
self.temporal_inference.step(
task, concept_task,
self.sequence_buffer,
self.operations_buffer
)
)
t2 = time()
print(f"time: {t2-t1}")
else:
pass # TODO: select a task from `self.sequence_buffer`?

# mental operation of NAL-9
if Enable.operation: # it should be `Enable.mental_operation`?
task_operation_return, task_executed, belief_awared = self.mental_operation(task, concept, answers_question,
answers_quest)
if task_operation_return is not None:
tasks_derived.append(task_operation_return)
if task_executed is not None:
tasks_derived.append(task_executed)
if belief_awared is not None:
tasks_derived.append(belief_awared)

# put the derived tasks into the internal-experience.
for task_derived in tasks_derived:
self.internal_experience.put(task_derived)
Expand Down Expand Up @@ -226,6 +199,39 @@ def observe(self, tasks_derived: List[Task]):
judgement_revised.truth.c - task.truth.c)
else:
self.global_eval.update_alertness(0.0)
# TODO: handling temporal induction and mental operation
# Is it implemented correctly?

# temporal induction in NAL-7
if Enable.temporal_reasoning and task is not None and task.is_judgement and task.is_external_event:
concept_task: Concept = self.memory.take_by_key(
task.term, remove=False)
# t1 = time()
tasks_derived.extend(
self.temporal_inference.step(
task, concept_task,
self.sequence_buffer,
self.operations_buffer
)
)
# t2 = time()
# print(f"time: {t2-t1}")
else:
pass # TODO: select a task from `self.sequence_buffer`?

# mental operation of NAL-9
if Enable.operation: # it should be `Enable.mental_operation`?
# self.memory.
concept_task: Concept = self.memory.take_by_key(
task.term, remove=False)
task_operation_return, task_executed, belief_awared = self.mental_operation(
task, concept_task, answers_question, answers_quest)
if task_operation_return is not None:
tasks_derived.append(task_operation_return)
if task_executed is not None:
tasks_derived.append(task_executed)
if belief_awared is not None:
tasks_derived.append(belief_awared)

return judgement_revised, goal_revised, answers_question, answers_quest,

Expand Down

0 comments on commit 49e4b83

Please sign in to comment.