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

(WIP) Attempt to eliminate cyclic dependency NAR→Cycle→Decision #280

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions src/Cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void Cycle_PopEvents(Event *selectionArray, double *selectionPriority, int *sele
//{Event (a &/ b)!, Event a.} |- Event b! Truth_Deduction
//if Truth_Expectation(a) >= ANTICIPATION_THRESHOLD else
//{Event (a &/ b)!} |- Event a! Truth_StructuralDeduction
bool Cycle_GoalSequenceDecomposition(Event *selectedGoal, double selectedGoalPriority, int layer)
bool Cycle_GoalSequenceDecomposition(Event *selectedGoal, double selectedGoalPriority, int layer, long currentTime)
{
//1. Extract potential subgoals
if(!Narsese_copulaEquals(selectedGoal->term.atoms[0], SEQUENCE)) //left-nested sequence
Expand Down Expand Up @@ -276,7 +276,7 @@ static void Cycle_ProcessAndInferGoalEvents(long currentTime, int layer)
Event *goal = &selectedGoals[i];
IN_DEBUG( fputs("selected goal ", stdout); Narsese_PrintTerm(&goal->term); puts(""); )
//if goal is a sequence, overwrite with first deduced non-fulfilled element
if(Cycle_GoalSequenceDecomposition(goal, selectedGoalsPriority[i], layer)) //the goal was a sequence which leaded to a subgoal derivation
if(Cycle_GoalSequenceDecomposition(goal, selectedGoalsPriority[i], layer, currentTime)) //the goal was a sequence which leaded to a subgoal derivation
{
continue;
}
Expand Down Expand Up @@ -340,7 +340,7 @@ static void Cycle_ProcessAndInferGoalEvents(long currentTime, int layer)
}

//Reinforce temporal implication link between a's and b's concept (via temporal induction)
static Implication Cycle_ReinforceLink(Event *a, Event *b)
static Implication Cycle_ReinforceLink(Event *a, Event *b, long currentTime)
{
if(a->type != EVENT_TYPE_BELIEF || b->type != EVENT_TYPE_BELIEF)
{
Expand Down Expand Up @@ -416,7 +416,7 @@ void Cycle_ProcessBeliefEvents(long currentTime)
//so now derive it
if(success5)
{
Cycle_ReinforceLink(&seq_op_cur, &postcondition); //<(A &/ op) =/> B>
Cycle_ReinforceLink(&seq_op_cur, &postcondition, currentTime); //<(A &/ op) =/> B>
}
}
}
Expand Down Expand Up @@ -445,10 +445,10 @@ void Cycle_ProcessBeliefEvents(long currentTime)
{
if(!op_id && !op_id2)
{
Cycle_ReinforceLink(&c->belief_spike, &postcondition); //<A =/> B>, <A =|> B>
Cycle_ReinforceLink(&c->belief_spike, &postcondition, currentTime); //<A =/> B>, <A =|> B>
if(c->belief_spike.occurrenceTime == postcondition.occurrenceTime)
{
Cycle_ReinforceLink(&postcondition, &c->belief_spike); //<B =|> A>
Cycle_ReinforceLink(&postcondition, &c->belief_spike, currentTime); //<B =|> A>
}
}
int sequence_len = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/Decision.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static Decision Decision_MotorBabbling()
return decision;
}

static Decision Decision_ConsiderNegativeOutcomes(Decision decision)
static Decision Decision_ConsiderNegativeOutcomes(Decision decision, long currentTime)
{
Event OpGoalImmediateOutcomes = {0};
//1. discount decision based on negative outcomes via revision
Expand Down Expand Up @@ -386,7 +386,7 @@ static Decision Decision_ConsiderImplication(long currentTime, Event *goal, Impl
i++;
}
}
return Decision_ConsiderNegativeOutcomes(decision);
return Decision_ConsiderNegativeOutcomes(decision, currentTime);
}

Decision Decision_BestCandidate(Concept *goalconcept, Event *goal, long currentTime)
Expand Down
1 change: 0 additions & 1 deletion src/Decision.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include <stdbool.h>
#include <stdio.h>
#include "Memory.h"
#include "NAR.h"
#include "Config.h"

//Parameters//
Expand Down
2 changes: 1 addition & 1 deletion src/NAR.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "NAR.h"

long currentTime = 1;
static long currentTime = 1; //This needs to be private to encourage the design of "pass in parameters rather than using global variables"
static bool initialized = false;
static int op_k = 0;
double QUESTION_PRIMING = QUESTION_PRIMING_INITIAL;
Expand Down
1 change: 0 additions & 1 deletion src/NAR.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
//Parameters//
//----------//
#define NAR_DEFAULT_TRUTH ((Truth) { .frequency = NAR_DEFAULT_FREQUENCY, .confidence = NAR_DEFAULT_CONFIDENCE })
extern long currentTime;
extern double QUESTION_PRIMING;

//Callback function types//
Expand Down