コード例 #1
0
ファイル: TemporalRules.cs プロジェクト: chargen/AGI-X0
        // https://github.com/opennars/opennars/blob/master/nars_core/nars/inference/TemporalRules.java#L502

        /**
         * Evaluate the quality of the judgment as a solution to a problem
         *
         * \param problem A goal or question
         * \param solution The solution to be evaluated
         * \return The quality of the judgment as the solution
         */
        public static float solutionQuality(EnumRateByConfidence rateByConfidence, ClassicalTask problemTask, ClassicalSentence solution, Memory memory, CompoundAndTermContext compoundAndTermContext)
        {
            ClassicalSentence problem = problemTask.sentence;

            /* TODO< implement TEMPORAL
             * if (!matchingOrder(problem.temporalOrder, solution.temporalOrder)) {
             *  return 0.0F;
             * }
             */

            TruthValue truth = solution.truth;

            if (problem.stamp.occurrenceTime != solution.stamp.occurrenceTime)
            {
                truth = solution.projectionTruth(problem.stamp.occurrenceTime, memory.time);
            }

            //when the solutions are comparable, we have to use confidence!! else truth expectation.
            //this way negative evidence can update the solution instead of getting ignored due to lower truth expectation.
            //so the previous handling to let whether the problem has query vars decide was wrong.
            if (rateByConfidence == EnumRateByConfidence.NO)
            {
                return((float)(truth.expectation / Math.Sqrt(Math.Sqrt(Math.Sqrt(compoundAndTermContext.getTermComplexityOfAndByTermReferer(solution.term) * Parameters.COMPLEXITY_UNIT)))));
            }
            else
            {
                return(truth.confidence);
            }
        }
コード例 #2
0
ファイル: LocalRules.cs プロジェクト: chargen/AGI-X0
        // does the emotion part of the trySolution function
        private static void trySolution_emotion(ClassicalSentence belief, ClassicalTask task, DerivationContext ctx)
        {
            ClassicalSentence problem = task.sentence;
            Memory            memory  = ctx.memory;

            ClassicalSentence oldBest = task.bestSolution;

            if (oldBest != null)
            {
                TemporalRules.EnumRateByConfidence rateByConfidence =
                    oldBest.term == belief.term ? TemporalRules.EnumRateByConfidence.YES : TemporalRules.EnumRateByConfidence.NO;

                float newQ = TemporalRules.solutionQuality(rateByConfidence, task, belief, memory, ctx.compoundAndTermContext);
                float oldQ = TemporalRules.solutionQuality(rateByConfidence, task, oldBest, memory, ctx.compoundAndTermContext);
                if (oldQ >= newQ)
                {
                    if (problem.isGoal)
                    {
                        memory.emotion.adjustHappy(oldQ, task.budget.priority, ctx);
                    }
                    //System.out.println("Unsolved: Solution of lesser quality");
                    //java memory.emit(Unsolved.class, task, belief, "Lower quality");
                    return;
                }
            }
        }
コード例 #3
0
        protected static void fireTaskLink(DerivationContext ctx, uint termLinks)
        {
            ClassicalTask task = ctx.currentTaskLink.targetTask;

            ctx.currentTerm       = ctx.currentConcept.term;
            ctx.currentBeliefLink = null;
            ctx.currentTask       = task; // one of the two places where this variable is set

            /* commented because PATRICK screwed up again, TODO MEDIUM< clarify with patrick after his study induced inactivity time
             * if( ctx.currentTaskLink.type == ClassicalTaskLink.EnumType.TRANSFORM ) {
             *  ctx.currentBelief = null;
             *
             *  RuleTables.transformTask(ctx.currentTaskLink, ctx); // to turn this into structural inference as below?
             * }
             * else */{
                while (termLinks > 0)
                {
                    ClassicalTermLink termLink = ctx.currentConcept.selectTermLink(ctx.currentTaskLink, ctx.memory.time);
                    if (termLink == null)
                    {
                        break;
                    }
                    fireTermlink(termLink, ctx);
                    ctx.currentConcept.returnTermLink(termLink);
                    termLinks--;
                }
            }

            //ctx.memory.emit(Events.ConceptFire.class, nal);
            //memory.logic.TASKLINK_FIRE.commit(currentTaskLink.budget.getPriority());
        }
コード例 #4
0
        // https://github.com/opennars/opennars/blob/master/nars_core/nars/entity/Concept.java#L233

        /**
         * To accept a new judgment as belief, and check for revisions and solutions
         *
         * \param judg The judgment to be accepted
         * \param task The task to be processed
         * \return Whether to continue the processing of the task
         */
        private void processJudgment(DerivationContext ctx, ClassicalConcept @this, ClassicalTask task)
        {
            ClassicalSentence judgement = task.sentence;

            ClassicalTask oldBeliefTask = selectCandidate(task, @this.beliefs, EnumForRevision.REVISION);// only revise with the strongest
            // QUESTION< how about projection? >
            ClassicalSentence oldBelief = null;

            if (oldBeliefTask != null)
            {
                oldBelief = oldBeliefTask.sentence;
                Stamp newStamp = judgement.stamp;
                Stamp oldStamp = oldBelief.stamp;       // when table is full, the latter check is especially important, too
                if (
                    Stamp.checkEquals(
                        newStamp,
                        oldStamp,
                        Stamp.EnumCompareCreationTime.NO,
                        Stamp.EnumCompareOccurrenceTime.YES,
                        Stamp.EnumCompareEvidentialBaseTime.YES) &&
                    task.sentence.truth == oldBelief.truth
                    )
                {
                    memory.removeTask(task, "Duplicated");
                    return;
                }
                else if (LocalRules.revisible(judgement, oldBelief))
                {
                    // commented because we have to implement revision like in the legacy system
                    // projection can occur either with the NARS default or the new exponential decay model
                    // QUESTION< which one is better ? >

                    ctx.setTheNewStamp(newStamp, oldStamp, memory.time);
                    ClassicalSentence projectedBelief = oldBelief.projection(memory.time, newStamp.occurrenceTime);
                    if (projectedBelief != null)
                    {
                        if (projectedBelief.stamp.occurrenceTime != oldBelief.stamp.occurrenceTime)
                        {
                            // nal.singlePremiseTask(projectedBelief, task.budget);
                        }
                        ctx.currentBelief = projectedBelief;
                        LocalRules.revision(ctx, judgement, projectedBelief, false);
                    }
                }
            }

            if (task.isAboveThreshold)
            {
                foreach (var iQuestion in @this.questions)
                {
                    LocalRules.trySolution(judgement, iQuestion, ctx, true, memory);
                }

                TableMaintenance.addToTable(task, false, @this.beliefs, Parameters.CONCEPT_BELIEFS_MAX, null /*ConceptBeliefAdd.class*/, null /*ConceptBeliefRemove.class*/);


                // if taskLink predicts this concept then add to predictive
                // TODO
            }
        }
