use of jcog.pri.Pri in project narchy by automenta.
the class ArrayBagTest method testBudgetMerge.
@Test
public void testBudgetMerge() {
PLinkArrayBag<String> a = new PLinkArrayBag<String>(4, plus, new HashMap<>(4));
assertEquals(0, a.size());
a.put(new PLink("x", 0.1f));
a.put(new PLink("x", 0.1f));
a.commit(null);
assertEquals(1, a.size());
PriReference<String> agx = a.get("x");
Pri expect = new Pri(0.2f);
assertTrue(Util.equals(expect.priElseNeg1(), agx.priElseNeg1(), 0.01f), agx + "==?==" + expect);
}
use of jcog.pri.Pri in project narchy by automenta.
the class PriMergeTest method testMerge.
private static Prioritized testMerge(Priority x, Prioritized y, @NotNull PriMerge m, float ouPri, float expectedOverflow) {
x = x.clonePri();
Prioritized x0 = x.clonePri();
float overflow = m.merge(x, y);
System.out.println(x0 + " <-merge<- " + y + " x " + "\t\texpect:" + new Pri(ouPri) + " ?? actual:" + x);
assertEquals(ouPri, x.pri(), tol);
if (expectedOverflow > 0)
assertEquals(expectedOverflow, overflow, 0.01f);
return x;
}
Aggregations