Exemple #1
0
        public TruthValue projectionTruth(long targetTime, long currentTime)
        {
            TruthValue newTruth = null;

            if (!stamp.isEternal)
            {
                newTruth = TruthFunctions.eternalize(truth);
                if (targetTime != Stamp.ETERNAL)
                {
                    long   occurrenceTime      = stamp.occurrenceTime;
                    double factor              = TruthFunctions.temporalProjection(occurrenceTime, targetTime, currentTime);
                    float  projectedConfidence = (float)(factor * truth.confidence);
                    if (projectedConfidence > newTruth.confidence)
                    {
                        newTruth = TruthValue.make(truth.frequency, projectedConfidence);
                    }
                }
            }

            if (newTruth == null)
            {
                newTruth = truth.clone();
            }

            return(newTruth);
        }
Exemple #2
0
        // 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);
        }