evoga.cpp
594 Logger::error(QString("I cannot open file B%1S%2.G%3.gen").arg(bi+1).arg(this->currentSeed).arg(cgen));
1011 #warning CONTROLLARE INDICE? ALLE VOLTE CRASHA SE NELLA GUI SI SELEZIONA UN INDICE OLTRE IL MASSIMO
1306 float offspringSize = 4.0 + floor(3.0 * log(genLen)); // Floating point number of offspring generated by the individual
1316 const int offSize = (const int)floor(offspringSize); // Number of offspring generated by the individual
1327 Eigen::VectorXf orderedUtility(offSize); // Array containing the ordered utilities (i.e. the best individual has the highest utility value)
1378 Eigen::MatrixXf parents(numStartInd,glen); // To avoid seed dependency, try different parents and choose the best one
1432 tmp = log(offspringSize / 2.0 + 1.0) - log((float)j + 1.0); // Remember that log(0) = -Inf, so 1 is added to index i
1491 // Creating evaluator objects in case of a multithread simulation. Also setting the actual number of threads used
1495 EvoRobotExperiment* newExp = savedConfigurationParameters.getObjectFromGroup<EvoRobotExperiment>(savedExperimentPrefix, false);
1635 // CODE TO PRINT SOME DEBUG INFORMATION (i.e. THE INDIVIDUAL AT THE BEGINNING OF THE EVOLUTIONARY PROCESS)
1702 currOffspring[i] = ind[i]; // This statement might sound strange (I use currOffspring to avoid defining another pointer variable)
1886 // We first evaluate all parents, so setting genotypes of parents (we have as many evaluators as individuals)
1909 offspringFreep[j][i] = evaluators[j]->getExperiment()->getNeuralNetwork()->getFreeParameter(i);
1963 fprintf(bfo, "Best fitness\t%lf\tBack-propagation fitness\t%lf\tOffset\t%lf\n", bestFit, f[offSize - 1], fitOffset);
2271 //always save in order to be able to resume the evolution process, but keep only the last gen file unless it has to be saved by the param savePopulationEachNGenerations
2274 //remove the previous genfile unless it has to be kept because of the savePopulationEachNGenerations param
2275 if ((savePopulationEachNGenerations == 0) || (gn>1 && ((gn-1) % (savePopulationEachNGenerations) != 0))) {
2276 //EX: gn 998 = G999S1.gen --- gn 999 = G1000S1.gen --- gn = 1000 = G1001S1.gen --- gn 1001 = G1002S1.gen
2280 Logger::warning(QString("Error deleting temporary gen file: ") + QString::fromStdString(filename));
2284 Logger::info(QString("Generation %1 took %2 minutes").arg(gn).arg((double)evotimer.elapsed()/60000.0, 0, 'f', 2));
2334 // - if the variation is limited, <offspringStdDev> is increased/decreased by a constant decay value.
2407 // Creating evaluator objects in case of a multithread simulation. Also setting the actual number of threads used
2411 EvoRobotExperiment* newExp = savedConfigurationParameters.getObjectFromGroup<EvoRobotExperiment>(savedExperimentPrefix, false);
2473 // Here we do this to avoid too many complications: if we have to run no threads, we use the old
2524 // We first evaluate all parents, so setting genotypes of parents (we have as many evaluators as individuals)
2582 // Finally, we look for the worst individuals (parents) and substitute them with best children.
2583 // What we do is: we order both the parents and the children in descending order, then we take the
2644 //always save in order to be able to resume the evolution process, but keep only the last gen file unless it has to be saved by the param savePopulationEachNGenerations
2647 //remove the previous genfile unless it has to be kept because of the savePopulationEachNGenerations param
2648 if ((savePopulationEachNGenerations == 0) || (gn>1 && ((gn-1) % (savePopulationEachNGenerations) != 0))) {
2649 //EX: gn 998 = G999S1.gen --- gn 999 = G1000S1.gen --- gn = 1000 = G1001S1.gen --- gn 1001 = G1002S1.gen
2652 Logger::warning(QString("Error deleting temporary gen file: ") + QString::fromStdString(filename));
2656 Logger::info(QString("Generation %1 took %2 minutes - Best fitness = %3").arg(gn+1).arg((double)evotimer.elapsed()/60000.0, 0, 'f', 2).arg(fmax));
2658 Logger::info(QString(" --- Target retention rate: %1; current rate: %2; fitness limitation factor: %3").arg(targetRetentionRate).arg(currentRetentionRate).arg(limitationFactor));
2745 Logger::info(QString("Generation %1 took %2 minutes").arg(gn+1).arg((double)evotimer.elapsed()/60000.0, 0, 'f', 2));
2772 startTime=startTime-randSeed; startTime=startTime-stackMem; startTime=startTime^(stackMem << 8);
2775 startTime=startTime-randSeed; startTime=startTime-stackMem; startTime=startTime^(stackMem << 16);
2778 startTime=startTime-randSeed; startTime=startTime-stackMem; startTime=startTime^(stackMem << 10);
2789 evolutionType = ConfigurationHelper::getString(params, prefix + "evolutionType", "steadyState");
2790 if ( evolutionType != "steadyState" && evolutionType != "generational" && evolutionType != "xnes" && evolutionType != "specializerSteadyState") {
2791 Logger::error( "Evoga - evolutionType has been wrongly setted. It can assume only 'steadyState', 'generational', 'xnes' or 'specializerSteadyState' values" );
2794 nogenerations = ConfigurationHelper::getInt(params, prefix + "ngenerations", 100); //number of generations
2795 nreplications = ConfigurationHelper::getInt(params, prefix + "nreplications", 10); //number of replications
2796 nreproducing = ConfigurationHelper::getInt(params, prefix + "nreproducing", 20); //number of father
2807 savebest = ConfigurationHelper::getInt(params, prefix + "savenbest", 1); //saving best n genotype
2809 numThreads = ConfigurationHelper::getInt(params, prefix + "numThreads", 1); //number of concurrent threads to use
2810 savePopulationEachNGenerations = ConfigurationHelper::getInt(params, prefix + "savePopulationEachNGenerations", 0);
2811 averageIndividualFitnessOverGenerations = ConfigurationHelper::getBool(params, prefix + "averageIndividualFitnessOverGenerations", true);
2815 targetRetentionRate = ConfigurationHelper::getDouble(params, prefix + "targetRetentionRate", false);
2819 modulesMutationRate = ConfigurationHelper::getDouble(params, prefix + "modulesMutationRate", 0.25);
2821 mutateOnlyRelatives = ConfigurationHelper::getBool(params, prefix + "mutateOnlyRelatives", true);
2825 Logger::error( "Evoga - selectionType has been wrongly setted. It can assume only 'rankBased' or 'species' values. 'rankBased' will be used as default value." );
2831 mutation = ConfigurationHelper::getDouble(params, prefix + "mutation_rate", mutation); //mutation rate
2847 mutationLearningRate = ConfigurationHelper::getDouble(params, prefix + "mutationLearningRate", 1.0);
2851 Logger::error( "Evoga - xnesCombinationType has been wrongly setted. It can assume only 0 or 1 values" );
2854 backPropOffspringUtilityRank = ConfigurationHelper::getInt(params, prefix + "backPropOffspringUtilityRank", 255);
2855 backPropOffspringFitnessIncrease = ConfigurationHelper::getBool(params, prefix + "backPropOffspringFitnessIncrease", false);
2856 backPropOffspringFitnessIncreasePercentage = ConfigurationHelper::getDouble(params, prefix + "backPropOffspringFitnessIncreasePercentage", 0.1);
2857 if (backPropOffspringFitnessIncreasePercentage < 0.0 || backPropOffspringFitnessIncreasePercentage > 1.0)
2859 Logger::error( "Evoga - backPropOffspringFitnessIncreasePercentage has been wrongly setted. It must be within the range [0,1] (it is a percentage!!!)" );
2865 debugPrintInfoToFile = ConfigurationHelper::getBool(params, prefix + "debugPrintInfoToFile", false);
2867 dissociateCovMatrix = ConfigurationHelper::getBool(params, prefix + "dissociateCovMatrix", false);
2868 specialUtilityRanking = ConfigurationHelper::getBool(params, prefix + "specialUtilityRanking", false);
2872 Logger::info( "Created EvoRobotExperiment " + params.getValue(prefix+"Experiment/type") + " from group " + prefix + "Experiment" );
2874 // Copying the ConfigurationParameters object and the prefix: we will need them to create new instances of the experiment for
2887 Descriptor d = addTypeDescription( type, "Implements the genetic algorithm developed by Stefano Nolfi" );
2888 d.describeEnum( "evolutionType" ).def("steadyState").values( QStringList() << "steadyState" << "generational" << "xnes" << "specializerSteadyState").props( IsMandatory ).help("Specify the type of evolution process to execute");
2890 d.describeInt( "nreplications" ).def(10).limits(1,MaxInteger).help("The number of which the evolution process will be replicated with a different random initial population");
2891 d.describeInt( "nreproducing" ).def(20).limits(1,MaxInteger).help("The number of individual allowed to produce offsprings; The size of populazion will be nreproducing x noffspring");
2892 d.describeInt( "noffspring" ).def(5).limits(1,MaxInteger).help("The number of offsprings generated by an individual; The size of populazion will be nreproducing x noffspring");
2893 d.describeInt( "seed" ).def(1234).limits(0,MaxInteger).help("The number used to initialize the random number generator; when a new replication will start, this value will be incremented by one to guarantee a truly different initial population for the next replica");
2894 d.describeInt("savenbest").def(1).limits(1,MaxInteger).help("The number of best genotypes to save each generation");
2896 d.describeInt("numThreads").def(1).limits(1,MaxInteger).help("The number of thread used to parallelize the evaluation of individuals");
2897 d.describeInt("savePopulationEachNGenerations").def(0).limits(0,MaxInteger).help("If is zero only the population of the last generation are saved into a file; otherwise it saves the population each N generations done");
2898 d.describeReal("mutation_rate").def(0.05).limits(0,100).help("The mutation rate", "The rate at which a mutation will occur during a genotype copy; a real value below 1 (i.e. 0.12) is considered as a rate (i.e. 0.12 correspond to 12% of mutation); a value egual or above 1 is considered as a percentage of mutation (i.e. 25 correspond to 25% of mutation, or 0.25 rate of mutation)");
2899 d.describeReal("mutation_decay").def(0.01).limits(0,1).help("At first generation the mutation rate will be always 0.5, and at each generation done the mutation rate will be decreased by this value until it reachs the mutation_rate value");
2900 d.describeReal("initial_mutation").def(0.5).limits(0,1).help("The initial value of the mutation rate in case of the steadyState evolution type");
2901 d.describeSubgroup( "Experiment" ).props(IsMandatory).type("EvoRobotExperiment").help("The object delegated to simulate and to evaluate the fitness of an individual");
2902 d.describeBool("averageIndividualFitnessOverGenerations").def(true).help("Whether to average the current fitness with the previous one or not");
2903 d.describeBool("saveRetetionStatistics").def(false).help("Whether to save the retetions statistics or not");
2904 d.describeReal("mutationRange").def(0.0).help("The mutation range used to generate the individual in case of the xnes evolution type");
2905 d.describeReal("offspringMutRange").def(0.0).help("The mutation range used to generate the offspring in case of the xnes evolution type");
2906 d.describeBool("useGaussian").def(false).help("Whether to use a gaussian distribution or not in order to generate offspring in case of the xnes evolution type");
2907 d.describeReal("gaussianMean").def(0.0).help("The mean of the gaussian distribution used to generate both parent and offspring in case of the xnes evolution type");
2908 d.describeReal("gaussianStdDev").def(1.0).help("The standard deviation of the gaussian distribution used to generate parent in case of the xnes evolution type");
2909 d.describeReal("offspringStdDev").def(1.0).help("The standard deviation of the gaussian distribution used to generate offspring in case of the xnes evolution type");
2910 d.describeBool("variableStdDev").def(false).help("Whether the standard deviation of the gaussian distribution used to generate offspring is variable or constant");
2911 d.describeInt("numStartInd").def(1).limits(1,MaxInteger).help("The number of individuals to be tested so to find the starting individual in case of the xnes evolution type");
2912 d.describeReal("mutationLearningRate").def(0.0).help("The learning rate used to generate \"mutated\" offspring in case of the xnes evolution type");
2913 d.describeBool("xnesCombination").def(false).help("Whether to combine xnes with backpropagation algorithm or not");
2914 d.describeInt("xnesCombinationType").def(0).limits(0,MaxInteger).help("Type of combination between xnes and backpropagation algorithms");
2915 d.describeInt("backPropOffspringUtilityRank").def(255).limits(0,MaxInteger).help("The utility rank of the backpropagation algorithm in case of the second type of combination with xnes");
2916 d.describeBool("backPropOffspringFitnessIncrease").def(false).help("Whether to increase the fitness of the backpropagation offspring in case of the second type of combination with xnes");
2917 d.describeReal("backPropOffspringFitnessIncreasePercentage").def(0.1).help("Percentage of increase of the backpropagation offspring fitness value in case of the second type of combination with xnes");
2918 d.describeInt("pheGen").def(0).limits(1,MaxInteger).help("How often the best phenotype must be saved");
2919 d.describeBool("standardNes").def(false).help("Whether to use standard version of xnes or not");
2920 d.describeBool("minimization").def(false).help("Whether the fitness function corresponds to a minimization problem");
2921 d.describeBool("debugPrintInfoToFile").def(false).help("Whether to print debug information to file");
2922 d.describeBool("dissociateInd").def(false).help("Whether to dissociate back-propagation effect on xNES individual update");
2923 d.describeBool("dissociateCovMatrix").def(false).help("Whether to dissociate back-propagation effect on xNES covariance matrix update");
2924 d.describeBool("specialUtilityRanking").def(false).help("Whether to use a special version to compute the utility ranking");
2925 d.describeInt("numModules").def(1).limits(0,MaxInteger).help("The number of modules that will compose the genotype");
2927 d.describeReal("crossoverRate").def(0.05).help("The probability that a crossover will occur in an offspring team");
2928 d.describeReal("modulesMutationRate").def(0.25).help("The probability that a module will be mutated on a team");
2929 d.describeBool("mutateOnlyRelatives").def(true).help("Wheater a module should be replace by its own offsprings or by any offspring");
2930 d.describeReal("overwriteRate").def(0.05).help("The learning rate used to generate \"mutated\" offsprings in case of the xnes evolution type");
2931 d.describeBool("limitRetention").def(false).help("Wheater the retention should be limited or not");
2932 d.describeReal("targetRetentionRate").def(0.2).help("The rate in which retention should be limited");
2933 d.describeBool("saveRetetionStatistics").def(false).help("Whether to save the retetions statistics or not");
2934 d.describeEnum( "selectionType" ).def("rankBased").values( QStringList() << "rankBased" << "species").props( IsMandatory ).help("Specify the type of selection that will be used to define which individuals will survive");
2935 d.describeReal("rankBasedProbability").def(0.75).help("The probability that the individuals with high fitness will be selected");
3031 Logger::error( QString("Evoga - request to execute a unrecognized evolution type: %1").arg(evolutionType) );
3219 // Creating evaluator objects in case of a multithread simulation. Also setting the actual number of threads used
3223 EvoRobotExperiment* newExp = savedConfigurationParameters.getObjectFromGroup<EvoRobotExperiment>(savedExperimentPrefix, false);
3275 //test the actual team of individuals - this should be done first of all so it is done in a monothread mode
3282 exp->doAllTrialsForIndividual(-1); //-1 means that the team will be tested without any substitution
3296 evaluators[i]->getExperiment()->m_weightIndividual[i] = allIndividuals[offspring+popSize]; //change the individual i by the offspring being tested
3314 exp->m_weightIndividual[i] = allIndividuals[offspring+popSize]; //change the individual i by the offspring being tested
3315 exp->doAllTrialsForIndividual(i); //the individual passed as parameter (i) is the substituted individual
3332 Logger::info(QString("Changing the policy %1 by the policy %2 produces a fitness of: %3 (original is %4)").arg(i).arg(offspring+popSize).arg(subsFitness[i]).arg(initFit));
3337 Logger::info(QString("Substituting the policy %1 by the policy %2, and increasing the fitness by %3").arg(indMax).arg(offspring+popSize).arg(maxFit-initFit));
3342 Logger::info(QString("Policy %1 won't be used because it presents no performance improvement.").arg(offspring+popSize));
3371 //always save in order to be able to resume the evolution process, but keep only the last gen file unless it has to be saved by the param savePopulationEachNGenerations
3374 //remove the previous genfile unless it has to be kept because of the savePopulationEachNGenerations param
3375 if ((savePopulationEachNGenerations == 0) || (gn>1 && ((gn-1) % (savePopulationEachNGenerations) != 0))) {
3376 //EX: gn 998 = G999S1.gen --- gn 999 = G1000S1.gen --- gn = 1000 = G1001S1.gen --- gn 1001 = G1002S1.gen
3379 Logger::warning(QString("Error deleting temporary gen file: ") + QString::fromStdString(filename));
3383 Logger::info(QString("Generation %1 took %2 minutes").arg(gn+1).arg((double)evotimer.elapsed()/60000.0, 0, 'f', 2));
3385 Logger::info(QString(" --- Target retention rate: %1; current rate: %2; fitness limitation factor: %3").arg(targetRetentionRate).arg(currentRetentionRate).arg(limitationFactor));
3439 // Creating evaluator objects in case of a multithread simulation. Also setting the actual number of threads used
3443 EvoRobotExperiment* newExp = savedConfigurationParameters.getObjectFromGroup<EvoRobotExperiment>(savedExperimentPrefix, false);
3586 if(mutateOnlyRelatives) //if yes, check if it should be substituted by its offspring, or any offspring
3603 if(!flagModificated) //if the offspring is equal to the parent, repeat the process for this offspring
3615 evaluators[i]->getExperiment()->m_weightIndividual.resize(composedGen[idOffspring].size());//for the case where teams can have different sizes
3616 for(int j=0;j<composedGen[idOffspring].size();j++) //setting the weights of the team i to the evaluator
3617 evaluators[i]->getExperiment()->m_weightIndividual[j] = allIndividuals[composedGen[idOffspring][j]];
3632 childrenFitness[i].fitness = allTeamsFitness[idOffspring].fitness = evaluators[i]->getFitness();
3669 for(int i=totalTeams-1;i>0;i--){ //now start with the teams with higher fitness - and proceed until numTeams were selected
3671 if((rand()%100)/100.0<rankBasedProb){//select the teams with greatest fitness with a probability defined by the user
3682 Logger::info(QString("i=%3 id=%1; fitness=%2").arg(allTeamsFitness[i].id).arg(allTeamsFitness[i].fitness).arg(i));
3684 }else if(selectionType=="species"){ //substitute the parent by its offspring with the best fitness
3686 Logger::info(QString("i=%3 id=%1; fitness=%2").arg(allTeamsFitness[i].id).arg(allTeamsFitness[i].fitness).arg(i));
3688 for(int offspring=0;offspring<noffspring;offspring++){ //check each offspring team and select it if its fitness is greater than actual selected one
3690 Logger::info(QString("Offsprings =======>i=%3 id=%1; fitness=%2").arg(allTeamsFitness[idOffspring].id).arg(allTeamsFitness[idOffspring].fitness).arg(idOffspring));
3691 if(selectedTeamFitness[i].fitness<allTeamsFitness[idOffspring].fitness){ //if some of its offspring has a better fitness, select it
3709 if(selectedTeamFitness[i].id>=numTeams) //if the id is greater than the number of teams, it means that a parent was replaced
3712 }else{ //if there were no sufficient individuals in the selected team vector, get individuals from the teams with higher fitness that weren't selected
3714 if(allTeamsFitness[ind].id==selectedTeamFitness[i].id){ //if this team is already selected pick the next one and restart the check to see if the next is already selected or not
3723 for(int j=0;j<numModules;j++){ //since the individuals that participates in the teams with the better fitness value will be selected, it will be necessary to change(translate) their id
3781 //always save in order to be able to resume the evolution process, but keep only the last gen file unless it has to be saved by the param savePopulationEachNGenerations
3787 //remove the previous genfile unless it has to be kept because of the savePopulationEachNGenerations param
3788 if ((savePopulationEachNGenerations == 0) || (gn>1 && ((gn-1) % (savePopulationEachNGenerations) != 0))) {
3789 //EX: gn 998 = G999S1.gen --- gn 999 = G1000S1.gen --- gn = 1000 = G1001S1.gen --- gn 1001 = G1002S1.gen
3792 Logger::warning(QString("Error deleting temporary gen file: ") + QString::fromStdString(filename));
3797 Logger::warning(QString("Error deleting temporary gen file: ") + QString::fromStdString(filename));
3802 Logger::warning(QString("Error deleting temporary gen file: ") + QString::fromStdString(filename));
3806 Logger::info(QString("Generation %1 took %2 minutes - best individual fitness %3").arg(gn+1).arg((double)evotimer.elapsed()/60000.0, 0, 'f', 2).arg(fmax));
3808 Logger::info(QString(" --- Target retention rate: %1; current rate: %2; fitness limitation factor: %3").arg(targetRetentionRate).arg(currentRetentionRate).arg(limitationFactor));
bool useGaussian
Flag to decide whether using gaussian distribution to generate offspring.
Definition: evoga.h:789
void usableResources(QStringList resources)
int getGenotypeId() const
Returns the id of the genotype used in this experiment.
Definition: evoga.cpp:202
void mreproduce()
Identify the best individuals and copy their genotypes into the bestgenome Matrix It also save the be...
Definition: evoga.cpp:617
float getFreeParameter(int i)
return the value of the ith parameter (normalized in the range [-wrange, wrange]
Definition: evonet.cpp:1075
QVector< int * > m_weightIndividual
Added by Jonata for the SpecializerSteadyState GA.
Definition: evorobotexperiment.h:467
bool minimization
Flags whether the fitness function is set to solve a minimization problem.
Definition: evoga.h:817
virtual void setCurrentMutationRate(double mutation_rate)
Set the current mutation rate to use.
Definition: evoga.cpp:3114
virtual QString generationFilename()
Returns the template name (regular expression) for "generation" files.
Definition: evoga.cpp:3165
QString savedExperimentPrefix
A copy of the prefix for experiment parameters.
Definition: evoga.h:869
int * getGenes(int ind)
Return a pointer to the genome of one individual of the current population.
Definition: evoga.cpp:1008
QString evolutionType
specify the type of the evolution process to execute This string can only assume two values at the mo...
Definition: evoga.h:725
void recoveredInterruptedEvolution(QString statfile)
emitted when an interrupted evolution has been recovered and it's going to start from there ...
void getLastFStat(double &min, double &max, double &average)
return the last value of min, max and average fitness
Definition: evoga.cpp:853
FARSA_UTIL_API RandomGenerator * globalRNG
virtual void setNetParameters(float *genes)
Sets the free parameters of the neural network. This is done for all agents, even disabled ones...
Definition: evorobotexperiment.cpp:516
static QString getString(ConfigurationParameters ¶ms, QString paramPath, QString def=QString())
double * tfitness
A pointer to a vector used to store the sum of the fitness obtained during different evaluations of a...
Definition: evoga.h:714
virtual double getCurrentMutationRate()
Returns the current mutation rate.
Definition: evoga.cpp:3110
bool dissociateCovMatrix
Flags whether to dissociate back-propagation effect on the xNES covariance matrix update...
Definition: evoga.h:823
virtual void save(ConfigurationParameters ¶ms, QString prefix)
Save the actual status of parameters into the ConfigurationParameters object passed.
Definition: evoga.cpp:2880
double mutation
The mutation rate can vary from 0 to 1 continuosly to express probability in the range [0...
Definition: evoga.h:735
virtual void initGeneration(int generation)
Called at the beginning of a generation. This function is NEVER called concurrently on different obje...
Definition: evorobotexperiment.cpp:296
bool mutateOnlyRelatives
Wheater a module should be replace by its own offspring or by any offspring – specializerSteadyState...
Definition: evoga.h:840
float getWrange()
return the value of wrange (which also determine the range in which all parameters are normalized) ...
Definition: evonet.cpp:1162
void doAllTrialsForIndividual(int individual)
Performs all trials for the given individual.
Definition: evorobotexperiment.cpp:242
double modulesMutationRate
The probability that a module will be mutated on a team – specializerSteadyState.
Definition: evoga.h:837
bool isStopped()
return true if the evolution process has been stopped with stop()
Definition: evoga.cpp:3050
void evolveSteadyState()
Main function of the Genetic Algorithm (Steady State Version) Each individual of the population is al...
Definition: evoga.cpp:2382
double ** statfit
A matrix that store the statistics (average, min, and max fitness) for all generations.
Definition: evoga.h:718
virtual int * getGenesForIndividual(unsigned int id)
Returns the array of genes for the given individual.
Definition: evoga.cpp:3135
void evolveSpecializerSteadyState2()
Main function of the Genetic Algorithm developed by Jonata - Team Version.
Definition: evoga.cpp:3405
void evolveGenerational()
Main function of the Genetic Algorithm (Generational, Truncation Selection Version) The size of the p...
Definition: evoga.cpp:2676
int nogenerations
The number of generations specified with the ngenerations parameter.
Definition: evoga.h:727
void saveRStat(QVector< int > subsVec)
Save the information regarding the offspring retention by appending a line to the retention statistic...
Definition: evoga.cpp:832
void copyPheParameters(int *pheGene)
transorm floating point parameters normalized in the range [-wrange,range] into integer parameters in...
Definition: evonet.cpp:1120
int getGenotypeId() const
Returns the id of the genotype used in this experiment.
Definition: evoga.cpp:95
void reproduce()
Identify the best individuals and copy their genotypes into the bestgenome Matrix It also save the be...
Definition: evoga.cpp:471
void saveFStat()
Save the average, minimal and maximal fitness by appending a line to the statSd.fit file...
Definition: evoga.cpp:815
void printPop()
Print the fitness of the individuals of the current population.
Definition: evoga.cpp:684
int savePopulationEachNGenerations
How often (i.e. how many generations) we want to same the population genome in a .gen file.
Definition: evoga.h:767
int numStartInd
Number of possible individuals from which finding out the starting individual of XNES.
Definition: evoga.h:799
virtual unsigned int getCurrentGeneration()
Returns the current generation.
Definition: evoga.cpp:3086
void setEvoga(Evoga *ga)
Set the Evoga on which this EvoRobotExperiment is used.
Definition: evorobotexperiment.cpp:505
FARSA_UTIL_TEMPLATE const T max(const T &t1, const U &t2)
void evolveSpecializerSteadyState()
Main function of the Genetic Algorithm developed by Jonata.
Definition: evoga.cpp:3187
QString selectionType
The type of selection that will be used to define which individuals will survive. ...
Definition: evoga.h:846
void updateGenomeFromEvonet(int ind)
update the genome of the individual to match the current weights of Evonet
Definition: evoga.cpp:1050
int pheGen
How often (in terms of number of generations) the best phenotype must be saved.
Definition: evoga.h:813
virtual void shareResourcesWith(ResourcesUser *buddy)
double mutationdecay
The amount of reduction of the mutation generations during the first generations until it reaches the...
Definition: evoga.h:739
ConfigurationParameters savedConfigurationParameters
A copy of the ConfigurationParameters object that was passed to our configure method.
Definition: evoga.h:862
double offspringMutRange
The mutation range used in XNES algorithm to generate the offspring.
Definition: evoga.h:787
void setGenotype(int id)
Configures the experiment with the given genotype id.
Definition: evoga.cpp:84
int backPropOffspringUtilityRank
The utility rank of the backpropagation offspring in the second type of combination with xNES...
Definition: evoga.h:807
double initial_mutation
The initial mutation rate setted when steadyState algorithm is used.
Definition: evoga.h:741
static const int MAXINDIVIDUALS
constant defining the maximimum number of individuals that Evoga can manage
Definition: evoga.h:73
void putGenome(int fromgenome, int tobestgenome)
Copy the genome of one individual to the bestgenome matrix in a specific position.
Definition: evoga.cpp:429
void saveBestTeam(QVector< QVector< int > > teams, QVector< double > fitness)
Append the best team of the current population to the BdSd.composed.gen file.
Definition: evoga.cpp:577
this is an helper class for implementing multithread in Evoga
Definition: evoga.cpp:55
void setSeed(int seed)
double mutationRange
The mutation range used in XNES algorithm to initialize the individual.
Definition: evoga.h:785
static bool getBool(ConfigurationParameters ¶ms, QString paramPath, bool def=false)
void setGenotype(int id, float *genes)
Configures the experiment with the given genotype id.
Definition: evoga.cpp:191
int mrand(int i)
return a random integer generated with an uniform distribution in the range [0, i-1] ...
Definition: evoga.cpp:308
double crossRate
The probability that a crossover will occur in an offspring team – specializerSteadyState.
Definition: evoga.h:834
void doNextStep()
Go ahead of one step if the EvoGa is in step-by-step modality, otherwise do nothing.
Definition: evoga.cpp:3070
static void info(QString msg)
bool commitStep()
this method marks the point on which it is called as a commited step of evolution ...
Definition: evoga.cpp:3040
static void error(QString msg)
virtual unsigned int numLoadedGenotypes() const
Returns number of loaded genotypes.
Definition: evoga.cpp:3130
bool hasResource(QString name) const
double mutationLearningRate
The mutation learning rate used to generate offspring from backprop array.
Definition: evoga.h:801
void enableStepByStep(bool enable)
enable/disable the step-by-step modality of evolution process
Definition: evoga.cpp:3058
bool xnesCombination
Flag to decide whether combining xnes with backpropagation algorithm.
Definition: evoga.h:803
Evonet * getNeuralNetwork(int agentId=0)
Return the neural network used for the experiment.
Definition: evorobotexperiment.cpp:500
int mutate(int w, double mut)
Mutate one gene Since genes are store as integer, this function first trasform them into 8 bits and t...
Definition: evoga.cpp:399
Definition: evodataviewer.h:41
static void describe(QString type)
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Definition: evoga.cpp:2886
virtual QString statisticsFilename(unsigned int seed)
Returns the name of the file with statistics (fitness) for the given seed.
Definition: evoga.cpp:3145
A simple structure keeping a fitness value and the id of a genotype.
Definition: evoga.cpp:287
bool pheFileLoaded()
check whether a .phe file (with parameters description) has been loaded
Definition: evonet.cpp:1080
void getPheParametersAndMutationsFromEvonet()
transfer .phe info inside GA
Definition: evoga.cpp:1026
int seed
The number used to initialized the seed of the first replication (successive replication use incremen...
Definition: evoga.h:731
virtual QVector< EvoRobotExperiment * > getEvoRobotExperimentPool()
Returns a list of pointers to the EvoRobotExperiment objects used by the ga to evaluate agents...
Definition: evoga.cpp:3079
void getMutations(float *mut)
set the mutation vector of the genetic algorithm that determine how parameters are mutated ...
Definition: evonet.cpp:1112
int * getBestGenes(int ind)
Return a pointer to the genome of one individual stored in the bestgenome matrix. ...
Definition: evoga.cpp:1016
virtual void configure(ConfigurationParameters ¶ms, QString prefix)
Configures the object using a ConfigurationParameters object.
Definition: evoga.cpp:2784
virtual void endGeneration(int generation)
Called at the end of a generation. This function is NEVER called concurrently on different objects...
Definition: evorobotexperiment.cpp:349
static double getDouble(ConfigurationParameters ¶ms, QString paramPath, double def=0)
virtual QString retentionsFilename(unsigned int seed)
Returns the name of the file with statistics (retentions) for the given seed.
Definition: evoga.cpp:3175
static Descriptor addTypeDescription(QString type, QString shortHelp, QString longHelp=QString(""))
QString getValue(QString path, bool alsoMatchParents=false) const
QWaitCondition waitForNextStep
the wait condition for waiting on step-by-step modality
Definition: evoga.h:763
void saveallgComposed(QVector< QVector< int > > composedGen)
Save the composed genome of the current population in a G?S?.composed.gen file.
Definition: evoga.cpp:792
virtual unsigned int getNumOfGenerations()
Returns the number of generations to do.
Definition: evoga.cpp:3106
bool specialUtilityRanking
Flags whether to use a special version to compute utility ranking.
Definition: evoga.h:825
this is an helper class for implementing multithread in xNES
Definition: evoga.cpp:161
virtual unsigned int loadGenotypes(QString filename)
Loads genotypes from the given file.
Definition: evoga.cpp:3118
int nreplications
The number of replications specified with the corresponding parameter.
Definition: evoga.h:729
double * ntfitness
A pointer to a vector used to store the total number of trials in which an unchanged individuals have...
Definition: evoga.h:716
void copyGenes(int from, int to, int mut)
Copy the genotype of an individual into the genotype of a second individual and introduce mutations T...
Definition: evoga.cpp:455
double rankBasedProb
The probability that the individuals with the highest fitness will be selected.
Definition: evoga.h:843
int currentSeed
The seed of the current generation (used for example to generate the name of the G?S?.gen files)
Definition: evoga.h:733
void newGASeed(int seed)
Called by the ga when the seed changes (e.g. in a new replication)
Definition: evorobotexperiment.cpp:670
TypeToCreate * getObjectFromGroup(QString group, bool configure=true, bool forceObjectCreation=false)
bool dissociateInd
Flags whether to dissociate back-propagation effect on the xNES individual update.
Definition: evoga.h:821
float backPropOffspringFitnessIncreasePercentage
Percentage of increase of the fitness of the backpropagation offspring.
Definition: evoga.h:811
void computeFStat2()
Calculate the average, minimal and maximal fitness of the current population Assume that the fitness ...
Definition: evoga.cpp:732
QMutex mutexStepByStep
the mutex used for controlling the step-by-step modality
Definition: evoga.h:761
double limitationFactor
The limitation factor that will multiply the offsprings' fitness.
Definition: evoga.h:854
int rouletteWheel(QVector< double > candidates)
perform a roulette wheel and return the winner's index
Definition: evoga.cpp:3829
double * terror
A pointer to a vector used to store the sum of the errors obtained during different evaluations of an...
Definition: evoga.h:720
virtual QString bestsFilename()
Returns the template name (regular expression) for "best genomes" files.
Definition: evoga.cpp:3155
void save_net_blocks(const char *filename, int mode)
Save the description of the neural architecture into a .net of .phe file (see the create_net_block me...
Definition: evonet.cpp:658
double drand()
return a random floating point value generated with an uniform distribution in the range[0...
Definition: evoga.cpp:383
Population bestgenome
The matrix that contains a copy of the genome of the best individuals.
Definition: evoga.h:708
virtual void doNotUseMultipleThreads()
Forces execution of the GA using no threads (i.e., in the current thread)
Definition: evoga.cpp:3170
bool standardNes
Flags whether the standard xNES algorithm must be used (i.e. the parameters are set according to the ...
Definition: evoga.h:815
void startingReplication(int replication)
emitted when a replication is going to start
double getGaussian(double var, double mean=0.0)
static const int MaxInteger
FARSA_UTIL_TEMPLATE const T min(const T &t1, const U &t2)
bool isEnabledStepByStep()
return true is the step-by-step modality is enabled, false otherwise
Definition: evoga.cpp:3066
void getGenome(int frombestgenome, int togenome, int mut)
Copy a genome stored in the bestgenome matrix into the genome of the current population Apply mutatio...
Definition: evoga.cpp:440
void setInitialPopulation(int *)
Overwrite the genome of all individuals with a manually specify vector of parameters (loaded from a ...
Definition: evoga.cpp:986
void loadgenotype(FILE *fp, int ind)
Load the genome of one individual in a text file.
Definition: evoga.cpp:859
Population genome
The matrix that contain the genome of the corrent population.
Definition: evoga.h:706
virtual EvoRobotExperiment * getEvoRobotExperiment()
Returns a pointer to the EvoRobotExperiment object.
Definition: evoga.cpp:3074
void saveagenotype(FILE *fp, int ind)
Save the genome of one individual in a text file.
Definition: evoga.cpp:763
bool averageIndividualFitnessOverGenerations
Whether to average an individual fitness with its previous one or not.
Definition: evoga.h:782
double getDouble(double min, double max)
void xnes()
Main function of the xNES Algorithm (exponential Natural Evolution Strategies) The size of the popula...
Definition: evoga.cpp:1299
virtual void postConfigureInitialization()
This function is called after all linked objects have been configured.
Definition: evoga.cpp:2938
static int getInt(ConfigurationParameters ¶ms, QString paramPath, int def=0)
double overwriteRate
The probability that a module will be overwritten by another one – specializerSteadyState.
Definition: evoga.h:849
int loadedIndividuals
The number of individual genome loaded from a .gen file into the genome matrix (-1 when none has been...
Definition: evoga.h:712
void saveallg()
Save the genome of the current population in a G?S?.gen file.
Definition: evoga.cpp:773
void computeFStat()
Calculate the average, minimal and maximal fitness of the current population Assume that the fitness ...
Definition: evoga.cpp:706
bool debugPrintInfoToFile
Flags whether to print debug information about the xNES algorithm to file.
Definition: evoga.h:819
void saveBestInd()
Append the genome of the best individual of the current population to the BdSd.gen file...
Definition: evoga.cpp:537
The base common class that evaluate the fitness of a robot.
Definition: evorobotexperiment.h:155
void endGeneration(int generation, double fmax, double faverage, double fmin)
emitted when a generation is ended
void printBest()
Print the fitness of the best individuals of the current population.
Definition: evoga.cpp:695
bool variableStdDev
Flags whether the standard deviation to generate offspring is constant or not.
Definition: evoga.h:797
virtual void evolveAllReplicas()
Evolves all replications of the ga process.
Definition: evoga.cpp:3016
static void warning(QString msg)
bool backPropOffspringFitnessIncrease
Flag whether to increase the fitness of the backpropagation offspring.
Definition: evoga.h:809
int loadallg(int gen, const char *filew)
Load the genome of the population from a file.
Definition: evoga.cpp:872
virtual unsigned int getNumReplications()
Returns the number of replications.
Definition: evoga.cpp:3101
IsMandatory
int xnesCombinationType
The type of combination between xnes and backpropagation algorithms.
Definition: evoga.h:805
int loadStatistics(char *filename)
Load the fitness statistics from a .fit file Return the number of loaded individuals (0 if the file d...
Definition: evoga.cpp:954
void loadallTeams(int gen, const char *filew, QVector< QVector< int > > &teams)
Load the teams of the population from a file.
Definition: evoga.cpp:907
static const float DEFAULT_VALUE
DEFAULT_VALUE is used for do not assign values to mut and parameters.
Definition: evonet.h:137