本文整理汇总了Java中burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling.toggleDebugPrinting方法的典型用法代码示例。如果您正苦于以下问题:Java SparseSampling.toggleDebugPrinting方法的具体用法?Java SparseSampling.toggleDebugPrinting怎么用?Java SparseSampling.toggleDebugPrinting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling
的用法示例。
在下文中一共展示了SparseSampling.toggleDebugPrinting方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IPSS
import burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling; //导入方法依赖的package包/类
public static void IPSS(){
InvertedPendulum ip = new InvertedPendulum();
ip.physParams.actionNoise = 0.;
Domain domain = ip.generateDomain();
RewardFunction rf = new InvertedPendulum.InvertedPendulumRewardFunction(Math.PI/8.);
TerminalFunction tf = new InvertedPendulum.InvertedPendulumTerminalFunction(Math.PI/8.);
State initialState = InvertedPendulum.getInitialState(domain);
SparseSampling ss = new SparseSampling(domain, rf, tf, 1, new SimpleHashableStateFactory(), 10 ,1);
ss.setForgetPreviousPlanResults(true);
ss.toggleDebugPrinting(false);
Policy p = new GreedyQPolicy(ss);
EpisodeAnalysis ea = p.evaluateBehavior(initialState, rf, tf, 500);
System.out.println("Num steps: " + ea.maxTimeStep());
Visualizer v = InvertedPendulumVisualizer.getInvertedPendulumVisualizer();
new EpisodeSequenceVisualizer(v, domain, Arrays.asList(ea));
}
示例2: IPSS
import burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling; //导入方法依赖的package包/类
public static void IPSS(){
InvertedPendulum ip = new InvertedPendulum();
ip.physParams.actionNoise = 0.;
RewardFunction rf = new InvertedPendulum.InvertedPendulumRewardFunction(Math.PI/8.);
TerminalFunction tf = new InvertedPendulum.InvertedPendulumTerminalFunction(Math.PI/8.);
ip.setRf(rf);
ip.setTf(tf);
SADomain domain = ip.generateDomain();
State initialState = new InvertedPendulumState();
SparseSampling ss = new SparseSampling(domain, 1, new SimpleHashableStateFactory(), 10, 1);
ss.setForgetPreviousPlanResults(true);
ss.toggleDebugPrinting(false);
Policy p = new GreedyQPolicy(ss);
Episode e = PolicyUtils.rollout(p, initialState, domain.getModel(), 500);
System.out.println("Num steps: " + e.maxTimeStep());
Visualizer v = CartPoleVisualizer.getCartPoleVisualizer();
new EpisodeSequenceVisualizer(v, domain, Arrays.asList(e));
}
示例3: runIteration
import burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling; //导入方法依赖的package包/类
/**
* Runs a single iteration of value iteration. Note that if the state samples have not been set, it will throw a runtime exception.
* @return the maximum change in the value function.
*/
public double runIteration(){
if(this.samples == null){
throw new RuntimeException("FittedVI cannot run value iteration because the state samples have not been set. Use the setSamples method or the constructor to set them.");
}
SparseSampling ss = new SparseSampling(this.domain, this.rf, this.tf, this.gamma, this.hashingFactory, this.planningDepth, this.transitionSamples);
ss.setValueForLeafNodes(this.leafNodeInit);
ss.toggleDebugPrinting(false);
List <SupervisedVFA.SupervisedVFAInstance> instances = new ArrayList<SupervisedVFA.SupervisedVFAInstance>(this.samples.size());
List <Double> oldVs = new ArrayList<Double>(this.samples.size());
for(State s : this.samples){
oldVs.add(this.valueFunction.value(s));
instances.add(new SupervisedVFA.SupervisedVFAInstance(s, QFunctionHelper.getOptimalValue(ss, s)));
}
this.valueFunction = this.valueFunctionTrainer.train(instances);
double maxDiff = 0.;
for(int i = 0; i < this.samples.size(); i++){
double newV = this.valueFunction.value(this.samples.get(i));
double diff = Math.abs(newV - oldVs.get(i));
maxDiff = Math.max(maxDiff, diff);
}
return maxDiff;
}
示例4: getQs
import burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling; //导入方法依赖的package包/类
@Override
public List<QValue> getQs(State s) {
SparseSampling ss = new SparseSampling(this.domain, this.rf, this.tf, this.gamma, this.hashingFactory, this.controlDepth, this.transitionSamples);
ss.setValueForLeafNodes(this.leafNodeInit);
ss.toggleDebugPrinting(false);
return ss.getQs(s);
}
示例5: getQ
import burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling; //导入方法依赖的package包/类
@Override
public QValue getQ(State s, AbstractGroundedAction a) {
SparseSampling ss = new SparseSampling(this.domain, this.rf, this.tf, this.gamma, this.hashingFactory, this.controlDepth, this.transitionSamples);
ss.setValueForLeafNodes(this.leafNodeInit);
ss.toggleDebugPrinting(false);
return ss.getQ(s, a);
}
示例6: runIteration
import burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling; //导入方法依赖的package包/类
/**
* Runs a single iteration of value iteration. Note that if the state samples have not been set, it will throw a runtime exception.
* @return the maximum change in the value function.
*/
public double runIteration(){
if(this.samples == null){
throw new RuntimeException("FittedVI cannot run value iteration because the state samples have not been set. Use the setSamples method or the constructor to set them.");
}
SparseSampling ss = new SparseSampling(this.domain, this.gamma, this.hashingFactory, this.planningDepth, this.transitionSamples);
ss.setModel(this.model);
ss.setValueForLeafNodes(this.leafNodeInit);
ss.toggleDebugPrinting(false);
List <SupervisedVFA.SupervisedVFAInstance> instances = new ArrayList<SupervisedVFA.SupervisedVFAInstance>(this.samples.size());
List <Double> oldVs = new ArrayList<Double>(this.samples.size());
for(State s : this.samples){
oldVs.add(this.valueFunction.value(s));
instances.add(new SupervisedVFA.SupervisedVFAInstance(s, Helper.maxQ(ss, s)));
}
this.valueFunction = this.valueFunctionTrainer.train(instances);
double maxDiff = 0.;
for(int i = 0; i < this.samples.size(); i++){
double newV = this.valueFunction.value(this.samples.get(i));
double diff = Math.abs(newV - oldVs.get(i));
maxDiff = Math.max(maxDiff, diff);
}
return maxDiff;
}
示例7: qValues
import burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling; //导入方法依赖的package包/类
@Override
public List<QValue> qValues(State s) {
SparseSampling ss = new SparseSampling(this.domain, this.gamma, this.hashingFactory, this.controlDepth, this.transitionSamples);
ss.setModel(model);
ss.setValueForLeafNodes(this.leafNodeInit);
ss.toggleDebugPrinting(false);
return ss.qValues(s);
}
示例8: qValue
import burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling; //导入方法依赖的package包/类
@Override
public double qValue(State s, Action a) {
SparseSampling ss = new SparseSampling(this.domain, this.gamma, this.hashingFactory, this.controlDepth, this.transitionSamples);
ss.setModel(model);
ss.setValueForLeafNodes(this.leafNodeInit);
ss.toggleDebugPrinting(false);
return ss.qValue(s, a);
}