burlap.mdp.singleagent.model.FactoredModel Java Examples
The following examples show how to use
burlap.mdp.singleagent.model.FactoredModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExampleGridWorld.java From burlap_examples with MIT License | 6 votes |
@Override public SADomain generateDomain() { SADomain domain = new SADomain(); domain.addActionTypes( new UniversalActionType(ACTION_NORTH), new UniversalActionType(ACTION_SOUTH), new UniversalActionType(ACTION_EAST), new UniversalActionType(ACTION_WEST)); GridWorldStateModel smodel = new GridWorldStateModel(); RewardFunction rf = new ExampleRF(this.goalx, this.goaly); TerminalFunction tf = new ExampleTF(this.goalx, this.goaly); domain.setModel(new FactoredModel(smodel, rf, tf)); return domain; }
Example #2
Source File: BlocksWorld.java From burlap with Apache License 2.0 | 5 votes |
@Override public OOSADomain generateDomain() { OOSADomain domain = new OOSADomain(); domain.addStateClass(CLASS_BLOCK, BlocksWorldBlock.class); domain.addActionType(new StackActionType(ACTION_STACK)) .addActionType(new UnstackActionType(ACTION_UNSTACK)); RewardFunction rf = this.rf; TerminalFunction tf = this.tf; if(rf == null){ rf = new NullRewardFunction(); } if(tf == null){ tf = new NullTermination(); } BWModel smodel = new BWModel(); FactoredModel model = new FactoredModel(smodel, rf , tf); domain.setModel(model); OODomain.Helper.addPfsToDomain(domain, this.generatePfs()); return domain; }
Example #3
Source File: InvertedPendulum.java From burlap with Apache License 2.0 | 5 votes |
@Override public SADomain generateDomain() { SADomain domain = new SADomain(); IPPhysicsParams cphys = this.physParams.copy(); IPModel smodel = new IPModel(cphys); RewardFunction rf = this.rf; TerminalFunction tf = this.tf; if(rf == null){ rf = new InvertedPendulumRewardFunction(); } if(tf == null){ tf = new InvertedPendulumTerminalFunction(); } FactoredModel model = new FactoredModel(smodel, rf ,tf); domain.setModel(model); domain.addActionType(new UniversalActionType(ACTION_LEFT)) .addActionType(new UniversalActionType(ACTION_RIGHT)) .addActionType(new UniversalActionType(ACTION_NO_FORCE)); return domain; }
Example #4
Source File: BasicBehavior.java From burlap_examples with MIT License | 4 votes |
public void experimentAndPlotter(){ //different reward function for more structured performance plots ((FactoredModel)domain.getModel()).setRf(new GoalBasedRF(this.goalCondition, 5.0, -0.1)); /** * Create factories for Q-learning agent and SARSA agent to compare */ LearningAgentFactory qLearningFactory = new LearningAgentFactory() { public String getAgentName() { return "Q-Learning"; } public LearningAgent generateAgent() { return new QLearning(domain, 0.99, hashingFactory, 0.3, 0.1); } }; LearningAgentFactory sarsaLearningFactory = new LearningAgentFactory() { public String getAgentName() { return "SARSA"; } public LearningAgent generateAgent() { return new SarsaLam(domain, 0.99, hashingFactory, 0.0, 0.1, 1.); } }; LearningAlgorithmExperimenter exp = new LearningAlgorithmExperimenter(env, 10, 100, qLearningFactory, sarsaLearningFactory); exp.setUpPlottingConfiguration(500, 250, 2, 1000, TrialMode.MOST_RECENT_AND_AVERAGE, PerformanceMetric.CUMULATIVE_STEPS_PER_EPISODE, PerformanceMetric.AVERAGE_EPISODE_REWARD); exp.startExperiment(); exp.writeStepAndEpisodeDataToCSV("expData"); }
Example #5
Source File: ExampleOOGridWorld.java From burlap_examples with MIT License | 4 votes |
@Override public OOSADomain generateDomain() { OOSADomain domain = new OOSADomain(); domain.addStateClass(CLASS_AGENT, ExGridAgent.class) .addStateClass(CLASS_LOCATION, EXGridLocation.class); domain.addActionTypes( new UniversalActionType(ACTION_NORTH), new UniversalActionType(ACTION_SOUTH), new UniversalActionType(ACTION_EAST), new UniversalActionType(ACTION_WEST)); OODomain.Helper.addPfsToDomain(domain, this.generatePfs()); OOGridWorldStateModel smodel = new OOGridWorldStateModel(); RewardFunction rf = new SingleGoalPFRF(domain.propFunction(PF_AT), 100, -1); TerminalFunction tf = new SinglePFTF(domain.propFunction(PF_AT)); domain.setModel(new FactoredModel(smodel, rf, tf)); return domain; }
Example #6
Source File: MountainCar.java From burlap with Apache License 2.0 | 4 votes |
@Override public SADomain generateDomain() { SADomain domain = new SADomain(); MCModel smodel = new MCModel(this.physParams.copy()); if(tf == null){ tf = new ClassicMCTF(physParams.xmax); } if(rf == null){ rf = new GoalBasedRF(tf, 100, 0); } FactoredModel model = new FactoredModel(smodel, rf, tf); domain.setModel(model); domain.addActionType(new UniversalActionType(ACTION_FORWARD)) .addActionType(new UniversalActionType(ACTION_BACKWARDS)) .addActionType(new UniversalActionType(ACTION_COAST)); return domain; }
Example #7
Source File: LunarLanderDomain.java From burlap with Apache License 2.0 | 4 votes |
@Override public OOSADomain generateDomain() { OOSADomain domain = new OOSADomain(); List <Double> thrustValuesTemp = this.thrustValues; if(thrustValuesTemp.isEmpty()){ thrustValuesTemp.add(0.32); thrustValuesTemp.add(-physParams.gravity); } domain.addStateClass(CLASS_AGENT, LLAgent.class) .addStateClass(CLASS_PAD, LLBlock.LLPad.class) .addStateClass(CLASS_OBSTACLE, LLBlock.LLObstacle.class); //make copy of physics parameters LLPhysicsParams cphys = this.physParams.copy(); //add actions domain.addActionType(new UniversalActionType(ACTION_TURN_LEFT)) .addActionType(new UniversalActionType(ACTION_TURN_RIGHT)) .addActionType(new UniversalActionType(ACTION_IDLE)) .addActionType(new ThrustType(thrustValues)); OODomain.Helper.addPfsToDomain(domain, this.generatePfs()); LunarLanderModel smodel = new LunarLanderModel(cphys); RewardFunction rf = this.rf; TerminalFunction tf = this.tf; if(rf == null){ rf = new LunarLanderRF(domain); } if(tf == null){ tf = new LunarLanderTF(domain); } FactoredModel model = new FactoredModel(smodel, rf, tf); domain.setModel(model); return domain; }
Example #8
Source File: GraphDefinedDomain.java From burlap with Apache License 2.0 | 4 votes |
@Override public SADomain generateDomain() { SADomain domain = new SADomain(); Map<Integer, Map<Integer, Set<NodeTransitionProbability>>> ctd = this.copyTransitionDynamics(); GraphStateModel stateModel = new GraphStateModel(ctd); FactoredModel model = new FactoredModel(stateModel, rf, tf); domain.setModel(model); for(int i = 0; i < this.maxActions; i++){ domain.addActionType(new GraphActionType(i, ctd)); } return domain; }
Example #9
Source File: FrostbiteDomain.java From burlap with Apache License 2.0 | 4 votes |
/** * Creates a new frostbite domain. * * @return the generated domain object */ @Override public OOSADomain generateDomain() { OOSADomain domain = new OOSADomain(); domain.addStateClass(CLASS_AGENT, FrostbiteAgent.class) .addStateClass(CLASS_IGLOO, FrostbiteIgloo.class) .addStateClass(CLASS_PLATFORM, FrostbitePlatform.class); //add actions domain.addActionType(new UniversalActionType(ACTION_NORTH)) .addActionType(new UniversalActionType(ACTION_SOUTH)) .addActionType(new UniversalActionType(ACTION_EAST)) .addActionType(new UniversalActionType(ACTION_WEST)) .addActionType(new UniversalActionType(ACTION_IDLE)); //add pfs List<PropositionalFunction> pfs = this.generatePFs(); for(PropositionalFunction pf : pfs){ domain.addPropFunction(pf); } FrostbiteModel smodel = new FrostbiteModel(scale); RewardFunction rf = this.rf; TerminalFunction tf = this.tf; if(rf == null){ rf = new FrostbiteRF(domain); } if(tf == null){ tf = new FrostbiteTF(domain); } FactoredModel model = new FactoredModel(smodel, rf, tf); domain.setModel(model); return domain; }
Example #10
Source File: CartPoleDomain.java From burlap with Apache License 2.0 | 3 votes |
@Override public SADomain generateDomain() { SADomain domain = new SADomain(); CPPhysicsParams cphys = this.physParams.copy(); RewardFunction rf = this.rf; TerminalFunction tf = this.tf; if(rf == null){ rf = new CartPoleRewardFunction(); } if(tf == null){ tf = new CartPoleTerminalFunction(); } FullStateModel smodel = cphys.useCorrectModel ? new CPClassicModel(cphys) : new CPClassicModel(cphys); FactoredModel model = new FactoredModel(smodel, rf, tf); domain.setModel(model); domain.addActionType(new UniversalActionType(ACTION_LEFT)) .addActionType(new UniversalActionType(ACTION_RIGHT)); return domain; }