void FireflyOptimizator::run() { optmized = false; beta = 1.0; ranks.clear(); ranks.resize(population.size()); markers.clear(); markers.resize(population.size()); vector<Segmentation>::iterator ffI; int idx_ffI =0; for (gen = 1; gen <= MaxGenerations; gen++) { cout<<">>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<"<<endl; cout<<"GENERATION "<<gen<<endl; cout<< "Starting generation. Updating population "; startClock(); startGeneration(); endClock(); cout << " - end ( "<< elapsed_secs<< " sec )" << endl; for( ffI = population.begin(),idx_ffI=0; ffI != population.end(); idx_ffI++,ffI++) { startClock(); computeFirefly(*ffI,idx_ffI); endClock(); cout << " - end ( "<< elapsed_secs<< " sec )" << endl; } cout<< "Generation done. Updating population "; startClock(); updateGeneration(); endClock(); cout<< " - OK "<<" ( "<< elapsed_secs << " sec )" << endl;; finishGeneration(); } cout<<"Final result "<<(generationBest.end()-1)->second<<endl; optmized = true; }
gameW::gameW(QWidget *parent) : QWidget(parent), mapSize(60), timer(new QTimer(this)) { timer->setInterval(100); currentGeneration = new bool[mapSize * mapSize]; nextGeneration = new bool[mapSize * mapSize]; for(int i = 0; i < mapSize * mapSize; i++) { currentGeneration[i] = false; nextGeneration[i] = false; } connect(timer, SIGNAL(timeout()), this, SLOT(updateGeneration())); connect(this, SIGNAL(changeBtn(const char*)), parent, SLOT(changeBtnText(const char*))); }