Search in sources :

Example 1 with CellWorldAction

use of aima.core.environment.cellworld.CellWorldAction in project aima-java by aimacode.

the class LearningDemo method passiveTDAgentDemo.

public static void passiveTDAgentDemo() {
    System.out.println("======================");
    System.out.println("DEMO: Passive-TD-Agent");
    System.out.println("======================");
    System.out.println("Figure 21.5");
    System.out.println("-----------");
    CellWorld<Double> cw = CellWorldFactory.createCellWorldForFig17_1();
    CellWorldEnvironment cwe = new CellWorldEnvironment(cw.getCellAt(1, 1), cw.getCells(), MDPFactory.createTransitionProbabilityFunctionForFigure17_1(cw), new JavaRandomizer());
    Map<Cell<Double>, CellWorldAction> fixedPolicy = new HashMap<Cell<Double>, CellWorldAction>();
    fixedPolicy.put(cw.getCellAt(1, 1), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(1, 2), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(1, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(2, 1), CellWorldAction.Left);
    fixedPolicy.put(cw.getCellAt(2, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(3, 1), CellWorldAction.Left);
    fixedPolicy.put(cw.getCellAt(3, 2), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(3, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(4, 1), CellWorldAction.Left);
    PassiveTDAgent<Cell<Double>, CellWorldAction> ptda = new PassiveTDAgent<Cell<Double>, CellWorldAction>(fixedPolicy, 0.2, 1.0);
    cwe.addAgent(ptda);
    output_utility_learning_rates(ptda, 20, 500, 100, 1);
    System.out.println("=========================");
}
Also used : CellWorldAction(aima.core.environment.cellworld.CellWorldAction) HashMap(java.util.HashMap) PassiveTDAgent(aima.core.learning.reinforcement.agent.PassiveTDAgent) JavaRandomizer(aima.core.util.JavaRandomizer) CellWorldEnvironment(aima.core.learning.reinforcement.example.CellWorldEnvironment) Cell(aima.core.environment.cellworld.Cell)

Example 2 with CellWorldAction

use of aima.core.environment.cellworld.CellWorldAction in project aima-java by aimacode.

the class LearningDemo method qLearningAgentDemo.

public static void qLearningAgentDemo() {
    System.out.println("======================");
    System.out.println("DEMO: Q-Learning-Agent");
    System.out.println("======================");
    CellWorld<Double> cw = CellWorldFactory.createCellWorldForFig17_1();
    CellWorldEnvironment cwe = new CellWorldEnvironment(cw.getCellAt(1, 1), cw.getCells(), MDPFactory.createTransitionProbabilityFunctionForFigure17_1(cw), new JavaRandomizer());
    QLearningAgent<Cell<Double>, CellWorldAction> qla = new QLearningAgent<Cell<Double>, CellWorldAction>(MDPFactory.createActionsFunctionForFigure17_1(cw), CellWorldAction.None, 0.2, 1.0, 5, 2.0);
    cwe.addAgent(qla);
    output_utility_learning_rates(qla, 20, 10000, 500, 20);
    System.out.println("=========================");
}
Also used : CellWorldAction(aima.core.environment.cellworld.CellWorldAction) JavaRandomizer(aima.core.util.JavaRandomizer) CellWorldEnvironment(aima.core.learning.reinforcement.example.CellWorldEnvironment) QLearningAgent(aima.core.learning.reinforcement.agent.QLearningAgent) Cell(aima.core.environment.cellworld.Cell)

Example 3 with CellWorldAction

use of aima.core.environment.cellworld.CellWorldAction in project aima-java by aimacode.

the class PassiveADPAgentTest method setUp.

@Before
public void setUp() {
    cw = CellWorldFactory.createCellWorldForFig17_1();
    cwe = new CellWorldEnvironment(cw.getCellAt(1, 1), cw.getCells(), MDPFactory.createTransitionProbabilityFunctionForFigure17_1(cw), new JavaRandomizer());
    Map<Cell<Double>, CellWorldAction> fixedPolicy = new HashMap<Cell<Double>, CellWorldAction>();
    fixedPolicy.put(cw.getCellAt(1, 1), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(1, 2), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(1, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(2, 1), CellWorldAction.Left);
    fixedPolicy.put(cw.getCellAt(2, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(3, 1), CellWorldAction.Left);
    fixedPolicy.put(cw.getCellAt(3, 2), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(3, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(4, 1), CellWorldAction.Left);
    padpa = new PassiveADPAgent<Cell<Double>, CellWorldAction>(fixedPolicy, cw.getCells(), cw.getCellAt(1, 1), MDPFactory.createActionsFunctionForFigure17_1(cw), new ModifiedPolicyEvaluation<Cell<Double>, CellWorldAction>(10, 1.0));
    cwe.addAgent(padpa);
}
Also used : CellWorldAction(aima.core.environment.cellworld.CellWorldAction) HashMap(java.util.HashMap) JavaRandomizer(aima.core.util.JavaRandomizer) CellWorldEnvironment(aima.core.learning.reinforcement.example.CellWorldEnvironment) Cell(aima.core.environment.cellworld.Cell) ModifiedPolicyEvaluation(aima.core.probability.mdp.impl.ModifiedPolicyEvaluation) Before(org.junit.Before)

Example 4 with CellWorldAction

use of aima.core.environment.cellworld.CellWorldAction in project aima-java by aimacode.

the class PassiveTDAgentTest method setUp.

@Before
public void setUp() {
    cw = CellWorldFactory.createCellWorldForFig17_1();
    cwe = new CellWorldEnvironment(cw.getCellAt(1, 1), cw.getCells(), MDPFactory.createTransitionProbabilityFunctionForFigure17_1(cw), new JavaRandomizer());
    Map<Cell<Double>, CellWorldAction> fixedPolicy = new HashMap<Cell<Double>, CellWorldAction>();
    fixedPolicy.put(cw.getCellAt(1, 1), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(1, 2), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(1, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(2, 1), CellWorldAction.Left);
    fixedPolicy.put(cw.getCellAt(2, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(3, 1), CellWorldAction.Left);
    fixedPolicy.put(cw.getCellAt(3, 2), CellWorldAction.Up);
    fixedPolicy.put(cw.getCellAt(3, 3), CellWorldAction.Right);
    fixedPolicy.put(cw.getCellAt(4, 1), CellWorldAction.Left);
    ptda = new PassiveTDAgent<Cell<Double>, CellWorldAction>(fixedPolicy, 0.2, 1.0);
    cwe.addAgent(ptda);
}
Also used : CellWorldAction(aima.core.environment.cellworld.CellWorldAction) HashMap(java.util.HashMap) JavaRandomizer(aima.core.util.JavaRandomizer) CellWorldEnvironment(aima.core.learning.reinforcement.example.CellWorldEnvironment) Cell(aima.core.environment.cellworld.Cell) Before(org.junit.Before)

Example 5 with CellWorldAction

use of aima.core.environment.cellworld.CellWorldAction in project aima-java by aimacode.

the class QLearningAgentTest method setUp.

@Before
public void setUp() {
    cw = CellWorldFactory.createCellWorldForFig17_1();
    cwe = new CellWorldEnvironment(cw.getCellAt(1, 1), cw.getCells(), MDPFactory.createTransitionProbabilityFunctionForFigure17_1(cw), new JavaRandomizer());
    qla = new QLearningAgent<Cell<Double>, CellWorldAction>(MDPFactory.createActionsFunctionForFigure17_1(cw), CellWorldAction.None, 0.2, 1.0, 5, 2.0);
    cwe.addAgent(qla);
}
Also used : CellWorldAction(aima.core.environment.cellworld.CellWorldAction) JavaRandomizer(aima.core.util.JavaRandomizer) CellWorldEnvironment(aima.core.learning.reinforcement.example.CellWorldEnvironment) Cell(aima.core.environment.cellworld.Cell) Before(org.junit.Before)

Aggregations

Cell (aima.core.environment.cellworld.Cell)6 CellWorldAction (aima.core.environment.cellworld.CellWorldAction)6 CellWorldEnvironment (aima.core.learning.reinforcement.example.CellWorldEnvironment)6 JavaRandomizer (aima.core.util.JavaRandomizer)6 HashMap (java.util.HashMap)4 Before (org.junit.Before)3 PassiveADPAgent (aima.core.learning.reinforcement.agent.PassiveADPAgent)1 PassiveTDAgent (aima.core.learning.reinforcement.agent.PassiveTDAgent)1 QLearningAgent (aima.core.learning.reinforcement.agent.QLearningAgent)1 ModifiedPolicyEvaluation (aima.core.probability.mdp.impl.ModifiedPolicyEvaluation)1