コード例 #5
0
        // see https://github.com/opennars/opennars/blob/master/nars_core/nars/entity/Concept.java#L779

        /**
         * Select a belief value or desire value for a given query
         *
         * @param query The query to be processed
         * @param list The list of beliefs or desires to be used
         * @return The best candidate selected
         */
        ClassicalTask selectCandidate(ClassicalTask query, IList <ClassicalTask> list, EnumForRevision forRevision)
        {
            var rateByConfidence = TemporalRules.EnumRateByConfidence.YES; //table vote, yes/no question / local processing

            // TODO< paralelize somehow >

            float         currentBest = 0;
            float         beliefQuality;
            ClassicalTask candidate = null;

            //synchronized(list) {
            for (int i = 0; i < list.Count; i++)
            {
                ClassicalTask     judgT = list[i];
                ClassicalSentence judg  = judgT.sentence;
                beliefQuality = TemporalRules.solutionQuality(rateByConfidence, query, judg, memory, compoundAndTermContext);     // makes revision explicitly search for
                if (beliefQuality > currentBest /*&& (!forRevision || judgT.sentence.equalsContent(query)) */ /*&& (!forRevision || !Stamp.baseOverlap(query.stamp.evidentialBase, judg.stamp.evidentialBase)) */)
                {
                    currentBest = beliefQuality;
                    candidate   = judgT;
                }
            }
            //}
            return(candidate);
        }
コード例 #6
0
        // https://github.com/opennars/opennars/blob/master/nars_core/nars/entity/Concept.java#L193
        public void directProcess(DerivationContext ctx, ClassicalConcept @this, ClassicalTask task)
        {
            var puctuation = task.sentence.punctation;

            /*final*/ switch (puctuation)
            {
            case ClassicalSentence.EnumPunctation.JUDGMENT:
                processJudgment(ctx, @this, task);
                break;

            case ClassicalSentence.EnumPunctation.GOAL:
                processGoal(ctx, @this, task);
                break;

            case ClassicalSentence.EnumPunctation.QUESTION:
            case ClassicalSentence.EnumPunctation.QUEST:
                processQuestion(ctx, @this, task);
                break;
            }

            maintainDisappointedAnticipations();

            if (task.isAboveThreshold)       // still need to be processed
                                             //memory.logic.LINK_TO_TASK.commit();
            {
                linkToTask(ctx, @this, task);
            }
        }
コード例 #7
0
ファイル: Memory.cs プロジェクト: chargen/AGI-X0
 /**
  * add new task that waits to be processed in the next cycleMemory
  */
 public void addNewTask(ClassicalTask t, string reason)
 {
     newTasks.Enqueue(t);
     //  logic.TASK_ADD_NEW.commit(t.getPriority());
     //emit(Events.TaskAdd.class, t, reason);
     //output(t);
 }
コード例 #8
0
ファイル: LocalRules.cs プロジェクト: chargen/AGI-X0
        /* -------------------- same contents -------------------- */

        /**
         * The task and belief have the same content
         * <p>
         * called in RuleTables.reason
         *
         * @param task The task
         * @param belief The belief
         * @param memory Reference to the memory
         */
        public static bool match(ClassicalTask task, ClassicalSentence belief, DerivationContext ctx)
        {
            ClassicalSentence sentence = task.sentence;

            if (sentence.isJudgment)
            {
                if (revisible(sentence, belief))
                {
                    return(revision(ctx, sentence, belief, true));
                }
            }
            else
            {
                // TODO

                /* commented because variables and order are not implemented
                 * if (matchingOrder(sentence, belief)) {
                 *  Term[] u = new Term[] { sentence.term, belief.term };
                 *  if (Variables.unify(Symbols.VAR_QUERY, u)) {
                 *      trySolution(belief, task, nal, true);
                 *  }
                 * }
                 */
            }
            return(false);
        }
コード例 #9
0
ファイル: DerivationContext.cs プロジェクト: chargen/AGI-X0
 /** tasks added with this method will be remembered by this NAL instance; useful for feedback */
 public void addTask(ClassicalTask t, string reason)
 {
     if (t.sentence.term == null)
     {
         return;
     }
     memory.addNewTask(t, reason);
 }
コード例 #10
0
ファイル: Memory.cs プロジェクト: chargen/AGI-X0
        public void perceptNewTaskWithBudgetCheck(ClassicalTask t)
        {
            if (!t.isAboveThreshold)
            {
                return;
            }

            addNewTask(t, "perceived");
        }
コード例 #11
0
ファイル: DerivationContext.cs プロジェクト: chargen/AGI-X0
        /**
         * Activated task called in MatchingRules.trySolution and
         * Concept.processGoal
         *
         * @param budget The budget value of the new Task
         * @param sentence The content of the new Task
         * @param candidateBelief The belief to be used in future inference, for
         * forward/backward correspondence
         */
        public void addTask(ClassicalTask currentTask, ClassicalBudgetValue budget, ClassicalSentence sentence, ClassicalSentence candidateBelief)
        {
            ClassicalTask.MakeParameters taskParameters = new ClassicalTask.MakeParameters();
            taskParameters.sentence     = sentence;
            taskParameters.budget       = budget;
            taskParameters.parentTask   = currentTask;
            taskParameters.parentBelief = sentence;
            taskParameters.bestSolution = candidateBelief;

            addTask(ClassicalTask.make(taskParameters), "Activated");
        }
コード例 #12
0
ファイル: Memory.cs プロジェクト: chargen/AGI-X0
        // see https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/storage/Memory.java#L392
        void localInference(ClassicalTask task)
        {
            DerivationContext context = new DerivationContext(this, compoundAndTermContext);

            context.currentTask    = task;
            context.currentTerm    = task.sentence.term;
            context.currentConcept = conceptualize(task.budget, context.currentTerm);
            if (context.currentConcept != null)
            {
                conceptProcessing.directProcess(context, context.currentConcept, task);
            }
        }
