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); }
public static TruthValue calcTruthDoublePremise(TruthValue a, TruthValue b, EnumTruthFunction truthFunction) { switch (truthFunction) { case EnumTruthFunction.REVISION: return(TruthFunctions.revision(a, b)); case EnumTruthFunction.COMPARISON: return(TruthFunctions.comparison(a, b)); case EnumTruthFunction.ANALOGY: return(TruthFunctions.analogy(a, b)); case EnumTruthFunction.ANALOGYTICK: return(TruthFunctions.anonymousAnalogy(a, b)); case EnumTruthFunction.DEDUCTION2: return(TruthFunctions.desireDed(a, b)); case EnumTruthFunction.INDUCTION: return(TruthFunctions.induction(a, b)); case EnumTruthFunction.INTERSECTION: return(TruthFunctions.intersection(a, b)); // TODO< search formulas > //case EnumTruthFunction.STRUCTINT: //case EnumTruthFunction.STRUCTABD: //case EnumTruthFunction.REDUCECONJUNCTION, case EnumTruthFunction.EXEMPLIFICATION: return(TruthFunctions.exemplification(a, b)); case EnumTruthFunction.RESEMBLANCE: return(TruthFunctions.resemblance(a, b)); default: throw new Exception("Double premise truth Function called for non-double premise truth"); } }
// 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); }