Search in sources :

Example 61 with BudgetValue

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);
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) TruthValue(nars.entity.TruthValue) Sentence(nars.entity.Sentence)

Example 62 with BudgetValue

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;
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) Narsese(nars.io.Narsese) Sentence(nars.entity.Sentence)

Example 63 with BudgetValue

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);
    }
}
Also used : Concept(nars.entity.Concept) BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Operation(nars.operator.Operation) LinkedList(java.util.LinkedList)

Example 64 with BudgetValue

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);
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) TermLink(nars.entity.TermLink) TaskLink(nars.entity.TaskLink)

Example 65 with BudgetValue

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));
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) Term(nars.language.Term) Sentence(nars.entity.Sentence)

Aggregations

BudgetValue (nars.entity.BudgetValue)66 TruthValue (nars.entity.TruthValue)52 Term (nars.language.Term)48 Sentence (nars.entity.Sentence)39 Task (nars.entity.Task)36 CompoundTerm (nars.language.CompoundTerm)34 Stamp (nars.entity.Stamp)22 Statement (nars.language.Statement)21 Conjunction (nars.language.Conjunction)18 Inheritance (nars.language.Inheritance)11 Interval (nars.language.Interval)9 Implication (nars.language.Implication)8 Concept (nars.entity.Concept)7 Product (nars.language.Product)7 Variable (nars.language.Variable)6 Operation (nars.operator.Operation)5 Memory (nars.storage.Memory)5 HashMap (java.util.HashMap)4 TruthFunctions.reduceConjunction (nars.inference.TruthFunctions.reduceConjunction)4 Equivalence (nars.language.Equivalence)4