コード例 #13
0
ファイル: Class1.cs プロジェクト: chargen/AGI-X0
        static void testNars()
        {
            CompoundAndTermContext compoundAndTermContext = new CompoundAndTermContext();

            RuleDispatcher.compoundAndTermContext = compoundAndTermContext; // for debugging

            PrototypingInput prototypingInput = new PrototypingInput(compoundAndTermContext);

            Nar nar = Nar.make(compoundAndTermContext, new MetaNix.nars.config.RuntimeParameters());

            CompoundIndex compoundIndex1 = prototypingInput.makeInheritance("a", "b");

            ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters task1SentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters();
            task1SentenceParameters.term       = compoundAndTermContext.accessCompoundByIndex(compoundIndex1).thisTermReferer;
            task1SentenceParameters.truth      = TruthValue.make(1.0f, 0.5f);
            task1SentenceParameters.stamp      = Stamp.makeWithPresentTense(nar.memory);
            task1SentenceParameters.punctation = ClassicalSentence.EnumPunctation.JUDGMENT;
            ClassicalSentence task1Sentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(task1SentenceParameters);

            ClassicalTask.MakeParameters task1MakeParameters = new ClassicalTask.MakeParameters();
            task1MakeParameters.sentence = task1Sentence;
            task1MakeParameters.budget   = new ClassicalBudgetValue(0.5f, 0.5f, 0.5f);

            nar.inputTask(ClassicalTask.make(task1MakeParameters));



            CompoundIndex compoundIndex2 = prototypingInput.makeInheritance("b", "c");

            ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters task2SentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters();
            task2SentenceParameters.term       = compoundAndTermContext.accessCompoundByIndex(compoundIndex2).thisTermReferer;
            task2SentenceParameters.truth      = TruthValue.make(1.0f, 0.5f);
            task2SentenceParameters.stamp      = Stamp.makeWithPresentTense(nar.memory);
            task2SentenceParameters.punctation = ClassicalSentence.EnumPunctation.JUDGMENT;
            ClassicalSentence task2Sentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(task2SentenceParameters);

            ClassicalTask.MakeParameters task2MakeParameters = new ClassicalTask.MakeParameters();
            task2MakeParameters.sentence = task2Sentence;
            task2MakeParameters.budget   = new ClassicalBudgetValue(0.5f, 0.5f, 0.5f);

            nar.inputTask(ClassicalTask.make(task2MakeParameters));

            for (;;)
            {
                nar.cycle();
            }

            int here = 5;
        }
コード例 #14
0
ファイル: DerivationContext.cs プロジェクト: chargen/AGI-X0
        public bool singlePremiseTask(ClassicalSentence newSentence, ClassicalBudgetValue newBudget)
        {
            if (!newBudget.isAboveThreshold)
            {
                return(false);
            }

            ClassicalTask.MakeParameters newTaskParameters = new ClassicalTask.MakeParameters();
            newTaskParameters.sentence   = newSentence;
            newTaskParameters.budget     = newBudget;
            newTaskParameters.parentTask = currentTask;

            ClassicalTask newTask = ClassicalTask.make(newTaskParameters);

            return(derivedTask(newTask, false, true, null, null, false));
        }
コード例 #15
0
ファイル: LocalRules.cs プロジェクト: chargen/AGI-X0
        /**
         * Check if a Sentence provide a better answer to a Question or Goal
         *
         * \param belief The proposed answer
         * \param task The task to be processed
         */
        public static bool trySolution(ClassicalSentence belief, ClassicalTask task, DerivationContext ctx, bool report, Memory memory)
        {
            trySolution_emotion(belief, task, ctx);

            task.setBestSolution(memory, belief);

            //memory.logic.SOLUTION_BEST.commit(task.getPriority());

            ClassicalBudgetValue budget = TemporalRules.solutionEval(task, belief, task, ctx);

            if (budget == null || !budget.isAboveThreshold)
            {
                //memory.emit(Unsolved.class, task, belief, "Insufficient budget");
                return(false);
            }
            // Solution was Activated

            // report
            if (task.sentence.isQuestion || task.sentence.isQuest)
            {
                if (task.isInput && report)  //only show input tasks as solutions
                //memory.emit(Answer.class, task, belief);
                {
                }
                else
                {
                    //memory.emit(Output.class, task, belief);   //solution to quests and questions can be always showed
                }
            }
            else
            {
                //memory.emit(Output.class, task, belief);   //goal things only show silence related
            }


            /*memory.output(task);
             *
             * //only questions and quests get here because else output is spammed
             * if(task.sentence.isQuestion() || task.sentence.isQuest()) {
             *  memory.emit(Solved.class, task, belief);
             * } else {
             *  memory.emit(Output.class, task, belief);
             * }*/

            ctx.addTask(ctx.currentTask, budget, belief, task.getParentBelief());
            return(true);
        }
コード例 #16
0
ファイル: TemporalRules.cs プロジェクト: chargen/AGI-X0
        // TODO< rename to evaluateQualityOfBeliefAsASolutionToProblemAndReward and refactor into functions >
        // https://github.com/opennars/opennars/blob/master/nars_core/nars/inference/TemporalRules.java#L537
        /* ----- Functions used both in direct and indirect processing of tasks ----- */

        /**
         * Evaluate the quality of a belief as a solution to a problem, then reward
         * the belief and de-prioritize the problem
         *
         * \param problem The problem (question or goal) to be solved
         * \param solution The belief as solution
         * \param task The task to be immediately processed, or null for continued process
         * \return The budget for the new task which is the belief activated, if
         * necessary
         */
        public static ClassicalBudgetValue solutionEval(
            ClassicalTask problem,
            ClassicalSentence solution,
            ClassicalTask task,
            DerivationContext ctx
            )
        {
            ClassicalBudgetValue budget = null;

            bool feedbackToLinks = false;

            if (task == null)
            {
                task            = ctx.currentTask;
                feedbackToLinks = true;
            }
            bool taskSentenceIsjudgment           = task.sentence.isJudgment;
            EnumRateByConfidence rateByConfidence = problem.sentence.term.hasVarQuery() ? EnumRateByConfidence.YES : EnumRateByConfidence.NO; // here its whether its a what or where question for budget adjustment
            float quality = TemporalRules.solutionQuality(rateByConfidence, problem, solution, ctx.memory, ctx.compoundAndTermContext);

            if (problem.sentence.isGoal)
            {
                ctx.memory.emotion.adjustHappy(quality, task.budget.priority, ctx);
            }

            if (taskSentenceIsjudgment)
            {
                task.budget.incPriority(quality);
            }
            else
            {
                float taskPriority = task.budget.priority; // +goal satisfication is a matter of degree - https://groups.google.com/forum/#!topic/open-nars/ZfCM416Dx1M
                budget = new ClassicalBudgetValue(UtilityFunctions.or(taskPriority, quality), task.budget.durability, BudgetFunctions.truthToQuality(solution.truth));
                task.budget.priority = Math.Min(1 - quality, taskPriority);
            }

            // TODO< implement links >

            /* LINKS commented because links are not implemented
             * if (feedbackToLinks) {
             *  TaskLink tLink = ctx.currentTaskLink;
             *  tLink.setPriority(Math.Min(1 - quality, tLink.getPriority()));
             *  TermLink bLink = ctx.currentBeliefLink;
             *  bLink.incPriority(quality);
             * }*/
            return(budget);
        }
