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