use of jcog.bag.Bag in project narchy by automenta.
the class TermlinkTemplates method activate.
public void activate(Concept src, float budgeted, NAR nar) {
int n = this.size();
if (n == 0)
return;
float budgetedToEach = budgeted / n;
// if (budgetedToEach < Pri.EPSILON)
// return;
MutableFloat refund = new MutableFloat(0);
// int nextTarget = nar.random().nextInt(n);
Term srcTerm = src.term();
Bag<Term, PriReference<Term>> srcTermLinks = src.termlinks();
float balance = nar.termlinkBalance.floatValue();
for (int i = 0; i < n; i++) {
Term tgtTerm = get(i);
boolean reverseLinked = false;
boolean conceptualizable = i < concepts;
if (conceptualizable) {
@Nullable Concept tgt = nar.conceptualize(tgtTerm);
float budgetedForward = budgetedToEach * (1f - balance);
float budgetedReverse = budgetedToEach * balance;
if (tgt != null) {
// insert termlink
tgt.termlinks().put(new PLink<>(srcTerm, budgetedForward), refund);
nar.activate(tgt, // budgetedToEach
budgetedForward);
reverseLinked = true;
// use the concept's id
tgtTerm = tgt.term();
}
if (!reverseLinked)
refund.add(budgetedForward);
((Bag) srcTermLinks).put(new PLink(tgtTerm, budgetedReverse), refund);
}
// float r = refund.floatValue();
// float cost = budgeted - r;
// return cost;
}
}
Aggregations