コード例 #17
0
ファイル: BudgetFunctions.cs プロジェクト: chargen/AGI-X0
        /**
         * Evaluate the quality of a revision, then de-prioritize the premises
         *
         * \param tTruth The truth value of the judgment in the task
         * \param bTruth The truth value of the belief
         * \param truth The truth value of the conclusion of revision
         * \return The budget for the new task
         */
        static public ClassicalBudgetValue revise(TruthValue tTruth, TruthValue bTruth, TruthValue truth, bool feedbackToLinks, nars.control.DerivationContext nal)
        {
            float         difT = truth.getExpDifAbs(tTruth);
            ClassicalTask task = nal.currentTask;

            task.budget.decPriority(1 - difT);
            task.budget.decDurability(1 - difT);

            /* commented because links are not jet implemented
             * if (feedbackToLinks) {
             *  TaskLink tLink = nal.currentTaskLink;
             *  tLink.decPriority(1 - difT);
             *  tLink.decDurability(1 - difT);
             *  TermLink bLink = nal.currentBeliefLink;
             *  float difB = truth.getExpDifAbs(bTruth);
             *  bLink.decPriority(1 - difB);
             *  bLink.decDurability(1 - difB);
             * } */
            float dif        = truth.confidence - Math.Max(tTruth.confidence, bTruth.confidence);
            float priority   = UtilityFunctions.or(dif, task.budget.priority);
            float durability = UtilityFunctions.aveAri(dif, task.budget.durability);
            float quality    = truthToQuality(truth);

            /*
             * if (priority < 0) {
             *  memory.nar.output(ERR.class,
             *          new RuntimeException("BudgetValue.revise resulted in negative priority; set to 0"));
             *  priority = 0;
             * }
             * if (durability < 0) {
             *  memory.nar.output(ERR.class,
             *          new RuntimeException("BudgetValue.revise resulted in negative durability; set to 0; aveAri(dif=" + dif + ", task.getDurability=" + task.getDurability() +") = " + durability));
             *  durability = 0;
             * }
             * if (quality < 0) {
             *  memory.nar.output(ERR.class,
             *          new RuntimeException("BudgetValue.revise resulted in negative quality; set to 0"));
             *  quality = 0;
             * }
             */

            return(new ClassicalBudgetValue(priority, durability, quality));
        }
コード例 #18
0
ファイル: DerivationContext.cs プロジェクト: chargen/AGI-X0
        /* --------------- new task building --------------- */

        /**
         * Shared final operations by all double-premise rules, called from the
         * rules except StructuralRules
         *
         * \param newContent The content of the sentence in task
         * \param newTruth The truth value of the sentence in task
         * \param newBudget The budget value in task
         */
        public bool doublePremiseTaskRevised(TermOrCompoundTermOrVariableReferer newContent, TruthValue newTruth, ClassicalBudgetValue newBudget)
        {
            ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters makeSentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters();
            makeSentenceParameters.term       = newContent;
            makeSentenceParameters.punctation = currentTask.sentence.punctation;
            makeSentenceParameters.truth      = newTruth;
            makeSentenceParameters.stamp      = returnTheNewStamp();
            ClassicalSentence newSentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(makeSentenceParameters);

            ClassicalTask.MakeParameters makeTaskParameters = new ClassicalTask.MakeParameters();
            makeTaskParameters.sentence     = newSentence;
            makeTaskParameters.budget       = newBudget;
            makeTaskParameters.parentTask   = currentTask;
            makeTaskParameters.parentBelief = currentBelief;
            ClassicalTask newTask = ClassicalTask.make(makeTaskParameters);

            return(derivedTask(newTask, true, false, null, null, true)); // allows overlap since overlap was already checked on revisable( function
                                                                         // which is not the case for other single premise tasks
        }
コード例 #19
0
        // https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/entity/Concept.java#L648

        /**
         * To answer a question by existing beliefs
         *
         * \param task The task to be processed
         * \return Whether to continue the processing of the task
         */
        private void processQuestion(DerivationContext ctx, ClassicalConcept @this, ClassicalTask task)
        {
            ClassicalTask quesTask    = task;
            bool          newQuestion = true;

            foreach (ClassicalTask t in @this.questions)
            {
                if (t.sentence.equalsContent(quesTask.sentence))
                {
                    quesTask    = t;
                    newQuestion = false;
                    break;
                }
            }

            if (newQuestion)
            {
                if (@this.questions.Count + 1 > Parameters.CONCEPT_QUESTIONS_MAX)
                {
                    ClassicalTask removed = @this.questions[0];
                    @this.questions.RemoveAt(0);    // FIFO
                    //memory.event.emit(ConceptQuestionRemove.class, this, removed);
                }

                @this.questions.Add(task);
                // memory.event.emit(ConceptQuestionAdd.class, this, task);
            }

            ClassicalSentence ques       = quesTask.sentence;
            ClassicalTask     newAnswerT = (ques.isQuestion)
                ? selectCandidate(quesTask, @this.beliefs, EnumForRevision.NOREVISION)
                : selectCandidate(quesTask, @this.desires, EnumForRevision.NOREVISION);

            if (newAnswerT != null)
            {
                LocalRules.trySolution(newAnswerT.sentence, task, ctx, true, memory);
            }
            // commented because memory events are not implemented
            //else if(task.isInput() && !quesTask.getTerm().hasVarQuery() && quesTask.getBestSolution() != null) { //show previously found solution anyway in case of input
            //memory.emit(Events.Answer.class, quesTask, quesTask.getBestSolution());
            //}
        }
