use of nars.entity.BudgetValue in project opennars by opennars.
the class Anticipate method deriveDidntHappen.
protected void deriveDidntHappen(Term aTerm, long expectedOccurenceTime) {
TruthValue truth = expiredTruth;
BudgetValue budget = expiredBudget;
Stamp stamp = new Stamp(nal.memory);
// stamp.setOccurrenceTime(nal.memory.time());
// it did not happen, so the time of when it did not
stamp.setOccurrenceTime(expectedOccurenceTime);
// happen is exactly the time it was expected
Sentence S = new Sentence(aTerm, Symbols.JUDGMENT_MARK, truth, stamp);
Task task = new Task(S, budget, true);
nal.derivedTask(task, false, true, false);
task.setElemOfSequenceBuffer(true);
nal.memory.emit(DISAPPOINT.class, task);
}
use of nars.entity.BudgetValue in project opennars by opennars.
the class NAR method askNow.
public NAR askNow(String termString, AnswerHandler answered) throws InvalidInputException {
Task t;
addInput(t = new Task(new Sentence(new Narsese(this).parseTerm(termString), Symbols.QUESTION_MARK, null, new Stamp(memory, Tense.Present)), new BudgetValue(Parameters.DEFAULT_QUESTION_PRIORITY, Parameters.DEFAULT_QUESTION_DURABILITY, 1), true));
if (answered != null) {
answered.start(t, this);
}
return this;
}
use of nars.entity.BudgetValue in project opennars by opennars.
the class TemporalInferenceControl method addToSequenceTasks.
public static void addToSequenceTasks(DerivationContext nal, final Task newEvent) {
// multiple versions are necessary, but we do not allow duplicates
List<Task> removals = new LinkedList<Task>();
for (Task s : nal.memory.seq_current) {
if (CompoundTerm.replaceIntervals(s.getTerm()).equals(CompoundTerm.replaceIntervals(newEvent.getTerm()))) {
// check term indices
if (s.getTerm().term_indices != null && newEvent.getTerm().term_indices != null) {
boolean differentTermIndices = false;
for (int i = 0; i < s.getTerm().term_indices.length; i++) {
if (s.getTerm().term_indices[i] != newEvent.getTerm().term_indices[i]) {
differentTermIndices = true;
}
}
if (differentTermIndices) {
continue;
}
}
removals.add(s);
break;
}
}
for (Task removal : removals) {
nal.memory.seq_current.take(removal);
}
// making sure we do not mess with budget of the task:
if (!(newEvent.sentence.getTerm() instanceof Operation)) {
Concept c = nal.memory.concept(newEvent.getTerm());
float event_quality = BudgetFunctions.truthToQuality(newEvent.sentence.truth);
float event_priority = event_quality;
if (c != null) {
event_priority = Math.max(event_quality, c.getPriority());
}
Task t2 = new Task(newEvent.sentence, new BudgetValue(event_priority, 1.0f / (float) newEvent.sentence.term.getComplexity(), event_quality), newEvent.getParentBelief(), newEvent.getBestSolution());
nal.memory.seq_current.putIn(t2);
}
}
use of nars.entity.BudgetValue in project opennars by opennars.
the class BudgetFunctions method revise.
/**
* 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 BudgetValue revise(final TruthValue tTruth, final TruthValue bTruth, final TruthValue truth, final boolean feedbackToLinks, final nars.control.DerivationContext nal) {
final float difT = truth.getExpDifAbs(tTruth);
final Task task = nal.getCurrentTask();
task.decPriority(1 - difT);
task.decDurability(1 - difT);
if (feedbackToLinks) {
TaskLink tLink = nal.getCurrentTaskLink();
tLink.decPriority(1 - difT);
tLink.decDurability(1 - difT);
TermLink bLink = nal.getCurrentBeliefLink();
final float difB = truth.getExpDifAbs(bTruth);
bLink.decPriority(1 - difB);
bLink.decDurability(1 - difB);
}
float dif = truth.getConfidence() - max(tTruth.getConfidence(), bTruth.getConfidence());
float priority = or(dif, task.getPriority());
float durability = aveAri(dif, task.getDurability());
float quality = truthToQuality(truth);
return new BudgetValue(priority, durability, quality);
}
use of nars.entity.BudgetValue in project opennars by opennars.
the class Evaluate method execute.
/**
* To create a quest with a given statement
* @param args Arguments, a Statement followed by an optional tense
* @param memory The memory in which the operation is executed
* @return Immediate results as Tasks
*/
@Override
protected ArrayList<Task> execute(Operation operation, Term[] args, Memory memory) {
Term content = args[1];
Sentence sentence = new Sentence(content, Symbols.QUEST_MARK, null, new Stamp(memory));
BudgetValue budget = new BudgetValue(Parameters.DEFAULT_QUEST_PRIORITY, Parameters.DEFAULT_QUESTION_DURABILITY, 1);
return Lists.newArrayList(new Task(sentence, budget, true));
}
Aggregations