当前位置: 首页>>代码示例>>C++>>正文


C++ UndirectedGraph::Write2File方法代码示例

本文整理汇总了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;
}
开发者ID:contaconta,项目名称:neurons,代码行数:101,代码来源:aco_kct.cpp


注:本文中的UndirectedGraph::Write2File方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。