コード例 #20
0
ファイル: Memory.cs プロジェクト: chargen/AGI-X0
        public void cycle()
        {
            void insertNewTasks()
            {
                // we do nothing here because we call addTask from outside already
            }

            insertNewTasks();

            processNewTasks();

            ClassicalTask currentTask = selectAttentional(); // get the task which has the highest attention

            if (currentTask != null)
            {
                localInference(currentTask);
            }

            GeneralInferenceControl.selectConceptForInference(this, compoundAndTermContext);
        }
コード例 #21
0
ファイル: Memory.cs プロジェクト: chargen/AGI-X0
        // see https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/storage/Memory.java#L417
        void processNewTasks()
        {
            while (newTasks.Count != 0)
            {
                ClassicalTask task = newTasks.Dequeue();

                if ( // new input or existing concept
                    task.isInput ||
                    task.sentence.isQuest ||
                    task.sentence.isQuestion
                    /*|| concept(task.sentence.term) != null*/
                    )
                {
                    localInference(task);
                }
                else
                {
                    ClassicalSentence sentence = task.sentence;
                    if (sentence.isJudgment || sentence.isGoal)
                    {
                        double expectation = sentence.truth.expectation;

                        // new concept formation
                        if (
                            (sentence.isJudgment && expectation > Parameters.DEFAULT_CREATION_EXPECTATION) ||
                            (sentence.isGoal && expectation > Parameters.DEFAULT_CREATION_EXPECTATION_GOAL)
                            )
                        {
                            attention.addNovelTask(task);
                        }
                        else
                        {
                            removeTask(task, "Neglected");
                        }
                    }
                }
            }
        }
