本文整理汇总了C++中VNode::Free方法的典型用法代码示例。如果您正苦于以下问题:C++ VNode::Free方法的具体用法?C++ VNode::Free怎么用?C++ VNode::Free使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VNode
的用法示例。
在下文中一共展示了VNode::Free方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckDESPOTSTAR
double DESPOT::CheckDESPOTSTAR(const VNode* vnode, double regularized_value) {
cout
<< "--------------------------------------------------------------------------------"
<< endl;
const vector<State*>& particles = vnode->particles();
vector<State*> copy;
for (int i = 0; i < particles.size(); i++) {
copy.push_back(model_->Copy(particles[i]));
}
VNode* root = new VNode(copy);
RandomStreams streams = RandomStreams(Globals::config.num_scenarios,
Globals::config.search_depth);
InitBounds(root, lower_bound_, upper_bound_, streams, history_);
double used_time = 0;
int num_trials = 0;
do {
double start = clock();
VNode* cur = Trial(root, streams, lower_bound_, upper_bound_, model_, history_);
num_trials++;
used_time += double(clock() - start) / CLOCKS_PER_SEC;
start = clock();
Backup(cur);
used_time += double(clock() - start) / CLOCKS_PER_SEC;
} while (root->lower_bound() < regularized_value);
cout << "DESPOT: # trials = " << num_trials << "; target = "
<< regularized_value << ", current = " << root->lower_bound()
<< ", l = " << root->lower_bound() << ", u = " << root->upper_bound()
<< "; time = " << used_time << endl;
cout
<< "--------------------------------------------------------------------------------"
<< endl;
root->Free(*model_);
delete root;
return used_time;
}
示例2: CheckDESPOT
double DESPOT::CheckDESPOT(const VNode* vnode, double regularized_value) {
cout
<< "--------------------------------------------------------------------------------"
<< endl;
const vector<State*>& particles = vnode->particles();
vector<State*> copy;
for (int i = 0; i < particles.size(); i ++) {
copy.push_back(model_->Copy(particles[i]));
}
VNode* root = new VNode(copy);
double pruning_constant = Globals::config.pruning_constant;
Globals::config.pruning_constant = 0;
RandomStreams streams = RandomStreams(Globals::config.num_scenarios,
Globals::config.search_depth);
streams.position(0);
InitBounds(root, lower_bound_, upper_bound_, streams, history_);
double used_time = 0;
int num_trials = 0, prev_num = 0;
double pruned_value;
do {
double start = clock();
VNode* cur = Trial(root, streams, lower_bound_, upper_bound_, model_, history_);
num_trials++;
used_time += double(clock() - start) / CLOCKS_PER_SEC;
start = clock();
Backup(cur);
used_time += double(clock() - start) / CLOCKS_PER_SEC;
if (double(num_trials - prev_num) > 0.05 * prev_num) {
int pruned_action;
Globals::config.pruning_constant = pruning_constant;
VNode* pruned = Prune(root, pruned_action, pruned_value);
Globals::config.pruning_constant = 0;
prev_num = num_trials;
pruned->Free(*model_);
delete pruned;
cout << "# trials = " << num_trials << "; target = "
<< regularized_value << ", current = " << pruned_value
<< ", l = " << root->lower_bound() << ", u = "
<< root->upper_bound() << "; time = " << used_time << endl;
if (pruned_value >= regularized_value) {
break;
}
}
} while (true);
cout << "DESPOT: # trials = " << num_trials << "; target = "
<< regularized_value << ", current = " << pruned_value << ", l = "
<< root->lower_bound() << ", u = " << root->upper_bound() << "; time = "
<< used_time << endl;
Globals::config.pruning_constant = pruning_constant;
cout
<< "--------------------------------------------------------------------------------"
<< endl;
root->Free(*model_);
delete root;
return used_time;
}