RLPark 1.0.0
Reinforcement Learning Framework in Java
|
00001 package rlpark.plugin.rltoys.experiments.testing.control; 00002 00003 import rlpark.plugin.rltoys.agents.rl.LearnerAgentFA; 00004 import rlpark.plugin.rltoys.algorithms.control.ControlLearner; 00005 import rlpark.plugin.rltoys.algorithms.representations.tilescoding.TileCoders; 00006 import rlpark.plugin.rltoys.algorithms.representations.tilescoding.TileCodersNoHashing; 00007 import rlpark.plugin.rltoys.envio.rl.RLAgent; 00008 import rlpark.plugin.rltoys.experiments.helpers.Runner; 00009 import rlpark.plugin.rltoys.problems.pendulum.SwingPendulum; 00010 00011 public class PendulumOnPolicyLearning { 00012 public interface ControlFactory { 00013 ControlLearner create(SwingPendulum problem, int vectorSize, double vectorNorm); 00014 } 00015 00016 public static double evaluate(ControlFactory controlFactory) { 00017 SwingPendulum problem = new SwingPendulum(null); 00018 TileCoders tileCoders = new TileCodersNoHashing(problem.getObservationRanges()); 00019 tileCoders.addFullTilings(10, 10); 00020 tileCoders.includeActiveFeature(); 00021 ControlLearner control = controlFactory.create(problem, tileCoders.vectorSize(), tileCoders.vectorNorm()); 00022 RLAgent agent = new LearnerAgentFA(control, tileCoders); 00023 Runner runner = new Runner(problem, agent, 50, 5000); 00024 runner.run(); 00025 return runner.runnerEvent().episodeReward / runner.runnerEvent().step.time; 00026 } 00027 }