コード例 #22
0
        // https://github.com/opennars/opennars/blob/62c814fb0f3e474a176515103394049b2887ec29/nars_core/nars/entity/Concept.java#L440

        /**
         * To accept a new goal, and check for revisions and realization, then
         * decide whether to actively pursue it
         *
         * \param judg The judgment to be accepted
         * \param task The task to be processed
         * \return Whether to continue the processing of the task
         */
        private bool processGoal(DerivationContext ctx, ClassicalConcept @this, ClassicalTask task)
        {
            ClassicalSentence goal     = task.sentence;
            ClassicalTask     oldGoalT = selectCandidate(task, @this.desires, EnumForRevision.REVISION); // revise with the existing desire values
            ClassicalSentence oldGoal  = null;

            if (oldGoalT != null)
            {
                oldGoal = oldGoalT.sentence;
                Stamp newStamp = goal.stamp;
                Stamp oldStamp = oldGoal.stamp;

                bool isStampEqual = Stamp.checkEquals(
                    newStamp,
                    oldStamp,
                    Stamp.EnumCompareCreationTime.NO,
                    Stamp.EnumCompareOccurrenceTime.NO,
                    Stamp.EnumCompareEvidentialBaseTime.YES);

                if (isStampEqual)
                {
                    return(false); // duplicate
                }
                if (LocalRules.revisible(goal, oldGoal))
                {
                    ctx.setTheNewStamp(newStamp, oldStamp, memory.time);

                    ClassicalSentence projectedGoal = oldGoal.projection(task.sentence.stamp.occurrenceTime, newStamp.occurrenceTime);
                    if (projectedGoal != null)
                    {
                        // if (goal.after(oldGoal, nal.memory.param.duration.get())) { //no need to project the old goal, it will be projected if selected anyway now
                        // nal.singlePremiseTask(projectedGoal, task.budget);
                        //return;
                        // }
                        ctx.currentBelief = projectedGoal;
                        if (true /* TODO< check if not operation > !(task.sentence.term instanceof Operation)*/)
                        {
                            bool successOfRevision = LocalRules.revision(ctx, task.sentence, projectedGoal, false);
                            if (successOfRevision) // it is revised, so there is a new task for which this function will be called
                            {
                                return(false);     // with higher/lower desire
                            } // it is not allowed to go on directly due to decision making https://groups.google.com/forum/#!topic/open-nars/lQD0no2ovx4
                        }
                    }
                }
            }

            Stamp s2 = goal.stamp.clone();

            s2.occurrenceTime = memory.time;
            if (s2.after(task.sentence.stamp, ctx.memory.param.duration.value))   // this task is not up to date we have to project it first
            {
                ClassicalSentence projGoal = task.sentence.projection(memory.time, ctx.memory.param.duration.value);
                if (projGoal != null && projGoal.truth.expectation > ctx.memory.param.decisionThreshold)
                {
                    ctx.singlePremiseTask(projGoal, task.budget.clone()); // keep goal updated
                    // return false; //outcommented, allowing "roundtrips now", relevant for executing multiple steps of learned implication chains
                }
            }

            if (task.isAboveThreshold)
            {
                ClassicalTask beliefT = selectCandidate(task, @this.beliefs, EnumForRevision.NOREVISION); // check if the Goal is already satisfied

                double antiSatisfaction = 0.5;                                                            // we dont know anything about that goal yet, so we pursue it to remember it because its maximally unsatisfied
                if (beliefT != null)
                {
                    ClassicalSentence belief          = beliefT.sentence;
                    ClassicalSentence projectedBelief = belief.projection(task.sentence.stamp.occurrenceTime, ctx.memory.param.duration.value);
                    LocalRules.trySolution(projectedBelief, task, ctx, true, memory); // check if the Goal is already satisfied (manipulate budget)
                    antiSatisfaction = task.sentence.truth.getExpDifAbs(belief.truth);
                }

                double     satisfaction = 1.0 - antiSatisfaction;
                TruthValue t            = goal.truth.clone();

                t.frequency = (float)(t.frequency - satisfaction); // decrease frequency according to satisfaction value

                bool fullfilled = antiSatisfaction < Parameters.SATISFACTION_TRESHOLD;

                ClassicalSentence projectedGoal = goal.projection(ctx.memory.time, ctx.memory.time); // NOTE< this projection is fine >

                /* commented because we stil have to implement operations
                 * if (projectedGoal != null && task.isAboveThreshold && !fullfilled && projectedGoal.truth.expectation > nal.memory.param.decisionThreshold.get()) {
                 *
                 *  try {
                 *      Operation bestop = null;
                 *      float bestop_truthexp = 0.0f;
                 *      TruthValue bestop_truth = null;
                 *      Task executable_precond = null;
                 *      //long distance = -1;
                 *      long mintime = -1;
                 *      long maxtime = -1;
                 *      for (Task t: this.executable_preconditions) {
                 *          Term[] prec = ((Conjunction)((Implication)t.getTerm()).getSubject()).term;
                 *          Term[] newprec = new Term[prec.length - 3];
                 *          for (int i = 0; i < prec.length - 3; i++) { //skip the last part: interval, operator, interval
                 *              newprec[i] = prec[i];
                 *          }
                 *
                 *          //distance = Interval.magnitudeToTime(((Interval)prec[prec.length-1]).magnitude, nal.memory.param.duration);
                 *          mintime = nal.memory.time() + Interval.magnitudeToTime(((Interval)prec[prec.length - 1]).magnitude - 1, nal.memory.param.duration);
                 *          maxtime = nal.memory.time() + Interval.magnitudeToTime(((Interval)prec[prec.length - 1]).magnitude + 2, nal.memory.param.duration);
                 *
                 *          Operation op = (Operation)prec[prec.length - 2];
                 *          Term precondition = Conjunction.make(newprec, TemporalRules.ORDER_FORWARD);
                 *
                 *          Concept preconc = nal.memory.concept(precondition);
                 *          long newesttime = -1;
                 *          Task bestsofar = null;
                 *          if (preconc != null) { //ok we can look now how much it is fullfilled
                 *
                 *              //check recent events in event bag
                 *              for (Task p : this.memory.sequenceTasks) {
                 *                  if (p.sentence.term.equals(preconc.term) && p.sentence.isJudgment() && !p.sentence.isEternal() && p.sentence.getOccurenceTime() > newesttime && p.sentence.getOccurenceTime() <= memory.time()) {
                 *                      newesttime = p.sentence.getOccurenceTime();
                 *                      bestsofar = p; //we use the newest for now
                 *                  }
                 *              }
                 *              if (bestsofar == null) {
                 *                  continue;
                 *              }
                 *              //ok now we can take the desire value:
                 *              TruthValue A = projectedGoal.getTruth();
                 *              //and the truth of the hypothesis:
                 *              TruthValue Hyp = t.sentence.truth;
                 *              //and the truth of the precondition:
                 *              Sentence projectedPrecon = bestsofar.sentence.projection(memory.time() comment*- distance comment*, memory.time());
                 *
                 *              if (projectedPrecon.isEternal()) {
                 *                  continue; //projection wasn't better than eternalization, too long in the past
                 *              }
                 *              //debug start
                 *              //long timeA = memory.time();
                 *              //long timeOLD = bestsofar.sentence.stamp.getOccurrenceTime();
                 *              //long timeNEW = projectedPrecon.stamp.getOccurrenceTime();
                 *              //debug end
                 *              TruthValue precon = projectedPrecon.truth;
                 *              //and derive the conjunction of the left side:
                 *              TruthValue leftside = TruthFunctions.desireDed(A, Hyp);
                 *              //in order to derive the operator desire value:
                 *              TruthValue opdesire = TruthFunctions.desireDed(precon, leftside);
                 *
                 *              float expecdesire = opdesire.getExpectation();
                 *              if (expecdesire > bestop_truthexp) {
                 *                  bestop = op;
                 *                  bestop_truthexp = expecdesire;
                 *                  bestop_truth = opdesire;
                 *                  executable_precond = t;
                 *              }
                 *          }
                 *      }
                 *
                 *      if (bestop != null && bestop_truthexp > memory.param.decisionThreshold.get()) {
                 *          Task t = new Task(new Sentence(bestop, Symbols.JUDGMENT_MARK, bestop_truth, projectedGoal.stamp), new BudgetValue(1.0f, 1.0f, 1.0f));
                 *          //System.out.println("used " +t.getTerm().toString() + String.valueOf(memory.randomNumber.nextInt()));
                 *          if (!task.sentence.stamp.evidenceIsCyclic()) {
                 *              if (!executeDecision(t)) { //this task is just used as dummy
                 *                  memory.emit(UnexecutableGoal.class, task, this, nal);
                 *              } else {
                 *                  memory.decisionBlock = memory.time() + Parameters.AUTOMATIC_DECISION_USUAL_DECISION_BLOCK_CYCLES;
                 *                  SyllogisticRules.generatePotentialNegConfirmation(nal, executable_precond.sentence, executable_precond.budget, mintime, maxtime, 2);
                 *              }
                 *          }
                 *      }
                 *  }
                 *  catch(Exception ex) {
                 *      System.out.println("Failure in operation choice rule, analyze!");
                 *  }
                 *
                 *
                 *
                 *  questionFromGoal(task, ctx);
                 *
                 *
                 *  addToTable(task, false, desires, Parameters.CONCEPT_GOALS_MAX, ConceptGoalAdd.class, ConceptGoalRemove.class);
                 *
                 *  InternalExperience.InternalExperienceFromTask(memory, task,false);
                 *
                 *  if(nal.memory.time >= memory.decisionBlock && !executeDecision(task)) {
                 *      // commented because we haven't implemented the observer until now    memory.emit(UnexecutableGoal.class, task, this, nal);
                 *      return true; // it was made true by itself
                 *  }
                 *  return false;
                 * } // big if
                 */

                return(fullfilled);
            }
            return(false);
        }
