Search in sources :

Example 1 with PredictionDemon

use of nars.rl.horde.demons.PredictionDemon in project narchy by automenta.

the class HordeTest method testPredictionDemon.

@Test
public void testPredictionDemon() {
    TD td = new TD(0.0, 0.1, 1);
    PredictionDemon predictionDemon = new PredictionDemon(RewardFunction01, td);
    PredictionDemonVerifier verifier = new PredictionDemonVerifier(td.gamma(), predictionDemon);
    runExperiment(predictionDemon, verifier);
    assertEquals(RewardFunction01.reward(), predictionDemon.prediction(), 1.0);
}
Also used : TD(nars.rl.horde.functions.TD) PredictionDemonVerifier(nars.rl.horde.demons.PredictionDemonVerifier) PredictionDemon(nars.rl.horde.demons.PredictionDemon) Test(org.junit.jupiter.api.Test)

Example 2 with PredictionDemon

use of nars.rl.horde.demons.PredictionDemon in project narchy by automenta.

the class HordeTest method testPredictionDemonGamma09MultipleState.

@Test
public void testPredictionDemonGamma09MultipleState() {
    final int bufferSize = 50;
    double gamma = 0.9;
    TD td = new TD(gamma, 0.1, bufferSize);
    CustomRewardFunction rewardFunction = new CustomRewardFunction(bufferSize);
    PredictionDemon predictionDemon = new PredictionDemon(rewardFunction, td);
    PredictionDemonVerifier verifier = new PredictionDemonVerifier(td.gamma(), predictionDemon);
    TimeToState timeToState = new TimeToState() {

        @Override
        public RealVector get(int time) {
            RealVector r = new ArrayRealVector(bufferSize);
            r.setEntry(time % bufferSize, 1);
            return r;
        }
    };
    runExperiment(predictionDemon, verifier, timeToState, 1000 * bufferSize);
}
Also used : TD(nars.rl.horde.functions.TD) PredictionDemonVerifier(nars.rl.horde.demons.PredictionDemonVerifier) RealVector(org.apache.commons.math3.linear.RealVector) ArrayRealVector(org.apache.commons.math3.linear.ArrayRealVector) ArrayRealVector(org.apache.commons.math3.linear.ArrayRealVector) PredictionDemon(nars.rl.horde.demons.PredictionDemon) Test(org.junit.jupiter.api.Test)

Example 3 with PredictionDemon

use of nars.rl.horde.demons.PredictionDemon in project narchy by automenta.

the class HordeTest method testPredictionDemonGamma09.

@Test
public void testPredictionDemonGamma09() {
    double gamma = 0.9;
    TD td = new TD(gamma, 0.1, 1);
    PredictionDemon predictionDemon = new PredictionDemon(RewardFunction01, td);
    PredictionDemonVerifier verifier = new PredictionDemonVerifier(td.gamma(), predictionDemon);
    runExperiment(predictionDemon, verifier);
    assertEquals(RewardFunction01.reward() / (1 - gamma), predictionDemon.prediction(), 1.0);
}
Also used : TD(nars.rl.horde.functions.TD) PredictionDemonVerifier(nars.rl.horde.demons.PredictionDemonVerifier) PredictionDemon(nars.rl.horde.demons.PredictionDemon) Test(org.junit.jupiter.api.Test)

Aggregations

PredictionDemon (nars.rl.horde.demons.PredictionDemon)3 PredictionDemonVerifier (nars.rl.horde.demons.PredictionDemonVerifier)3 TD (nars.rl.horde.functions.TD)3 Test (org.junit.jupiter.api.Test)3 ArrayRealVector (org.apache.commons.math3.linear.ArrayRealVector)1 RealVector (org.apache.commons.math3.linear.RealVector)1