burlap.mdp.core.oo.propositional.GroundedProp Java Examples
The following examples show how to use
burlap.mdp.core.oo.propositional.GroundedProp.
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: PFFeatures.java From burlap with Apache License 2.0 | 6 votes |
@Override public double[] features(State s) { List<Double> featureValueList = new LinkedList<Double>(); for(PropositionalFunction pf : this.pfsToUse){ //List<GroundedProp> gps = s.getAllGroundedPropsFor(pf); List<GroundedProp> gps = pf.allGroundings((OOState)s); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)s)){ featureValueList.add(1.); } else{ featureValueList.add(0.); } } } double [] fv = new double[featureValueList.size()]; int i = 0; for(double f : featureValueList){ fv[i] = f; i++; } return fv; }
Example #3
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 #4
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 #5
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 #6
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 #7
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 #8
Source File: IRLExample.java From burlap_examples with MIT License | 5 votes |
protected int getActiveLocationVal(OOState s){ List<GroundedProp> gps = this.inLocationPF.allGroundings(s); for(GroundedProp gp : gps){ if(gp.isTrue(s)){ GridLocation l = (GridLocation)s.object(gp.params[1]); return l.type; } } return -1; }
Example #9
Source File: CommandCheckProps.java From burlapcraft with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args) { MinecraftDomainGenerator mdg = new MinecraftDomainGenerator(); OOSADomain domain = mdg.generateDomain(); boolean printFalse = false; if(args.length > 0){ if(args[0].equals("+not")){ printFalse = true; } } State s = MinecraftStateGeneratorHelper.getCurrentState(BurlapCraft.currentDungeon); List<GroundedProp> gps = PropositionalFunction.allGroundingsFromList(domain.propFunctions(), (OOState)s); StringBuffer buf = new StringBuffer(); buf.append("\n"); for(GroundedProp gp : gps){ if(!gp.isTrue((OOState)s)){ if(printFalse) { buf.append("NOT "); buf.append(gp.toString()); buf.append("\n"); } } else{ buf.append(gp.toString()); buf.append("\n"); } } sender.addChatMessage(new ChatComponentText(buf.toString())); }
Example #10
Source File: SinglePFSCT.java From burlap with Apache License 2.0 | 5 votes |
@Override public boolean satisfies(State s) { //List<GroundedProp> gps = s.getAllGroundedPropsFor(pf); List<GroundedProp> gps = this.pf.allGroundings((OOState)s); for(GroundedProp gp : gps){ if(gp.isTrue((OOState)s)){ return true; } } return false; }
Example #11
Source File: TestGridWorld.java From burlap with Apache License 2.0 | 5 votes |
public void assertPFs(State s, boolean[] expectedValues) { OOState os = (OOState)s; PropositionalFunction atLocation = domain.propFunction(GridWorldDomain.PF_AT_LOCATION); List<GroundedProp> gpAt = atLocation.allGroundings(os); Assert.assertEquals(1, gpAt.size()); Assert.assertEquals(expectedValues[0], gpAt.get(0).isTrue((OOState)s)); PropositionalFunction pfWallNorth = domain.propFunction(GridWorldDomain.PF_WALL_NORTH); List<GroundedProp> gpWallNorth = pfWallNorth.allGroundings(os); Assert.assertEquals(1, gpWallNorth.size()); Assert.assertEquals(expectedValues[1], gpWallNorth.get(0).isTrue((OOState)s)); PropositionalFunction pfWallSouth = domain.propFunction(GridWorldDomain.PF_WALL_SOUTH); List<GroundedProp> gpWallSouth = pfWallSouth.allGroundings(os); Assert.assertEquals(1, gpWallSouth.size()); Assert.assertEquals(expectedValues[2], gpWallSouth.get(0).isTrue((OOState)s)); PropositionalFunction pfWallEast = domain.propFunction(GridWorldDomain.PF_WALL_EAST); List<GroundedProp> gpWallEast = pfWallEast.allGroundings(os); Assert.assertEquals(1, gpWallEast.size()); Assert.assertEquals(expectedValues[3], gpWallEast.get(0).isTrue((OOState)s)); PropositionalFunction pfWallWest = domain.propFunction(GridWorldDomain.PF_WALL_WEST); List<GroundedProp> gpWallWest = pfWallWest.allGroundings(os); Assert.assertEquals(1, gpWallWest.size()); Assert.assertEquals(expectedValues[4], gpWallWest.get(0).isTrue((OOState)s)); }
Example #12
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; }