Search in sources :

Example 16 with NALTask

use of nars.task.NALTask in project narchy by automenta.

the class RelationClustering method link.

@Override
protected void link(Task tx, Task ty) {
    // TODO abstract
    assert (tx.isBelief() && ty.isBelief());
    // TODO Allen interval
    String relation;
    if (tx.intersects(ty.start(), ty.end())) {
        relation = "simul";
    } else if (ty.isAfter(tx.end(), dur / 2)) {
        relation = "seq";
    } else if (tx.isAfter(ty.end(), dur / 2)) {
        Task z = tx;
        tx = ty;
        ty = z;
        relation = "seq";
    } else {
        relation = null;
    }
    if (relation != null) {
        Term x = tx.term();
        Truth truX = tx.truth();
        if (truX.isNegative()) {
            x = x.neg();
            truX = truX.neg();
        }
        Term y = ty.term();
        Truth truY = ty.truth();
        if (truY.isNegative()) {
            y = y.neg();
            truY = truY.neg();
        }
        if (x.volume() + y.volume() < nar.termVolumeMax.intValue() - 2) {
            Truth tru = TruthFunctions.intersection(truX, truY, nar.confMin.floatValue());
            if (tru == null)
                return;
            // TODO enum
            Term t;
            switch(relation) {
                case "simul":
                    t = $.inh(SETe.the(x, y), $.the("simul"));
                    break;
                case "seq":
                    t = $.func(relation, x, y);
                    break;
                default:
                    throw new UnsupportedOperationException();
            }
            if (t instanceof Bool)
                return;
            t = t.normalize();
            long now = nar.time();
            NALTask tt = new NALTask(t, BELIEF, tru, now, Math.min(tx.start(), ty.start()), Math.max(tx.end(), ty.end()), nar.time.nextStampArray());
            tt.pri(tx.priElseZero() * ty.priElseZero());
            in.input(tt);
        }
    }
}
Also used : ITask(nars.task.ITask) NALTask(nars.task.NALTask) Task(nars.Task) Bool(nars.term.atom.Bool) NALTask(nars.task.NALTask) Term(nars.term.Term) Truth(nars.truth.Truth)

Example 17 with NALTask

use of nars.task.NALTask in project narchy by automenta.

the class Inperience method leak.

@Override
protected float leak(Task x) {
    float xPri = x.priElseZero();
    Term c = reify(x, nar.self());
    if (c == null || !c.op().conceptualizable)
        return 0;
    Term r = c.temporalize(Retemporalize.retemporalizeXTERNALToDTERNAL).normalize();
    if (r == null || !r.op().conceptualizable)
        return 0;
    long now = nar.time();
    long start = x.start();
    long end;
    if (start == ETERNAL)
        end = start = now;
    else {
        end = x.end();
    }
    // TODO Task.tryContent
    NALTask y = new NALTask(r, BELIEF, $.t(1, nar.confDefault(Op.BELIEF)), now, start, end, x.stamp());
    y.causeMerge(x);
    feedback(y.log("Inperience").pri(xPri * priFactor));
    return 1;
}
Also used : NALTask(nars.task.NALTask) Term(nars.term.Term)

Aggregations

NALTask (nars.task.NALTask)17 Task (nars.Task)8 Term (nars.term.Term)8 Truth (nars.truth.Truth)7 Nullable (org.jetbrains.annotations.Nullable)6 ITask (nars.task.ITask)4 SignalTask (nars.task.signal.SignalTask)3 PreciseTruth (nars.truth.PreciseTruth)3 FasterList (jcog.list.FasterList)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Predicate (java.util.function.Predicate)1 Stream (java.util.stream.Stream)1 Util (jcog.Util)1 LongInterval (jcog.math.LongInterval)1 Priority (jcog.pri.Priority)1 VLink (jcog.pri.VLink)1 Top (jcog.sort.Top)1