コード例 #23
0
        // function prototype and some of the methode is like https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/inference/RuleTables.java#L73
        internal static void reason(
            ClassicalTaskLink taskLink,
            ClassicalTermLink beliefLink,
            DerivationContext ctx
            )
        {
            { // debugging
                int taskId   = taskLink.targetTask.name.term.getAtomicOrTerm;
                int beliefId = beliefLink.target.getAtomicOrTerm;

                if (taskId == 300002 && beliefId == 300004)
                {
                    int breakpointHere2 = 1;
                }
                else if (taskId == 300004 && beliefId == 300002)
                {
                    int breakpointHere2 = 1;
                }

                int breakpointHere1 = 1;
            }

            Memory memory = ctx.memory;

            memory.emotion.manageBusy(ctx);

            ClassicalTask     task         = ctx.currentTask;
            ClassicalSentence taskSentence = task.sentence;

            TermOrCompoundTermOrVariableReferer taskTerm   = taskSentence.term;
            TermOrCompoundTermOrVariableReferer beliefTerm = beliefLink.target;

            // commented because not jet translated
            //if (equalSubTermsInRespectToImageAndProduct(taskTerm, beliefTerm))
            //    return;

            ClassicalConcept beliefConcept = memory.translateTermToConcept(beliefTerm);

            ClassicalSentence belief = (beliefConcept != null) ? beliefConcept.getBelief(ctx, task) : null;

            ctx.currentBelief = belief;

            if (belief != null)
            {
                beliefTerm = belief.term; //because interval handling that differs on conceptual level


                // too restrictive, its checked for non-deductive inference rules in derivedTask (also for single prem)
                if (Stamp.checkBaseOverlap(task.sentence.stamp, belief.stamp))
                {
                    ctx.evidentalOverlap = true;
                    if (!task.sentence.stamp.isEternal || !belief.stamp.isEternal)
                    {
                        return; // only allow for eternal reasoning for now to prevent derived event floods
                    }
                    //return; // preparisons are made now to support this nicely
                }
                // comment out for recursive examples, this is for the future, it generates a lot of potentially useless tasks

                //ctx.emit(Events.BeliefReason.class, belief, beliefTerm, taskTerm, nal);

                if (LocalRules.match(task, belief, ctx))    // new tasks resulted from the match, so return
                {
                    return;
                }
            }

            // current belief and task may have changed, so set again:
            ctx.currentBelief = belief;
            ctx.currentTask   = task;

            // HACK< derivation must be made by combining compounds >
            if (!TermUtilities.isTermCompoundTerm(taskTerm) || !TermUtilities.isTermCompoundTerm(beliefTerm))
            {
                return;
            }

            // derive and create new tasks for the results
            {
                IList <TemporaryDerivedCompoundWithDecorationAndTruth> derivedCompoundTermsWithDecorationAndTruth = new List <TemporaryDerivedCompoundWithDecorationAndTruth>();
                bool insert = true;

                DeriverCaller.deriverCaller(
                    ctx.compoundAndTermContext,
                    ctx.compoundAndTermContext.translateToCompoundChecked(taskTerm),
                    ctx.compoundAndTermContext.translateToCompoundChecked(beliefTerm),
                    out derivedCompoundTermsWithDecorationAndTruth, insert);

                // translate derivedCompoundTermsWithDecorationAndTruth to tasks and add them
                // for this we have to call DerivationContext.doublePremiseTask() to generate the tasks
                foreach (var iDerivedWithDecorationAndTruth in derivedCompoundTermsWithDecorationAndTruth)
                {
                    TermOrCompoundTermOrVariableReferer content = iDerivedWithDecorationAndTruth.derivedCompoundWithDecoration.termReferer;

                    bool temporalInduction = false; // TODO< decide by rule? from the deriver? >
                    bool overlapAllowed    = false; // TODO< decide by rule? from the deriver? >

                    TruthValue truth = null;
                    truth = RuleTable.calcTruthDoublePremise(task.sentence.truth, belief.truth, iDerivedWithDecorationAndTruth.truthfunction);

                    ClassicalBudgetValue budget = new ClassicalBudgetValue(0.5f, 0.5f, 0.5f); // TODO< calculate budget by table >

                    ctx.doublePremiseTask(content,
                                          truth,
                                          budget,
                                          temporalInduction,
                                          overlapAllowed
                                          );
                }
            }
        }
コード例 #24
0
ファイル: DerivationContext.cs プロジェクト: chargen/AGI-X0
        /**
         * Derived task comes from the inference rules.
         *
         * \param task the derived task
         * \param overlapAllowed //https://groups.google.com/forum/#!topic/open-nars/FVbbKq5En-M
         */
        public bool derivedTask(
            ClassicalTask task,
            bool revised,
            bool single,
            ClassicalTask parent,
            ClassicalSentence occurence2,
            bool overlapAllowed
            )
        {
            if (derivationFilters != null)
            {
                foreach (DerivationFilter iDerivationFilter in derivationFilters)
                {
                    string rejectionReason = iDerivationFilter.reject(this, task, revised, single, parent, occurence2);
                    if (rejectionReason != null)
                    {
                        memory.removeTask(task, rejectionReason);
                        return(false);
                    }
                }
            }

            ClassicalSentence occurence = parent != null ? parent.sentence : null;


            if (!task.budget.isAboveThreshold)
            {
                memory.removeTask(task, "Insufficient Budget");
                return(false);
            }

            if (task.sentence != null && task.sentence.truth != null)
            {
                float conf = task.sentence.truth.confidence;
                if (conf == 0)
                {
                    //no confidence - we can delete the wrongs out that way.
                    memory.removeTask(task, "Ignored (zero confidence)");
                    return(false);
                }
            }


            /* uncommented because operations are not jet implemented
             * TODO< translate to C# if operations are implemented
             */
            /*
             * if (task.sentence.term instanceof Operation) {
             *  Operation op = (Operation)task.sentence.term;
             *  if (op.getSubject() instanceof Variable || op.getPredicate() instanceof Variable) {
             *      memory.removeTask(task, "Operation with variable as subject or predicate");
             *      return false;
             *  }
             * }
             */



            Stamp stamp = task.sentence.stamp;

            if (occurence != null && !occurence.stamp.isEternal)
            {
                stamp.occurrenceTime = occurence.stamp.occurrenceTime;
            }
            if (occurence2 != null && !occurence2.stamp.isEternal)
            {
                stamp.occurrenceTime = occurence2.stamp.occurrenceTime;
            }

            // it is revision, of course its cyclic, apply evidental base policy
            // TODO< reconsider >
            if (
                !overlapAllowed &&
                this.evidentalOverlap &&
                Stamp.checkOverlap(stamp)
                )
            {
                memory.removeTask(task, "Overlapping Evidenctal Base");
                //"(i=" + i + ",j=" + j +')'
                return(false);
            }

            task.setElementOfSequenceBuffer(false);
            if (!revised)
            {
                task.budget.durability = (task.budget.durability * Parameters.DERIVATION_DURABILITY_LEAK);
                task.budget.priority   = (task.budget.priority * Parameters.DERIVATION_PRIORITY_LEAK);
            }
            //memory.event.emit(Events.TaskDerive.class, task, revised, single, occurence, occurence2);
            //memory.logic.TASK_DERIVED.commit(task.budget.getPriority());

            addTask(task, "Derived");
            return(true);
        }
