本文整理汇总了C++中Ensemble::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ Ensemble::assign方法的具体用法?C++ Ensemble::assign怎么用?C++ Ensemble::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ensemble
的用法示例。
在下文中一共展示了Ensemble::assign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_one_state
void EnsembleGenerator::add_one_state(const Ensemble& init_ensemble,
Ensemble& new_ensemble) {
std::priority_queue<boost::tuple<double, int, int>,
Vector<boost::tuple<double, int, int> >,
Comparator> bestK;
// iterate over all init MultiStateModels and try to add a new state to each
for(unsigned int i=0; i<init_ensemble.size(); i++) {
unsigned int first_to_search = init_ensemble[i].get_last_state()+1;
if(first_to_search<N_) {
if(i>0 && i%100==0 && !bestK.empty()) {
double curr_bestK_score = boost::get<0>(bestK.top());
std::cout << "Extending ensemble: " << i << " out of "
<< init_ensemble.size() << " last best "
<< curr_bestK_score << std::endl;
}
MultiStateModel new_model(init_ensemble[i]);
new_model.add_state(first_to_search);
// try all possible additions of a new state
for(unsigned int j=first_to_search; j<N_; j++) {
new_model.replace_last_state(j);
double curr_score = get_score(new_model);
if(curr_score < 0.0) continue; // invalid model
// add to bestK
if(bestK.size() <= K_ || curr_score < boost::get<0>(bestK.top())) {
bestK.push(boost::make_tuple(curr_score, i, j));
if(bestK.size() > K_) bestK.pop();
}
}
}
}
// save best scoring
new_ensemble.assign(bestK.size(), MultiStateModel(0));
int index = bestK.size()-1;
// generate bestK new MultiStateModels
while(!bestK.empty()) {
double score;
int ensemble_index, new_state_index;
boost::tie(score, ensemble_index, new_state_index) = bestK.top();
MultiStateModel new_model(init_ensemble[ensemble_index]);
new_model.add_state(new_state_index);
new_model.set_score(score);
new_ensemble[index] = new_model;
index--;
bestK.pop();
}
}