Search in sources :

Example 1 with ByteIntHashMap

use of org.eclipse.collections.impl.map.mutable.primitive.ByteIntHashMap in project narchy by automenta.

the class WorkerMultiExecTest method testValueDerivationBranches.

@Test
public void testValueDerivationBranches() throws Narsese.NarseseException {
    // int threads = 1;
    // Exec exe = new MultiExec(32, threads, 2);
    Exec exe = new UniExec(32);
    NAR n = new NARS().deriverAdd(1, 1).deriverAdd(6, 6).exe(exe).get();
    // all -1 except goal production
    Arrays.fill(n.emotion.want, -1);
    n.emotion.want(MetaGoal.Desire, +1);
    Exec.Revaluator r = new Focus.DefaultRevaluator();
    int cycles = 100;
    // 2 competing independent processes. NAL1 rules will apply to one, and NAL6 rules apply to ther other.
    // measure the amount of derivation work occurring for each
    ByteIntHashMap byPunc = new ByteIntHashMap();
    n.onTask(t -> {
        if (t instanceof DerivedTask) {
            byPunc.addToValue(t.punc(), 1);
        }
    });
    n.log();
    n.input("(x==>y).");
    n.input("f:a.");
    for (int i = 0; i < cycles; i++) {
        n.input("f:b. :|:");
        n.input("x! :|:");
        n.run(1);
        r.update(n);
    }
    System.out.println(byPunc);
    n.causes.forEach(c -> {
        double sum = Util.sum((ToDoubleFunction<Traffic>) (t -> t.total), c.goal);
        if (sum > Double.MIN_NORMAL) {
            System.out.println(Arrays.toString(c.goal) + "\t" + c);
        }
    });
}
Also used : NARS(nars.NARS) ByteIntHashMap(org.eclipse.collections.impl.map.mutable.primitive.ByteIntHashMap) Traffic(nars.control.Traffic) DerivedTask(nars.task.DerivedTask) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Aggregations

NAR (nars.NAR)1 NARS (nars.NARS)1 Traffic (nars.control.Traffic)1 DerivedTask (nars.task.DerivedTask)1 ByteIntHashMap (org.eclipse.collections.impl.map.mutable.primitive.ByteIntHashMap)1 Test (org.junit.jupiter.api.Test)1