本文整理汇总了Java中burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling.setValueForLeafNodes方法的典型用法代码示例。如果您正苦于以下问题:Java SparseSampling.setValueForLeafNodes方法的具体用法?Java SparseSampling.setValueForLeafNodes怎么用?Java SparseSampling.setValueForLeafNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类burlap.behavior.singleagent.planning.stochastic.sparsesampling.SparseSampling
的用法示例。
在下文中一共展示了SparseSampling.setValueForLeafNodes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
示例4: 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;
}
示例5: 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);
}
示例6: 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);
}