Search in sources :

Example 11 with Task

use of nars.Task in project narchy by automenta.

the class RTreeBeliefTable method eternalize.

private void eternalize(Task x, Consumer<Tasked> added, NAR nar) {
    if ((x instanceof SignalTask)) {
        // ignore for now
        return;
    }
    float xPri = x.pri();
    if (xPri != xPri)
        // deleted already somehow
        return;
    float xc = x.conf();
    float e = x.eviEternalized((1 / xc) * size());
    float c = w2cSafe(e);
    if (c >= nar.confMin.floatValue()) {
        added.accept(() -> {
            // if (x.op().temporal) { //==IMPL /*x.op().statement */ /*&& !x.term().isTemporal()*/) {
            // //experimental eternalize
            Task eternalized = Task.clone(x, x.term(), Truth.theDithered(x.freq(), e, nar), x.punc(), x.creation(), ETERNAL, ETERNAL);
            if (eternalized != null) {
                eternalized.pri(xPri * c / xc);
                if (Param.DEBUG)
                    eternalized.log("Eternalized Temporal");
                nar.input(eternalized);
                if (!(eternalized.isDeleted()))
                    ((NALTask) x).delete(eternalized);
            }
            return null;
        });
    }
}
Also used : SignalTask(nars.task.signal.SignalTask) NALTask(nars.task.NALTask) Task(nars.Task) SignalTask(nars.task.signal.SignalTask)

Example 12 with Task

use of nars.Task in project narchy by automenta.

the class RTreeBeliefTable method truth.

@Override
public Truth truth(long start, long end, EternalTable eternal, int dur) {
    assert (end >= start);
    final Task ete = eternal != null ? eternal.strongest() : null;
    int s = size();
    x: if (s > 0) {
        if (start == ETERNAL) {
            LongInterval r = ((LongInterval) root().bounds());
            if (r == null)
                break x;
            // return ete != null ? ete.truth() : null;
            start = r.start();
            end = r.end();
        }
        int maxTruths = TRUTHPOLATION_LIMIT;
        int maxTries = (int) Math.max(1, Math.ceil(capacity * SCAN_QUALITY));
        maxTries = Math.min(s * 2, /* in case the same task is encountered twice HACK*/
        maxTries);
        ScanFilter tt = new ScanFilter(maxTruths, maxTruths, task(// taskRelevance(start, end)
        taskStrength(start, end, dur)), maxTries).scan(this, start - dur, end + dur);
        if (!tt.isEmpty()) {
            return new TruthPolation(start, end, dur, tt).truth(ete);
        // PreciseTruth pt = Param.truth(null, start, end, dur, tt);
        // if (pt!=null && (ete == null || (pt.evi() >= ete.evi())))
        // return pt;
        }
    }
    return ete != null ? ete.truth() : null;
}
Also used : SignalTask(nars.task.signal.SignalTask) NALTask(nars.task.NALTask) Task(nars.Task) LongInterval(jcog.math.LongInterval) TruthPolation(nars.task.TruthPolation)

Example 13 with Task

use of nars.Task in project narchy by automenta.

the class TaskMatch method accept.

@Override
public void accept(@NotNull Task _x) {
    Task x = _x;
    test(x);
}
Also used : Task(nars.Task)

Example 14 with Task

use of nars.Task in project narchy by automenta.

the class TruthPolation method add.

public TruthPolation add(Tasked tt) {
    Task t = tt.task();
    add(new TaskComponent(t));
    long dd = t.minDistanceTo(start, end);
    if (dur > 0) {
        if (dd < dur)
            dur = (int) dd;
    // if (computeDensity) {
    // long ts = Util.clamp(t.start(), start, end);
    // long te = Util.clamp(t.end(), start, end);
    // spanStart = Math.min(ts, spanStart);
    // spanEnd = Math.max(te, spanEnd);
    // rangeSum += Math.max(1, te - ts);
    // }
    }
    return this;
}
Also used : Task(nars.Task)

Example 15 with Task

use of nars.Task in project narchy by automenta.

the class ChainClustering method linkClustersChain.

protected void linkClustersChain(Stream<VLink<Task>> sortedByCentroidStream, NAR nar) {
    List<VLink<Task>> sortedbyCentroid = sortedByCentroidStream.collect(Collectors.toList());
    int current = -1;
    int nTasks = sortedbyCentroid.size();
    VLink<Task> x = null;
    for (int i = 0; i < nTasks; i++) {
        VLink<Task> y = sortedbyCentroid.get(i);
        if (y == null)
            continue;
        if (y.centroid != current) {
            current = y.centroid;
        } else {
            // link to previous item
            Task tx = x.get();
            Task ty = y.get();
            link(tx, ty);
        }
        x = y;
    }
}
Also used : VLink(jcog.pri.VLink) Task(nars.Task)

Aggregations

Task (nars.Task)50 Term (nars.term.Term)15 NALTask (nars.task.NALTask)13 Truth (nars.truth.Truth)12 Nullable (org.jetbrains.annotations.Nullable)11 SignalTask (nars.task.signal.SignalTask)9 Test (org.junit.jupiter.api.Test)8 ITask (nars.task.ITask)6 FasterList (jcog.list.FasterList)5 NAR (nars.NAR)5 PreciseTruth (nars.truth.PreciseTruth)4 Util (jcog.Util)3 Top (jcog.sort.Top)3 Op (nars.Op)3 Param (nars.Param)3 TaskRegion (nars.task.util.TaskRegion)3 List (java.util.List)2 Map (java.util.Map)2 Random (java.util.Random)2 VLink (jcog.pri.VLink)2