コード例 #25
0
ファイル: Memory.cs プロジェクト: chargen/AGI-X0
        /**
         * Uses the attention menchamism to select the next task to get processed
         *
         *
         */
        private ClassicalTask selectAttentional()
        {
            ClassicalTask taskWithAttention = attention.getNextAttentionElement();

            return(taskWithAttention);
        }
コード例 #26
0
ファイル: Memory.cs プロジェクト: chargen/AGI-X0
 public void removeTask(ClassicalTask task, string reason)
 {
     //emit(TaskRemove.class, task, reason);
     task.wasDiscarded();
 }
コード例 #27
0
ファイル: DerivationContext.cs プロジェクト: chargen/AGI-X0
        // see https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/control/DerivationContext.java#L217

        /**
         * Shared final operations by all double-premise rules, called from the
         * rules except StructuralRules
         *
         * /param newContent The content of the sentence in task
         * /param newTruth The truth value of the sentence in task
         * /param newBudget The budget value in task
         * /param temporalInduction
         * /param overlapAllowed // https://groups.google.com/forum/#!topic/open-nars/FVbbKq5En-M
         */
        public IList <ClassicalTask> doublePremiseTask(
            TermOrCompoundTermOrVariableReferer newContent,
            TruthValue newTruth,
            ClassicalBudgetValue newBudget,
            bool temporalInduction,
            bool overlapAllowed
            )
        {
            IList <ClassicalTask> ret = new List <ClassicalTask>();

            if (newContent == null)
            {
                return(null);
            }

            if (!newBudget.isAboveThreshold)
            {
                return(null);
            }

            if (
                newContent == null  /* commented because not implemented   ||
                                     * ((newContent instanceof Interval)) ||
                                     * ((newContent instanceof Variable))*/
                )
            {
                return(null);
            }

            /* commented because not implemented
             * if (newContent.subjectOrPredicateIsIndependentVar()) {
             *  return null;
             * }*/

            ClassicalSentence newSentence;
            ClassicalTask     newTask;

            ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters makeSentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters();
            makeSentenceParameters.term       = newContent;
            makeSentenceParameters.punctation = currentTask.sentence.punctation;
            makeSentenceParameters.truth      = newTruth;
            makeSentenceParameters.stamp      = returnTheNewStamp();

            newSentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(makeSentenceParameters);
            newSentence.producedByTemporalInduction = temporalInduction;

            ClassicalTask.MakeParameters taskMakeParameters = new ClassicalTask.MakeParameters();
            taskMakeParameters.sentence     = newSentence;
            taskMakeParameters.budget       = newBudget;
            taskMakeParameters.parentTask   = currentTask;
            taskMakeParameters.parentBelief = currentBelief;

            newTask = ClassicalTask.make(taskMakeParameters);

            if (newTask != null)
            {
                bool added = derivedTask(newTask, false, false, null, null, overlapAllowed);
                if (added)
                {
                    ret.Add(newTask);
                }
            }

            // "Since in principle it is always valid to eternalize a tensed belief"
            if (temporalInduction && Parameters.IMMEDIATE_ETERNALIZATION)    // temporal induction generated ones get eternalized directly
            {
                TruthValue truthEternalized = TruthFunctions.eternalize(newTruth);
                Stamp      st = returnTheNewStamp().clone();
                st.isEternal = true;

                makeSentenceParameters            = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters();
                makeSentenceParameters.term       = newContent;
                makeSentenceParameters.punctation = currentTask.sentence.punctation;
                makeSentenceParameters.truth      = truthEternalized;
                makeSentenceParameters.stamp      = st;

                newSentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(makeSentenceParameters);
                newSentence.producedByTemporalInduction = temporalInduction;

                taskMakeParameters              = new ClassicalTask.MakeParameters();
                taskMakeParameters.sentence     = newSentence;
                taskMakeParameters.budget       = newBudget;
                taskMakeParameters.parentTask   = currentTask;
                taskMakeParameters.parentBelief = currentBelief;

                newTask = ClassicalTask.make(taskMakeParameters);
                if (newTask != null)
                {
                    bool added = derivedTask(newTask, false, false, null, null, overlapAllowed);
                    if (added)
                    {
                        ret.Add(newTask);
                    }
                }
            }

            return(ret);
        }
コード例 #28
0
        /**
         * Link to a new task from all relevant concepts for continued processing in
         * the near future for unspecified time.
         * <p>
         * The only method that calls the TaskLink constructor.
         *
         * /param task The task to be linked
         * /param content The content of the task
         */
        private static void linkToTask(DerivationContext ctx, ClassicalConcept @this, ClassicalTask task)
        {
            ClassicalBudgetValue taskBudget = task.budget;

            @this.insertTaskLink(
                new ClassicalTaskLink(
                    task,
                    null,
                    taskBudget,
                    Parameters.TERM_LINK_RECORD_LENGTH),
                ctx);  // link type: SELF

            if (!TermUtilities.isTermCompoundTerm(@this.term))
            {
                return;
            }

            if (@this.termLinkTemplates.isEmpty())
            {
                return;
            }

            ClassicalBudgetValue subBudget = BudgetFunctions.distributeAmongLinks(taskBudget, @this.termLinkTemplates.Count);

            if (!subBudget.isAboveThreshold)
            {
                return;
            }
            // else here

            for (int t = 0; t < @this.termLinkTemplates.Count; t++)
            {
                ClassicalTermLink termLink = @this.termLinkTemplates[t];

                if (termLink.type == ClassicalTermLink.EnumType.TEMPORAL)
                {
                    continue;
                }

                TermOrCompoundTermOrVariableReferer componentTerm = termLink.target;

                ClassicalConcept componentConcept = @this.memory.conceptualize(subBudget, componentTerm);

                if (componentConcept != null)
                {
                    componentConcept.insertTaskLink(
                        new ClassicalTaskLink(
                            task,
                            termLink,
                            subBudget,
                            Parameters.TERM_LINK_RECORD_LENGTH),
                        ctx);
                }
            }

            @this.buildTermLinks(taskBudget);  // recursively insert TermLink
        }
コード例 #29
0
ファイル: Nar.cs プロジェクト: chargen/AGI-X0
 public void inputTask(ClassicalTask task)
 {
     memory.perceptNewTaskWithBudgetCheck(task);
 }