00001 #include "SIGEL_GP/SIG_GPTournament.h" 00002 00003 SIGEL_GP::SIG_GPTournament::SIG_GPTournament(SIGEL_Tools::SIG_Randomizer& randomizer, 00004 SIG_GPFitnessTrainer& trainer, 00005 SIG_GPPopulation& actPool, 00006 SIG_GPParameter& gpParameter, 00007 SIGEL_Robot::SIG_LanguageParameters &languageP) 00008 :gpPool(actPool), 00009 trainer(trainer), 00010 indis(), 00011 justWaiting(false), 00012 depNumber(0), 00013 gpParameter(gpParameter), 00014 randomizer(randomizer), 00015 languageP(languageP) 00016 { 00017 indis.setAutoDelete( true ); 00018 }; 00019 00020 SIGEL_GP::SIG_GPTournament::~SIG_GPTournament() 00021 { }; 00022 00023 bool SIGEL_GP::SIG_GPTournament::run() 00024 { }; 00025 00026 void SIGEL_GP::SIG_GPTournament::inhume( SIG_GPIndividual &corps ) 00027 { 00028 if (gpParameter.getLiveUndead()) 00029 { 00030 QDir graveYardDir = gpParameter.getGraveYardDirectory(); 00031 00032 QString corpsFileName = graveYardDir.path() 00033 + QString( "/" ) 00034 + QString( "Individual_" ) 00035 + corps.getName() 00036 + QString( "_Fitness_" ) 00037 + QString::number( corps.getFitness() ) 00038 + ".ind"; 00039 00040 #ifdef SIG_DEBUG 00041 SIGEL_Tools::SIG_IO::cerr << "SIG_GPTournament saving dead Individual " 00042 << corps.getName() 00043 << "\n"; 00044 #endif 00045 00046 QFile corpsFile( corpsFileName ); 00047 00048 if (corpsFile.open( IO_WriteOnly )) 00049 { 00050 QTextStream buffer( &corpsFile ); 00051 corps.writeToFile( buffer ); 00052 corpsFile.close(); 00053 } 00054 else 00055 SIGEL_Tools::SIG_IO::cerr << "Could not save corps under " 00056 << corpsFileName 00057 << "!\n"; 00058 }; 00059 }; 00060