Search in sources :

Example 1 with ByteLongPair

use of org.eclipse.collections.api.tuple.primitive.ByteLongPair in project narchy by automenta.

the class Tasklinks method linkTaskTemplates.

public static void linkTaskTemplates(Concept c, Task t, float priApplied, NAR nar) {
    Concept[] cc = c.templates().conceptsShuffled(nar, true);
    int ccs = cc.length;
    if (ccs <= 0)
        return;
    MutableFloat overflow = new MutableFloat();
    float p = priApplied;
    float pEach = p / ccs;
    if (pEach > Pri.EPSILON) {
        Pair<Term, ByteLongPair> tlSeed = TaskLink.GeneralTaskLink.seed(t, false, nar);
        final float headRoom = 1f - pEach;
        for (int i = 0; i < ccs; i++) {
            float o = overflow.get();
            // spread overflow of saturated targets to siblings
            float change;
            if (o >= Pri.EPSILON) {
                overflow.subtract(change = Math.min(o, headRoom));
            } else {
                change = 0;
            }
            TaskLink xx = // new TaskLink.DirectTaskLink(t, pEach + change);
            new TaskLink.GeneralTaskLink(tlSeed, pEach + change);
            linkTask(xx, cc[i].tasklinks(), overflow);
        }
    }
}
Also used : TaskConcept(nars.concept.TaskConcept) Concept(nars.concept.Concept) ByteLongPair(org.eclipse.collections.api.tuple.primitive.ByteLongPair) MutableFloat(org.apache.commons.lang3.mutable.MutableFloat) Term(nars.term.Term)

Aggregations

Concept (nars.concept.Concept)1 TaskConcept (nars.concept.TaskConcept)1 Term (nars.term.Term)1 MutableFloat (org.apache.commons.lang3.mutable.MutableFloat)1 ByteLongPair (org.eclipse.collections.api.tuple.primitive.ByteLongPair)1