本文整理汇总了Java中burlap.behavior.singleagent.auxiliary.StateReachability.getReachableStates方法的典型用法代码示例。如果您正苦于以下问题:Java StateReachability.getReachableStates方法的具体用法?Java StateReachability.getReachableStates怎么用?Java StateReachability.getReachableStates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类burlap.behavior.singleagent.auxiliary.StateReachability
的用法示例。
在下文中一共展示了StateReachability.getReachableStates方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCommand
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
MinecraftDomainGenerator mdg = new MinecraftDomainGenerator();
SADomain domain = mdg.generateDomain();
State in = MinecraftStateGeneratorHelper.getCurrentState(BurlapCraft.currentDungeon);
List<State> reachable = StateReachability.getReachableStates(in, domain, new SimpleHashableStateFactory());
for(State s : reachable){
OOState os = (OOState)s;
BCAgent a = (BCAgent)os.object(CLASS_AGENT);
System.out.println(a.x + ", " + a.y + ", " + a.z + ", " + a.rdir + ", "+ a.vdir + ", " + a.selected);
}
System.out.println(reachable.size());
}
示例2: visualizeValueFunction
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
public static void visualizeValueFunction(QComputablePlanner planner, Policy p, State initialState, Domain domain, StateHashFactory hashingFactory) {
List<State> allStates = StateReachability.getReachableStates(initialState,
(SADomain) domain, hashingFactory);
LandmarkColorBlendInterpolation rb = new LandmarkColorBlendInterpolation();
rb.addNextLandMark(0., Color.RED);
rb.addNextLandMark(1., Color.BLUE);
StateValuePainter2D svp = new StateValuePainter2D(rb);
svp.setValueStringRenderingFormat(8, Color.WHITE, 2, 0.0f, 0.8f);
svp.setXYAttByObjectClass(GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTX,
GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTY);
PolicyGlyphPainter2D spp = new PolicyGlyphPainter2D();
spp.setXYAttByObjectClass(GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTX,
GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTY);
spp.setActionNameGlyphPainter(GridWorldDomain.ACTIONNORTH, new ArrowActionGlyph(0));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTIONSOUTH, new ArrowActionGlyph(1));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTIONEAST, new ArrowActionGlyph(2));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTIONWEST, new ArrowActionGlyph(3));
spp.setRenderStyle(PolicyGlyphPainter2D.PolicyGlyphRenderStyle.DISTSCALED);
ValueFunctionVisualizerGUI gui = new ValueFunctionVisualizerGUI(allStates, svp, planner);
gui.setSpp(spp);
gui.setPolicy(p);
gui.setBgColor(Color.GRAY);
gui.initGUI();
}
示例3: simpleValueFunctionVis
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
public void simpleValueFunctionVis(ValueFunction valueFunction, Policy p,
State initialState, Domain domain, HashableStateFactory hashingFactory, String title){
List<State> allStates = StateReachability.getReachableStates(initialState,
(SADomain)domain, hashingFactory);
ValueFunctionVisualizerGUI gui = GridWorldDomain.getGridWorldValueFunctionVisualization(
allStates, valueFunction, p);
gui.setTitle(title);
gui.initGUI();
}
示例4: manualValueFunctionVis
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
public void manualValueFunctionVis(ValueFunction valueFunction, Policy p){
List<State> allStates = StateReachability.getReachableStates(initialState, (SADomain)domain, hashingFactory);
//define color function
LandmarkColorBlendInterpolation rb = new LandmarkColorBlendInterpolation();
rb.addNextLandMark(0., Color.RED);
rb.addNextLandMark(1., Color.BLUE);
//define a 2D painter of state values, specifying which attributes correspond to the x and y coordinates of the canvas
StateValuePainter2D svp = new StateValuePainter2D(rb);
svp.setXYAttByObjectClass(GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTX,
GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTY);
//create our ValueFunctionVisualizer that paints for all states
//using the ValueFunction source and the state value painter we defined
ValueFunctionVisualizerGUI gui = new ValueFunctionVisualizerGUI(allStates, svp, valueFunction);
//define a policy painter that uses arrow glyphs for each of the grid world actions
PolicyGlyphPainter2D spp = new PolicyGlyphPainter2D();
spp.setXYAttByObjectClass(GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTX,
GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTY);
spp.setActionNameGlyphPainter(GridWorldDomain.ACTIONNORTH, new ArrowActionGlyph(0));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTIONSOUTH, new ArrowActionGlyph(1));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTIONEAST, new ArrowActionGlyph(2));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTIONWEST, new ArrowActionGlyph(3));
spp.setRenderStyle(PolicyGlyphPainter2D.PolicyGlyphRenderStyle.DISTSCALED);
//add our policy renderer to it
gui.setSpp(spp);
gui.setPolicy(p);
//set the background color for places where states are not rendered to grey
gui.setBgColor(Color.GRAY);
//start it
gui.initGUI();
}
示例5: RandomStartStateGenerator
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
/**
* Will discover the reachable states from which to randomly select. Reachable states found using a {@link burlap.oomdp.statehashing.SimpleHashableStateFactory} with identifier dependence.
* @param domain the domain from which states will be drawn.
* @param seedState the seed state from which the reachable states will be found.
*/
public RandomStartStateGenerator(SADomain domain, State seedState) {
HashableStateFactory hashFactory = new SimpleHashableStateFactory(false);
this.reachableStates = StateReachability.getReachableStates(seedState, domain, hashFactory);
this.random = new Random();
}
示例6: manualValueFunctionVis
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
public void manualValueFunctionVis(ValueFunction valueFunction, Policy p) {
List<State> allStates = StateReachability.getReachableStates(
initialState, domain, hashingFactory);
//define color function
LandmarkColorBlendInterpolation rb = new LandmarkColorBlendInterpolation();
rb.addNextLandMark(0., Color.RED);
rb.addNextLandMark(1., Color.BLUE);
//define a 2D painter of state values,
//specifying which attributes correspond to the x and y coordinates of the canvas
StateValuePainter2D svp = new StateValuePainter2D(rb);
svp.setXYKeys("x", "y",
new VariableDomain(0, 11), new VariableDomain(0, 11),
1, 1);
//create our ValueFunctionVisualizer that paints for all states
//using the ValueFunction source and the state value painter we defined
ValueFunctionVisualizerGUI gui = new ValueFunctionVisualizerGUI(
allStates, svp, valueFunction);
//define a policy painter that uses arrow glyphs for each of the grid world actions
PolicyGlyphPainter2D spp = new PolicyGlyphPainter2D();
spp.setXYKeys("x", "y", new VariableDomain(0, 11),
new VariableDomain(0, 11),
1, 1);
spp.setActionNameGlyphPainter(GridWorldDomain.ACTION_NORTH, new ArrowActionGlyph(0));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTION_SOUTH, new ArrowActionGlyph(1));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTION_EAST, new ArrowActionGlyph(2));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTION_WEST, new ArrowActionGlyph(3));
spp.setRenderStyle(PolicyGlyphPainter2D.PolicyGlyphRenderStyle.DISTSCALED);
//add our policy renderer to it
gui.setSpp(spp);
gui.setPolicy(p);
//set the background color for places where states are not rendered to grey
gui.setBgColor(Color.GRAY);
//start it
gui.initGUI();
}
示例7: runIRL
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
/**
* Runs MLIRL on the trajectories stored in the "irlDemo" directory and then visualizes the learned reward function.
*/
public void runIRL(String pathToEpisodes){
//create reward function features to use
LocationFeatures features = new LocationFeatures(this.domain, 5);
//create a reward function that is linear with respect to those features and has small random
//parameter values to start
LinearStateDifferentiableRF rf = new LinearStateDifferentiableRF(features, 5);
for(int i = 0; i < rf.numParameters(); i++){
rf.setParameter(i, RandomFactory.getMapped(0).nextDouble()*0.2 - 0.1);
}
//load our saved demonstrations from disk
List<Episode> episodes = Episode.readEpisodes(pathToEpisodes);
//use either DifferentiableVI or DifferentiableSparseSampling for planning. The latter enables receding horizon IRL,
//but you will probably want to use a fairly large horizon for this kind of reward function.
double beta = 10;
//DifferentiableVI dplanner = new DifferentiableVI(this.domain, rf, 0.99, beta, new SimpleHashableStateFactory(), 0.01, 100);
DifferentiableSparseSampling dplanner = new DifferentiableSparseSampling(this.domain, rf, 0.99, new SimpleHashableStateFactory(), 10, -1, beta);
dplanner.toggleDebugPrinting(false);
//define the IRL problem
MLIRLRequest request = new MLIRLRequest(domain, dplanner, episodes, rf);
request.setBoltzmannBeta(beta);
//run MLIRL on it
MLIRL irl = new MLIRL(request, 0.1, 0.1, 10);
irl.performIRL();
//get all states in the domain so we can visualize the learned reward function for them
List<State> allStates = StateReachability.getReachableStates(basicState(), this.domain, new SimpleHashableStateFactory());
//get a standard grid world value function visualizer, but give it StateRewardFunctionValue which returns the
//reward value received upon reaching each state which will thereby let us render the reward function that is
//learned rather than the value function for it.
ValueFunctionVisualizerGUI gui = GridWorldDomain.getGridWorldValueFunctionVisualization(
allStates,
5,
5,
new RewardValueProjection(rf),
new GreedyQPolicy((QProvider) request.getPlanner())
);
gui.initGUI();
}
示例8: manualValueFunctionVis
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
public void manualValueFunctionVis(ValueFunction valueFunction, Policy p){
List<State> allStates = StateReachability.getReachableStates(initialState, domain, hashingFactory);
//define color function
LandmarkColorBlendInterpolation rb = new LandmarkColorBlendInterpolation();
rb.addNextLandMark(0., Color.RED);
rb.addNextLandMark(1., Color.BLUE);
//define a 2D painter of state values, specifying which attributes correspond to the x and y coordinates of the canvas
StateValuePainter2D svp = new StateValuePainter2D(rb);
svp.setXYKeys("agent:x", "agent:y", new VariableDomain(0, 11), new VariableDomain(0, 11), 1, 1);
//create our ValueFunctionVisualizer that paints for all states
//using the ValueFunction source and the state value painter we defined
ValueFunctionVisualizerGUI gui = new ValueFunctionVisualizerGUI(allStates, svp, valueFunction);
//define a policy painter that uses arrow glyphs for each of the grid world actions
PolicyGlyphPainter2D spp = new PolicyGlyphPainter2D();
spp.setXYKeys("agent:x", "agent:y", new VariableDomain(0, 11), new VariableDomain(0, 11), 1, 1);
spp.setActionNameGlyphPainter(GridWorldDomain.ACTION_NORTH, new ArrowActionGlyph(0));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTION_SOUTH, new ArrowActionGlyph(1));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTION_EAST, new ArrowActionGlyph(2));
spp.setActionNameGlyphPainter(GridWorldDomain.ACTION_WEST, new ArrowActionGlyph(3));
spp.setRenderStyle(PolicyGlyphPainter2D.PolicyGlyphRenderStyle.DISTSCALED);
//add our policy renderer to it
gui.setSpp(spp);
gui.setPolicy(p);
//set the background color for places where states are not rendered to grey
gui.setBgColor(Color.GRAY);
//start it
gui.initGUI();
}
示例9: RandomStartStateGenerator
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
/**
* Will discover the reachable states from which to randomly select. Reachable states found using a {@link SimpleHashableStateFactory} with identifier dependence.
* @param domain the domain from which states will be drawn.
* @param seedState the seed state from which the reachable states will be found.
*/
public RandomStartStateGenerator(SADomain domain, State seedState) {
HashableStateFactory hashFactory = new SimpleHashableStateFactory(false);
this.reachableStates = StateReachability.getReachableStates(seedState, domain, hashFactory);
this.random = new Random();
}
示例10: simpleValueFunctionVis
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
public void simpleValueFunctionVis(ValueFunction valueFunction, Policy p){
List<State> allStates = StateReachability.getReachableStates(initialState, (SADomain)domain, hashingFactory);
ValueFunctionVisualizerGUI gui = GridWorldDomain.getGridWorldValueFunctionVisualization(allStates, valueFunction, p);
gui.initGUI();
}
示例11: simpleValueFunctionVis
import burlap.behavior.singleagent.auxiliary.StateReachability; //导入方法依赖的package包/类
public void simpleValueFunctionVis(ValueFunction valueFunction, Policy p){
List<State> allStates = StateReachability.getReachableStates(initialState, domain, hashingFactory);
ValueFunctionVisualizerGUI gui = GridWorldDomain.getGridWorldValueFunctionVisualization(allStates, 11, 11, valueFunction, p);
gui.initGUI();
}