@Test public void testRunRLUnitTestSuite() throws Exception { final URL code = getClass().getResource("/org/jsoar/kernel/RLTests_testRLUnit.soar"); SoarCommands.source(agent.getInterpreter(), code); boolean hrl_discount = agent.getProperties() .get(ReinforcementLearningParams.HRL_DISCOUNT) == ReinforcementLearningParams.HrlDiscount.on; final Map<String, List<Double>> expectedValues = new HashMap<String, List<Double>>(); if (hrl_discount) { expectedValues.put("rl*value*function*2", Arrays.asList(10., 19.5, 28.5, 37.005, 45.024)); expectedValues.put("rl*value*function*3", Arrays.asList(10., 19., 27.1, 34.39, 40.951)); expectedValues.put("rl*value*function*4", Arrays.asList(15., 28.75, 41.35, 52.8925, 63.463)); expectedValues.put("rl*value*function*5", Arrays.asList(10., 19., 27.1, 34.39, 40.951)); expectedValues.put("rl*value*function*6", Arrays.asList(15., 28.75, 41.35, 52.8925, 63.463)); expectedValues.put("rl*value*function*7", Arrays.asList(10., 19., 27.1, 34.39, 40.951)); expectedValues.put("rl*value*function*8", Arrays.asList(18.75, 35.6875, 50.9875, 64.808125, 77.29225)); expectedValues.put("rl*value*function*9", Arrays.asList(10., 19., 27.1, 34.39, 40.951)); } else { expectedValues.put("rl*value*function*2", Arrays.asList(10., 19.5, 28.5, 37.005, 45.024)); expectedValues.put("rl*value*function*3", Arrays.asList(10., 19., 27.1, 34.39, 40.951)); expectedValues.put("rl*value*function*4", Arrays.asList(15., 28.75, 41.35, 52.8925,63.463)); expectedValues.put("rl*value*function*5", Arrays.asList(10., 19., 27.1, 34.39, 40.951)); expectedValues.put("rl*value*function*6", Arrays.asList(20., 38.5, 55.6, 71.395, 85.975)); expectedValues.put("rl*value*function*7", Arrays.asList(10., 19., 27.1, 34.39, 40.951)); expectedValues.put("rl*value*function*8", Arrays.asList(20., 38.125,54.55, 69.43375,82.92025)); expectedValues.put("rl*value*function*9", Arrays.asList(10., 19., 27.1, 34.39, 40.951)); } final int NUM_RUNS = 5; for(int run = 0; run < NUM_RUNS; run++) { agent.runFor(0, RunType.FOREVER); for(Map.Entry<String, List<Double>> e : expectedValues.entrySet()) { final String ruleName = e.getKey(); final double expectedValue = e.getValue().get(run); final Production rule = agent.getProductions().getProduction(ruleName); assertNotNull(rule); Double actualValue = rule.getFirstAction().asMakeAction().referent .asSymbolValue().getSym().asDouble().getValue(); assertEquals(expectedValue, actualValue, 0.00000001); } agent.initialize(); } }
public void initialize() { this.syms = Adaptables.require(getClass(), myContext, SymbolFactoryImpl.class); this.decider = Adaptables.require(getClass(), myContext, Decider.class); this.chunker = Adaptables.require(getClass(), myContext, Chunker.class); this.recMemory = Adaptables.require(getClass(), myContext, RecognitionMemory.class); this.rete = Adaptables.require(getClass(), myContext, Rete.class); this.preSyms = Adaptables.require(getClass(), myContext, PredefinedSymbols.class); this.trace = Adaptables.require(getClass(), myContext, Trace.class); this.printer = Adaptables.require(getClass(), myContext, Printer.class); properties.addListener(ReinforcementLearningParams.LEARNING, new PropertyListener<Learning>() { @Override public void propertyChanged(PropertyChangeEvent<Learning> event) { if (event.getNewValue() == Learning.off) { rl_reset_data(); } } }); rl_initialize_template_tracking(); }
ReinforcementLearning { public void initialize() { this.syms = Adaptables.require(getClass(), myContext, SymbolFactoryImpl.class); this.decider = Adaptables.require(getClass(), myContext, Decider.class); this.chunker = Adaptables.require(getClass(), myContext, Chunker.class); this.recMemory = Adaptables.require(getClass(), myContext, RecognitionMemory.class); this.rete = Adaptables.require(getClass(), myContext, Rete.class); this.preSyms = Adaptables.require(getClass(), myContext, PredefinedSymbols.class); this.trace = Adaptables.require(getClass(), myContext, Trace.class); this.printer = Adaptables.require(getClass(), myContext, Printer.class); properties.addListener(ReinforcementLearningParams.LEARNING, new PropertyListener<Learning>() { @Override public void propertyChanged(PropertyChangeEvent<Learning> event) { if (event.getNewValue() == Learning.off) { rl_reset_data(); } } }); rl_initialize_template_tracking(); } }
ReinforcementLearning { public void initialize() { this.syms = Adaptables.require(getClass(), myContext, SymbolFactoryImpl.class); this.decider = Adaptables.require(getClass(), myContext, Decider.class); this.chunker = Adaptables.require(getClass(), myContext, Chunker.class); this.recMemory = Adaptables.require(getClass(), myContext, RecognitionMemory.class); this.rete = Adaptables.require(getClass(), myContext, Rete.class); this.preSyms = Adaptables.require(getClass(), myContext, PredefinedSymbols.class); this.trace = Adaptables.require(getClass(), myContext, Trace.class); this.printer = Adaptables.require(getClass(), myContext, Printer.class); properties.addListener(ReinforcementLearningParams.LEARNING, new PropertyListener<Learning>() { @Override public void propertyChanged(PropertyChangeEvent<Learning> event) { if (event.getNewValue() == Learning.off) { rl_reset_data(); } } }); rl_initialize_template_tracking(); } ReinforcementLearning(Adaptable context); }
ReinforcementLearning { public void initialize() { this.syms = Adaptables.require(getClass(), myContext, SymbolFactoryImpl.class); this.decider = Adaptables.require(getClass(), myContext, Decider.class); this.chunker = Adaptables.require(getClass(), myContext, Chunker.class); this.recMemory = Adaptables.require(getClass(), myContext, RecognitionMemory.class); this.rete = Adaptables.require(getClass(), myContext, Rete.class); this.preSyms = Adaptables.require(getClass(), myContext, PredefinedSymbols.class); this.trace = Adaptables.require(getClass(), myContext, Trace.class); this.printer = Adaptables.require(getClass(), myContext, Printer.class); properties.addListener(ReinforcementLearningParams.LEARNING, new PropertyListener<Learning>() { @Override public void propertyChanged(PropertyChangeEvent<Learning> event) { if (event.getNewValue() == Learning.off) { rl_reset_data(); } } }); rl_initialize_template_tracking(); } ReinforcementLearning(Adaptable context); ReinforcementLearningParams getParams(); void initialize(); boolean rl_enabled(); void rl_initialize_template_tracking(); SymbolImpl rl_build_template_instantiation( Instantiation my_template_instance, Token tok, WmeImpl w ); void rl_tabulate_reward_value_for_goal(IdentifierImpl goal ); void rl_tabulate_reward_values(); void rl_store_data(IdentifierImpl goal, Preference cand); void rl_perform_update(double op_value, boolean op_rl, IdentifierImpl goal); void rl_perform_update(double op_value, boolean op_rl, IdentifierImpl goal, boolean update_efr ); static void rl_watkins_clear(IdentifierImpl goal ); void addProduction(Production p); void exciseProduction(Production prod); }
ReinforcementLearning { public void initialize() { this.syms = Adaptables.require(getClass(), myContext, SymbolFactoryImpl.class); this.decider = Adaptables.require(getClass(), myContext, Decider.class); this.chunker = Adaptables.require(getClass(), myContext, Chunker.class); this.recMemory = Adaptables.require(getClass(), myContext, RecognitionMemory.class); this.rete = Adaptables.require(getClass(), myContext, Rete.class); this.preSyms = Adaptables.require(getClass(), myContext, PredefinedSymbols.class); this.trace = Adaptables.require(getClass(), myContext, Trace.class); this.printer = Adaptables.require(getClass(), myContext, Printer.class); properties.addListener(ReinforcementLearningParams.LEARNING, new PropertyListener<Learning>() { @Override public void propertyChanged(PropertyChangeEvent<Learning> event) { if (event.getNewValue() == Learning.off) { rl_reset_data(); } } }); rl_initialize_template_tracking(); } ReinforcementLearning(Adaptable context); ReinforcementLearningParams getParams(); void initialize(); boolean rl_enabled(); void rl_initialize_template_tracking(); SymbolImpl rl_build_template_instantiation( Instantiation my_template_instance, Token tok, WmeImpl w ); void rl_tabulate_reward_value_for_goal(IdentifierImpl goal ); void rl_tabulate_reward_values(); void rl_store_data(IdentifierImpl goal, Preference cand); void rl_perform_update(double op_value, boolean op_rl, IdentifierImpl goal); void rl_perform_update(double op_value, boolean op_rl, IdentifierImpl goal, boolean update_efr ); static void rl_watkins_clear(IdentifierImpl goal ); void addProduction(Production p); void exciseProduction(Production prod);  }