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);
}
}
}
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;
}
Aggregations