本文整理汇总了C++中Population::compute_statistics方法的典型用法代码示例。如果您正苦于以下问题:C++ Population::compute_statistics方法的具体用法?C++ Population::compute_statistics怎么用?C++ Population::compute_statistics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population
的用法示例。
在下文中一共展示了Population::compute_statistics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: single_run
//.........这里部分代码省略.........
// sort according to fitness (error)
//P->sort(i,tree_comp_fitness);
///printf("\n\n***********Generation %d after genetic operations (not sorted, new trees marked with f9.999999E+99)************\n", i-1);
//P->print_population_without_parameters(i-1);
//printf("\n***********************************************************************\n");
// update the best individual - structure and complete tree (for PARAMETER INHERITANCE)
//P->update_ext_archive();
//---------------------------------------------------------------------------------------------
// sort according to F
// VITAL! Both populations must be sorted, trees[] and complete_trees[]...
P->sort(i,tree_comp_F);
///printf("\n\n***********Generation %d after genetic operations (not sorted, new trees marked with f9.999999E+99)************\n", i-1);
///P->print_population_without_parameters(i-1);
///printf("\n***********************************************************************\n");
// update the best individual - structure and complete tree (for PARAMETER INHERITANCE)
P->update_ext_archive();
// compute elapsed time
elapsed_time = (int)(P->compute_time(start, finish, &delta_t));
if (VERBOSE) {
// print elapsed time
cout << "Elapsed time: " << elapsed_time << " sec"; //total seconds
// print out the best member - population WITHOUT parameters
P->print_population_without_parameters(i);
// print out the best member - population WITH parameters
P->print_population_with_parameters(i);
}
// compute statistical data relating to population (vital if data is shared through populations)
// IT's REALLY IMPORTANT that this function is executed after evaluate and sort,
// as evaluate uses statistical data referring to the previous generation
P->compute_statistics();
// evaluate termination condition
check_end=P->terminate(p_parameters->threshold);
last_gen = i;
// for the split data set, re-tune and re-evaluate the individuals on the merged data set
if (p_parameters->split) {
if ((check_end) || (i==p_parameters->G)) {
cout << "\nBest Individual re-tuning and re-evaluation on the whole dataset" << endl;
P->split_data(p_parameters, p_problem,last_gen,last_gen);
P->evaluate(i,p_parameters->G);
}
}
// PRINT TO FILE OPERATIONS (in case of crash, data is saved) -------------------------
// print to file (if termination criterion met, it closes the stream of data to file )
pop_reporter.stats2file(p_parameters, P, DIR_RUN_K, i, check_end);
// write the test-points (training set), and the corresponding values of g_obj and the best individual (only one)
pop_reporter.points2file(p_parameters, p_problem, P, DIR_RUN_K, i, check_end, start, finish, delta_t,SEED[cur_run]);
// write best individual's expression ATTENZIONE: cambiato il 7/4/2015... da verificare
pop_reporter.update_best2file_build(P, DIR_RUN_K, i, check_end); //old function: update_best2file(P, DIR_RUN_K, i, check_end);
// update the list of the best-so-far individuals (see elite or archive) - truncation! ATTENZIONE: cambiato il 7/4/2015... da verificare
pop_reporter.archive2file_build(P, DIR_RUN_K, i, check_end); //old function: objective_table2file(P, DIR_RUN_K, i, check_end);
// update no of tree evaluations
pop_reporter.n_tree_eval2file(P, DIR_RUN_K, i, check_end);
// -------------------------------------------------------------------------------------
if (check_end)
break;
}
# pragma omp critical
{
cout << "Elapsed time to complete run " << cur_run+1 << ": " << elapsed_time << " sec" << endl; //total seconds
//termination criterion satisfied
if (check_end) {
cout << "Termination criterion satisfied (RMSE < " << p_parameters->threshold << ")." << endl;
cout << "Possible solution: " << endl;
P->print_population_with_parameters(last_gen);
cout << "Check latest_archive.txt for solutions\n" << endl;
}
else {
P->print_population_with_parameters(last_gen);
}
}
// just for test
//P->get_tree_derivative_given_norm_vector(problem, P->complete_trees[0]);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// write node statistics to file
pop_reporter.node_stats2file(p_parameters, P, DIR_RUN_K);
// end - free memory allocated to Population
delete P;
}