本文整理汇总了C++中UndirectedGraph::Write2File方法的典型用法代码示例。如果您正苦于以下问题:C++ UndirectedGraph::Write2File方法的具体用法?C++ UndirectedGraph::Write2File怎么用?C++ UndirectedGraph::Write2File使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UndirectedGraph
的用法示例。
在下文中一共展示了UndirectedGraph::Write2File方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
}
for (list<Edge*>::iterator e = (graph->edges).begin(); e != (graph->edges).end(); e++) {
(*pheromone)[*e] = (*pheromone)[*e] + (l_rate * ((*new_pd)[*e] - (*pheromone)[*e]));
if ((*pheromone)[*e] > tau_max) {
(*pheromone)[*e] = tau_max;
}
if ((*pheromone)[*e] < tau_min) {
(*pheromone)[*e] = tau_min;
}
}
delete(trans_best);
delete(trans_newSol);
delete(trans_restartBest);
delete(new_pd);
}
for (list<KCT_Ant*>::iterator i = ants.begin(); i != ants.end(); i++) {
(*i)->reset();
}
iter = iter + 1;
if (tfile_is_given) {
if (timer.elapsed_time(Timer::VIRTUAL) > time_limit) {
program_stop = true;
}
}
else {
if (time_limit_given && iter_limit_given) {
if ((timer.elapsed_time(Timer::VIRTUAL) > time_limit) || (iter > n_of_iter)) {
program_stop = true;
}
}
else {
if (time_limit_given) {
if (timer.elapsed_time(Timer::VIRTUAL) > time_limit) {
program_stop = true;
}
}
else {
if (iter > n_of_iter) {
program_stop = true;
}
}
}
}
}
printf("end try %d\n",trial_counter);
// eturetken 18.09.09. Write the best MST for this cardinality to the file.
////////////////////////////////////////////////////////////////////
if( mstfile_is_given )
{
string MSTFile(mst_file);
best->Write2File(concatIntToString(MSTFile, card_counter) + ".mst");
}
////////////////////////////////////////////////////////////////////
delete(best);
delete(restartBest);
delete(newSol);
}
double r_mean = 0.0;
double t_mean = 0.0;
for (int i = 0; i < results.size(); i++) {
r_mean = r_mean + results[i];
t_mean = t_mean + times_best_found[i];
}
r_mean = r_mean / ((double)results.size());
t_mean = t_mean / ((double)times_best_found.size());
double rsd = 0.0;
double tsd = 0.0;
for (int i = 0; i < results.size(); i++) {
rsd = rsd + pow(results[i]-r_mean,2.0);
tsd = tsd + pow(times_best_found[i]-t_mean,2.0);
}
rsd = rsd / ((double)(results.size()-1.0));
if (rsd > 0.0) {
rsd = sqrt(rsd);
}
tsd = tsd / ((double)(times_best_found.size()-1.0));
if (tsd > 0.0) {
tsd = sqrt(tsd);
}
if (output_file_given == true) {
fout << cardinality << "\t" << r_mean << "\t" << rsd << "\t" << t_mean << "\t" << tsd << endl;
}
else {
printf("statistics\t%d\t%g\t%f\t%f\t%f\t%f\n",cardinality,biar,r_mean,rsd,t_mean,tsd);
}
printf("end cardinality %d\n",cardinality);
}
}
if (output_file_given == true) {
fout.close();
}
delete(graph);
delete rnd;
}