コード例 #1
0
  @Test
  public void test2() throws Exception {
    MDP mdp = MDP.instance();
    mdp.addDoubleOutcomAction(
        State.instance(0),
        State.instance(1),
        State.instance(2),
        7.9,
        -5.1,
        0.81,
        0.19,
        Action.defaultName);
    mdp.addSingleOutcomAction(State.instance(1), State.instance(3), 2.5, Action.defaultName);
    mdp.addSingleOutcomAction(State.instance(2), State.instance(3), -7.2, Action.defaultName);
    mdp.addSingleOutcomAction(State.instance(3), State.instance(4), 9.0, Action.defaultName);
    mdp.addSingleOutcomAction(State.instance(4), State.instance(5), 0, Action.defaultName);
    mdp.addSingleOutcomAction(State.instance(5), State.instance(6), 1.6, Action.defaultName);

    MDPViewer.instance(mdp).display();

    ValueIteration vi = new ValueIteration(mdp);
    vi.run();
    Assert.assertEquals(16.687, State.instance(0).getValue(), 0.1);

    MLUtils.readFromConsole("Press any key");
  }
コード例 #2
0
 @Test
 public void test1() throws Exception {
   MDP mdp = MDP.instance();
   mdp.addSingleOutcomAction(State.instance(1), State.instance(2), 10, Action.defaultName);
   ValueIteration vi = new ValueIteration(mdp);
   vi.run();
   Assert.assertEquals(10, State.instance(1).getValue(), 0.1);
 }