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


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

本文整理汇总了C++中UndirectedGraph::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ UndirectedGraph::copy方法的具体用法?C++ UndirectedGraph::copy怎么用?C++ UndirectedGraph::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UndirectedGraph的用法示例。


在下文中一共展示了UndirectedGraph::copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........

                if ((!(card_counter == cardb)) || (!(trial_counter == 1))) {
                    reset_pheromone_trail();
                    for (list<KCT_Ant*>::iterator ant = ants.begin(); ant != ants.end(); ant++) {
                        (*ant)->restart_reset();
                    }
                }

                int iter = 1;
                double cf = 0.0;
                bool restart = false;
                bool program_stop = false;
                bool bs_update = false;

                while (program_stop == false) {

                    for (list<KCT_Ant*>::iterator ant = ants.begin(); ant != ants.end(); ant++) {
                        for (k = 0; k < cardinality; k++) {
                            (*ant)->step(0.8);
                        }
                        (*ant)->evaluate();
                    }

                    if (!(newSol == NULL)) {
                        delete(newSol);
                    }
                    if (elite_action == "no") {
                        newSol = getBestDaemonSolutionInIteration();
                    }
                    else {
                        KCT_Ant* bestAnt = getBestDaemonAntInIteration();
                        bestAnt->eliteAction();
                        newSol = new UndirectedGraph();
                        newSol->copy(bestAnt->getCurrentDaemonSolution());
                    }

                    if (iter == 1) {
                        best = new UndirectedGraph();
                        printf("best %f\ttime %f\n",newSol->weight(),timer.elapsed_time(Timer::VIRTUAL));
                        best->copy(newSol);
                        restartBest = new UndirectedGraph(newSol);
                        results.push_back(newSol->weight());
                        times_best_found.push_back(timer.elapsed_time(Timer::VIRTUAL));
                        if (trial_counter == 1) {
                            biar = newSol->weight();
                        }
                        else {
                            if (newSol->weight() < biar) {
                                biar = newSol->weight();
                            }
                        }
                    }
                    else {
                        if (restart) {
                            restart = false;
                            restartBest->copy(newSol);
                            if (newSol->weight() < best->weight()) {
                                printf("best %f\ttime %f\n",newSol->weight(),timer.elapsed_time(Timer::VIRTUAL));
                                best->copy(newSol);
                                results[trial_counter-1] = newSol->weight();
                                times_best_found[trial_counter-1] = timer.elapsed_time(Timer::VIRTUAL);
                                if (newSol->weight() < biar) {
                                    biar = newSol->weight();
                                }
                            }
                        }
开发者ID:contaconta,项目名称:neurons,代码行数:67,代码来源:aco_kct.cpp


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