bool NetworkPNL::AddArc(int nodeFrom, int nodeTo) { MarkCallFunction("AddArc", true); Graph().AddArc(nodeFrom, nodeTo); std::vector<int> parents; GetParents(nodeTo, parents); Distributions().Setup(nodeTo); m_aNodeValueStatus[nodeTo] = NetConst::NotUpdated; return true; }
bool GenAlgo::Run(const int func_no) { int nPopu, totGen, indx_f = 0, //Index of one parent. indx_m = 0; //Index of another parent. bool rslt; func_num = func_no; /*INPUT PARAMETERS FROM USER*/ rslt = InputParams(); totGen = nGEN; Fitness_Calculations = 0; //Setting the fittness calculations count to 0. /*INITIALIZE THE 0TH GEN POPULATION*/ Initialize(); Fitness_Calculations += nPOPU; do { CHILDREN child1, child2; //This are used to store the children temporaryly nPopu = nPOPU; //ShowPopu(); if (Fitness_Calculations > MaxFitness_Calculations) break; //Maximum number of fittness calculations has occured. while ((nPopu -= 2) >= 0) { /*allocation memory*/ child1.fChromo = new char[lenChromo_tot]; child2.fChromo = new char[lenChromo_tot]; child1.fFitness = child2.fFitness = NULL; /*SELECT PARENTS*/ GetParents(&indx_f, &indx_m); /*DO CROSSOVER*/ CreateChildren(child1, child2, &indx_f, &indx_m); /*MUTATES THE CHILDREN*/ MutateChildren(child1); MutateChildren(child2); /*CALCULATE FITNESS OF OFFSPRINGS*/ child1.fFitness = CalculateFitness(child1); child2.fFitness = CalculateFitness(child2); Fitness_Calculations += 2; /*IDENTIFY GOOD CHILDS AND STORE THEM*/ IdentifyChilds(child1, child2, indx_f, indx_m, nPOPU - nPopu - 2); /*cleaning up*/ indx_f = indx_m; delete[] child1.fChromo; delete[] child2.fChromo; child1.fFitness = child2.fFitness = NULL; } /*UPDATE NEW GEN POPULATION*/ CopyPopulation(nGEN - totGen); std::cout << "\nGen no :: " << nGEN - totGen << std::endl; std::cout << "**************" << std::endl; ShowDude(); } while (--totGen); ShowStatistics(); ShowDude(); return true; }