use of nars.table.RTreeBeliefTable in project narchy by automenta.
the class RTreeBeliefTableTest method testBasicOperations.
@Test
public void testBasicOperations() throws Narsese.NarseseException {
NAR n = NARS.shell();
Term ab = nars.$.$("a:b");
TaskConcept X = (TaskConcept) n.conceptualize(ab);
RTreeBeliefTable r = RTreeBeliefTable.build(ab);
r.setCapacity(4);
assertEquals(0, r.size());
Term x = X.term();
float freq = 1f;
float conf = 0.9f;
int creationTime = 1;
int start = 1, end = 1;
Task a = add(r, x, freq, conf, start, end, n);
assertEquals(1, r.size());
r.add(a, X, n);
r.print(System.out);
// no change for inserted duplicate
assertEquals(1, r.size());
// WEAKer
Task b = add(r, x, 0f, 0.5f, 1, 1, n);
assertEquals(2, r.size());
Task c = add(r, x, 0.1f, 0.9f, 2, 2, n);
assertEquals(3, r.size());
Task d = add(r, x, 0.1f, 0.9f, 3, 4, n);
assertEquals(4, r.size());
System.out.println("at capacity");
r.print(System.out);
// try capacity limit
Task e = add(r, x, 0.3f, 0.9f, 3, 4, n);
System.out.println("\nat capacity?");
r.print(System.out);
r.forEachTask(System.out::println);
// capacity limit unaffected
assertEquals(4, r.size());
System.out.println("after capacity compress inserting " + e.toString(true));
r.print(System.out);
}
use of nars.table.RTreeBeliefTable in project narchy by automenta.
the class RTreeBeliefTableTest method testProjection.
@Test
public void testProjection() throws Narsese.NarseseException {
NAR n = NARS.shell();
Term ab = nars.$.$("a:b");
TaskConcept X = (TaskConcept) n.conceptualize(ab);
RTreeBeliefTable r = RTreeBeliefTable.build(ab);
r.setCapacity(4);
add(r, X, 1f, 0.9f, 0, 1, n);
add(r, X, 0f, 0.9f, 2, 3, n);
assertEquals(1f, r.truth(0, 0, null, 1).freq());
assertEquals("%.65;.93%", r.truth(0, 1, null, 1).toString());
assertEquals("%.65;.93%", r.truth(1, 1, null, 1).toString());
assertEquals("%.50;.95%", r.truth(1, 2, null, 1).toString());
assertEquals("%.35;.93%", r.truth(2, 3, null, 1).toString());
assertEquals(0f, r.truth(3, 3, null, 1).freq());
assertEquals("%0.0;.83%", r.truth(4, 4, null, 1).toString());
assertEquals("%0.0;.83%", r.truth(4, 5, null, 1).toString());
assertEquals("%0.0;.78%", r.truth(5, 5, null, 1).toString());
}
Aggregations