burlap.mdp.core.oo.OODomain Java Examples
The following examples show how to use
burlap.mdp.core.oo.OODomain.
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: GameSequenceVisualizer.java From burlap with Apache License 2.0 | 6 votes |
private void updatePropTextArea(State s){ if(!(domain instanceof OODomain) || !(s instanceof OOState)){ return ; } StringBuilder buf = new StringBuilder(); List <PropositionalFunction> props = ((OODomain)domain).propFunctions(); for(PropositionalFunction pf : props){ List<GroundedProp> gps = pf.allGroundings((OOState)s); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)s)){ buf.append(gp.toString()).append("\n"); } } } propViewer.setText(buf.toString()); }
Example #2
Source File: EpisodeSequenceVisualizer.java From burlap with Apache License 2.0 | 6 votes |
protected void updatePropTextArea(State s){ if(!(domain instanceof OODomain) || !(s instanceof OOState)){ return ; } StringBuilder buf = new StringBuilder(); List <PropositionalFunction> props = ((OODomain)domain).propFunctions(); for(PropositionalFunction pf : props){ //List<GroundedProp> gps = s.getAllGroundedPropsFor(pf); List<GroundedProp> gps = pf.allGroundings((OOState)s); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)s)){ buf.append(gp.toString()).append("\n"); } } } propViewer.setText(buf.toString()); }
Example #3
Source File: VisualWorldObserver.java From burlap with Apache License 2.0 | 6 votes |
private void updatePropTextArea(State s){ if(!(domain instanceof OODomain) || !(s instanceof OOState)){ return ; } StringBuilder buf = new StringBuilder(); List <PropositionalFunction> props = ((OODomain)domain).propFunctions(); for(PropositionalFunction pf : props){ //List<GroundedProp> gps = s.getAllGroundedPropsFor(pf); List<GroundedProp> gps = pf.allGroundings((OOState)s); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)s)){ buf.append(gp.toString()).append("\n"); } } } propViewer.setText(buf.toString()); }
Example #4
Source File: VisualActionObserver.java From burlap with Apache License 2.0 | 6 votes |
private void updatePropTextArea(State s){ if(domain == null || !(s instanceof OOState)){ return ; } StringBuilder buf = new StringBuilder(); List <PropositionalFunction> props = ((OODomain)domain).propFunctions(); for(PropositionalFunction pf : props){ List<GroundedProp> gps = pf.allGroundings((OOState)s); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)s)){ buf.append(gp.toString()).append("\n"); } } } propViewer.setText(buf.toString()); }
Example #5
Source File: VisualExplorer.java From burlap with Apache License 2.0 | 6 votes |
/** * Updates the propositional function evaluation text display for the given state. * @param s the input state on which propositional functions are to be evaluated. */ protected void updatePropTextArea(State s){ if(!(domain instanceof OODomain) || !(s instanceof OOState)){ return ; } StringBuilder buf = new StringBuilder(); List <PropositionalFunction> props = ((OODomain)domain).propFunctions(); for(PropositionalFunction pf : props){ List<GroundedProp> gps = pf.allGroundings((OOState)s); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)s)){ buf.append(gp.toString()).append("\n"); } } } propViewer.setText(buf.toString()); }
Example #6
Source File: SGVisualExplorer.java From burlap with Apache License 2.0 | 6 votes |
protected void updatePropTextArea(State s){ if(!(domain instanceof OODomain) || !(s instanceof OOState)){ return; } StringBuilder buf = new StringBuilder(); List <PropositionalFunction> props = ((OODomain)domain).propFunctions(); for(PropositionalFunction pf : props){ List<GroundedProp> gps = pf.allGroundings((OOState)s); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)s)){ buf.append(gp.toString()).append("\n"); } } } propViewer.setText(buf.toString()); }
Example #7
Source File: GridGame.java From burlap with Apache License 2.0 | 5 votes |
/** * Initializes for a given domain, step cost reward, universal goal reward, and unique personal goal reward for each player. * @param ggDomain the domain * @param stepCost the reward returned for all transitions except transtions to goal locations * @param universalGoalReward the reward returned for transitions to a universal goal * @param noopIncursStepCost if true, then noop actions also incur the stepCost reward; if false, then noops always return 0 reward. * @param personalGoalRewards a map from player numbers to their personal goal reward (the first player number is 0) */ public GGJointRewardFunction(OODomain ggDomain, double stepCost, double universalGoalReward, boolean noopIncursStepCost, Map<Integer, Double> personalGoalRewards){ agentInPersonalGoal = ggDomain.propFunction(GridGame.PF_IN_P_GOAL); agentInUniversalGoal = ggDomain.propFunction(GridGame.PF_IN_U_GOAL); this.stepCost = stepCost; this.uGoalReward = universalGoalReward; this.noopIncursCost = noopIncursStepCost; this.personalGoalRewards = personalGoalRewards; }
Example #8
Source File: GridGame.java From burlap with Apache License 2.0 | 5 votes |
/** * Initializes for a given domain, step cost reward, personal goal reward, and universal goal reward. * @param ggDomain the domain * @param stepCost the reward returned for all transitions except transtions to goal locations * @param personalGoalReward the reward returned for transitions to a personal goal * @param universalGoalReward the reward returned for transitions to a universal goal * @param noopIncursStepCost if true, then noop actions also incur the stepCost reward; if false, then noops always return 0 reward. */ public GGJointRewardFunction(OODomain ggDomain, double stepCost, double personalGoalReward, double universalGoalReward, boolean noopIncursStepCost){ agentInPersonalGoal = ggDomain.propFunction(GridGame.PF_IN_P_GOAL); agentInUniversalGoal = ggDomain.propFunction(GridGame.PF_IN_U_GOAL); this.stepCost = stepCost; this.pGoalReward = personalGoalReward; this.uGoalReward = universalGoalReward; this.noopIncursCost = noopIncursStepCost; }
Example #9
Source File: GridGame.java From burlap with Apache License 2.0 | 5 votes |
/** * Initializes for a given domain, step cost reward and goal reward. * @param ggDomain the domain * @param stepCost the reward returned for all transitions except transtions to goal locations * @param goalReward the reward returned for transitioning to a personal or universal goal * @param noopIncursStepCost if true, then noop actions also incur the stepCost reward; if false, then noops always return 0 reward. */ public GGJointRewardFunction(OODomain ggDomain, double stepCost, double goalReward, boolean noopIncursStepCost){ agentInPersonalGoal = ggDomain.propFunction(GridGame.PF_IN_P_GOAL); agentInUniversalGoal = ggDomain.propFunction(GridGame.PF_IN_U_GOAL); this.stepCost = stepCost; this.pGoalReward = this.uGoalReward = goalReward; this.noopIncursCost = noopIncursStepCost; }
Example #10
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 #11
Source File: LunarLanderRF.java From burlap with Apache License 2.0 | 5 votes |
/** * Initializes with default reward values (move through air = -1; collision = -100; land on pad = +1000) * @param domain a {@link burlap.domain.singleagent.lunarlander.LunarLanderDomain} generated {@link burlap.mdp.core.Domain}. */ public LunarLanderRF(OODomain domain){ this.onGround = domain.propFunction(LunarLanderDomain.PF_ON_GROUND); this.touchingSurface = domain.propFunction(LunarLanderDomain.PF_TOUCH_SURFACE); this.touchingPad = domain.propFunction(LunarLanderDomain.PF_TOUTCH_PAD); this.onPad = domain.propFunction(LunarLanderDomain.PF_ON_PAD); }
Example #12
Source File: VisualActionObserver.java From burlap with Apache License 2.0 | 5 votes |
/** * Initializes * @param domain the {@link OODomain} holding the propositional functions for the propositional function viewer * @param painter the painter for rendering states * @param cWidth the width of the state visualization area * @param cHeight the height of the state visualization area */ public VisualActionObserver(OODomain domain, Visualizer painter, int cWidth, int cHeight){ this.domain = domain; this.painter = painter; this.cWidth = cWidth; this.cHeight = cHeight; this.propViewer = new TextArea(); this.propViewer.setEditable(false); }
Example #13
Source File: PFFeatures.java From burlap with Apache License 2.0 | 5 votes |
/** * Initializes using all propositional functions that belong to the domain * @param domain the domain containing all the propositional functions to use */ public PFFeatures(OODomain domain){ this.pfsToUse = new PropositionalFunction[domain.propFunctions().size()]; int i = 0; for(PropositionalFunction pf : domain.propFunctions()){ this.pfsToUse[i] = pf; i++; } }
Example #14
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 #15
Source File: FrostbiteTF.java From burlap with Apache License 2.0 | 4 votes |
public FrostbiteTF(OODomain domain) { this.inWater = domain.propFunction(FrostbiteDomain.PF_IN_WATER); this.onIce = domain.propFunction(FrostbiteDomain.PF_ON_ICE); this.iglooBuilt = domain.propFunction(FrostbiteDomain.PF_IGLOO_BUILT); }
Example #16
Source File: GridGame.java From burlap with Apache License 2.0 | 4 votes |
/** * Initializes for the given domain * @param ggDomain the specific grid world domain. */ public GGTerminalFunction(OODomain ggDomain){ agentInPersonalGoal = ggDomain.propFunction(GridGame.PF_IN_P_GOAL); agentInUniversalGoal = ggDomain.propFunction(GridGame.PF_IN_U_GOAL); }
Example #17
Source File: FrostbiteRF.java From burlap with Apache License 2.0 | 4 votes |
public FrostbiteRF(OODomain domain) { this.inWater = domain.propFunction(FrostbiteDomain.PF_IN_WATER); this.onIce = domain.propFunction(FrostbiteDomain.PF_ON_ICE); this.iglooBuilt = domain.propFunction(FrostbiteDomain.PF_IGLOO_BUILT); }
Example #18
Source File: GridGame.java From burlap with Apache License 2.0 | 4 votes |
@Override public OOSGDomain generateDomain() { OOSGDomain domain = new OOSGDomain(); domain.addStateClass(CLASS_AGENT, GGAgent.class) .addStateClass(CLASS_GOAL, GGGoal.class) .addStateClass(CLASS_DIM_H_WALL, GGWall.GGHorizontalWall.class) .addStateClass(CLASS_DIM_V_WALL, GGWall.GGVerticalWall.class); 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_NOOP)); OODomain.Helper.addPfsToDomain(domain, this.generatePFs()); domain.setJointActionModel(new GridGameStandardMechanics(domain, this.semiWallProb)); return domain; }
Example #19
Source File: GridGame.java From burlap with Apache License 2.0 | 4 votes |
/** * Initializes for a given domain. Defaults rewards to 0 reward everywhere except transition to unviersal or personal goals which return a reward 1. * @param ggDomain the domain */ public GGJointRewardFunction(OODomain ggDomain){ agentInPersonalGoal = ggDomain.propFunction(GridGame.PF_IN_P_GOAL); agentInUniversalGoal = ggDomain.propFunction(GridGame.PF_IN_U_GOAL); }
Example #20
Source File: IRLExample.java From burlap_examples with MIT License | 4 votes |
public LocationFeatures(OODomain domain, int numLocations){ this.numLocations = numLocations; this.inLocationPF = domain.propFunction(GridWorldDomain.PF_AT_LOCATION); }
Example #21
Source File: ListPropFunctions.java From burlap with Apache License 2.0 | 4 votes |
@Override public int call(BurlapShell shell, String argString, Scanner is, PrintStream os) { Environment env = ((EnvironmentShell)shell).getEnv(); OptionSet oset = this.parser.parse(argString.split(" ")); if(oset.has("h")){ os.println("[s]\nCommand to list all true (or false) grounded propositional function for the current environment observation.\n" + "-f: list false grounded propositional functions, rather than true ones. " + "-n: list the name of all propositional functions, rather than grounded evaluations\n" + "-s: evaluate propositional functions on POMDP environment hidden state, rather than environment observation. Environment must extend SimulatedPOEnvironment"); return 0; } if(!(shell.getDomain() instanceof OODomain)){ os.println("cannot query propositional functions because the domain is not an OODomain"); return 0; } if(oset.has("n")){ for(PropositionalFunction pf : ((OODomain)shell.getDomain()).propFunctions()){ os.println(pf.getName()); } return 0; } State qs = env.currentObservation(); if(oset.has("s")){ if(!(env instanceof SimulatedPOEnvironment)){ os.println("Cannot query applicable actions with respect to POMDP hidden state, because the environment does not extend SimulatedPOEnvironment."); return 0; } qs = ((SimulatedPOEnvironment)env).getCurrentHiddenState(); } List<GroundedProp> gps = PropositionalFunction.allGroundingsFromList(((OODomain)shell.getDomain()).propFunctions(), (OOState)qs); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)qs) == !oset.has("f")){ os.println(gp.toString()); } } return 0; }
Example #22
Source File: AddStateObjectCommand.java From burlap with Apache License 2.0 | 4 votes |
public AddStateObjectCommand(Domain domain) { if(domain instanceof OODomain) { this.domain = (OODomain) domain; } }
Example #23
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 #24
Source File: LunarLanderRF.java From burlap with Apache License 2.0 | 3 votes |
/** * Initializes with custom reward condition values. * @param domain a {@link burlap.domain.singleagent.lunarlander.LunarLanderDomain} generated {@link burlap.mdp.core.Domain}. * @param goalReward the reward for landing on the landing pad. * @param collisionReward the reward for a collision. * @param defaultReward the default reward for all other states (i.e., moving through the air) */ public LunarLanderRF(OODomain domain, double goalReward, double collisionReward, double defaultReward){ this(domain); this.goalReward = goalReward; this.collisionReward = collisionReward; this.defaultReward = defaultReward; }
Example #25
Source File: LunarLanderTF.java From burlap with Apache License 2.0 | 2 votes |
/** * Initializes. * @param domain a {@link burlap.domain.singleagent.lunarlander.LunarLanderDomain} generated {@link burlap.mdp.core.Domain} object. */ public LunarLanderTF(OODomain domain){ this.onPad = domain.propFunction(LunarLanderDomain.PF_ON_PAD); }
Example #26
Source File: VisualActionObserver.java From burlap with Apache License 2.0 | 2 votes |
/** * Initializes with a visualizer size of 800x800 * @param domain the {@link OODomain} holding the propositional functions for the propositional function viewer * @param painter the painter for rendering states */ public VisualActionObserver(OODomain domain, Visualizer painter){ this(domain, painter, 800, 800); }