Genetic algorithm from evorobot more or less (spare parts) More...

Inheritance diagram for Evoga:

Classes

class  Population
 A class modelling a population of genomes.

Public Slots

void doNextStep ()
 Go ahead of one step if the EvoGa is in step-by-step modality, otherwise do nothing.
void enableStepByStep (bool enable)
 enable/disable the step-by-step modality of evolution process

Signals

void endGeneration (int generation, double fmax, double faverage, double fmin)
 emitted when a generation is ended
void finished ()
 emitted when the evolution has been finished or stopped
void recoveredInterruptedEvolution (QString statfile)
 emitted when an interrupted evolution has been recovered and it's going to start from there
void startingReplication (int replication)
 emitted when a replication is going to start

Public Member Functions

 Evoga ()
 Constructor.
 ~Evoga ()
 Destructor.
virtual QString bestsFilename (unsigned int seed)
 Returns the name of the file with the best genomes for the given seed.
virtual QString bestsFilename ()
 Returns the template name (regular expression) for "best genomes" files.
bool commitStep ()
 this method marks the point on which it is called as a commited step of evolution
void computeFStat ()
 Calculate the average, minimal and maximal fitness of the current population Assume that the fitness is always positive.
void computeFStat2 ()
 Calculate the average, minimal and maximal fitness of the current population Assume that the fitness can also be negative.
virtual void configure (ConfigurationParameters &params, QString prefix)
 Configures the object using a ConfigurationParameters object.
void copyGenes (int from, int to, int mut)
 Copy the genotype of an individual into the genotype of a second individual and introduce mutations This function is used by the steadystate genetic algorithm to store the child in the genome matrix at position population+1 and eventually to use the genome of the child to overwrite the genome of the worst individual or discarded.
virtual unsigned int currentGeneration ()
 Returns the current generation.
virtual void doNotUseMultipleThreads ()
 Forces execution of the GA using no threads (i.e., in the current thread)
double drand ()
 return a random floating point value generated with an uniform distribution in the range[0.0, 1.0]
virtual void evolveAllReplicas ()
 Evolves all replications of the ga process.
void evolveGenerational ()
 Main function of the Genetic Algorithm (Generational, Truncation Selection Version) The size of the population is set equal to nreproducing*noffspring Each individual is allowed to generate a variable number of offspring (noffspring parameter) Every generation the best "nreproducing" individuals are allowed to reproduce At reproduction the entire population is replaced by offspring unless the elitism parameter is greated than 0 When elitism is used, each individual is allowed to produce one or more offspring without mutations (i.e.
void evolveSteadyState ()
 Main function of the Genetic Algorithm (Steady State Version) Each individual of the population is allowed to produce an offspring that is used to replace the current worst individual or discarded depending on whether its fitness is better or not of the worst individuals During each generation individuals are re-evaluated to avoid that individuals that happened to be luck in their first evaluation continue to be overestimated with respect to their real capacities The mutation rate is initially set to 50% and then progressively reduced of 1% each generation until it reach the value specified in the mutation rate parameter This initially hight mutation rate is used to explore many random solutions during the initial generations to avoid premature convergence The size of the population is set equal to nreproducing*noffspring however, the number of offsrping is always 1 (it is independent from the noffpring parameter)
virtual QString generationFilename (unsigned int generation, unsigned int seed)
 Returns the name of the file containing the given generation for the given seed.
virtual QString generationFilename ()
 Returns the template name (regular expression) for "generation" files.
int * getBestGenes (int ind)
 Return a pointer to the genome of one individual stored in the bestgenome matrix.
virtual double getCurrentMutationRate ()
 Returns the current mutation rate.
virtual unsigned int getCurrentSeed ()
 Returns the current seed.
virtual EvoRobotExperimentgetEvoRobotExperiment ()
 Returns a pointer to the EvoRobotExperiment object.
virtual QVector
< EvoRobotExperiment * > 
getEvoRobotExperimentPool ()
 Returns a list of pointers to the EvoRobotExperiment objects used by the ga to evaluate agents.
int * getGenes (int ind)
 Return a pointer to the genome of one individual of the current population.
virtual int * getGenesForIndividual (unsigned int id)
 Returns the array of genes for the given individual.
void getGenome (int frombestgenome, int togenome, int mut)
 Copy a genome stored in the bestgenome matrix into the genome of the current population Apply mutation during the copy.
void getLastFStat (double &min, double &max, double &average)
 return the last value of min, max and average fitness
double getNoise (double minn, double maxn)
 Unused function (to be removed)
virtual unsigned int getNumOfGenerations ()
 Returns the number of generations to do.
virtual unsigned int getNumReplications ()
 Returns the number of replications.
void getPheParametersAndMutationsFromEvonet ()
 transfer .phe info inside GA
virtual unsigned int getStartingSeed ()
 Returns the starting seed.
bool isEnabledStepByStep ()
 return true is the step-by-step modality is enabled, false otherwise
bool isStopped ()
 return true if the evolution process has been stopped with stop()
int loadallg (int gen, const char *filew)
 Load the genome of the population from a file.
void loadgenotype (FILE *fp, int ind)
 Load the genome of one individual in a text file.
virtual unsigned int loadGenotypes (QString filename)
 Loads genotypes from the given file.
int loadStatistics (char *filename)
 Load the fitness statistics from a .fit file Return the number of loaded individuals (0 if the file does not exists)
int mrand (int i)
 return a random integer generated with an uniform distribution in the range [0, i-1]
void mreproduce ()
 Identify the best individuals and copy their genotypes into the bestgenome Matrix It also save the best genotypes in the Bx.gen files Assume that the best individuals have the lowest fitness (minimization) This function is not used and it is to be removed.
int mutate (int w, double mut)
 Mutate one gene Since genes are store as integer, this function first trasform them into 8 bits and then mutate (i.e.
virtual unsigned int numLoadedGenotypes () const
 Returns number of loaded genotypes.
virtual void postConfigureInitialization ()
 This function is called after all linked objects have been configured.
void printBest ()
 Print the fitness of the best individuals of the current population.
void printPop ()
 Print the fitness of the individuals of the current population.
void putGenome (int fromgenome, int tobestgenome)
 Copy the genome of one individual to the bestgenome matrix in a specific position.
void randomizePop ()
 Randomize the genome of the population.
void reproduce ()
 Identify the best individuals and copy their genotypes into the bestgenome Matrix It also save the best genotypes in the Bx.gen files.
void resetGenerationCounter ()
 Reset the generation counter to 0.
void resetStop ()
 reset the stopped status to false
virtual void save (ConfigurationParameters &params, QString prefix)
 Save the actual status of parameters into the ConfigurationParameters object passed.
void saveagenotype (FILE *fp, int ind)
 Save the genome of one individual in a text file.
void saveallg ()
 Save the genome of the current population in a G?S?.gen file.
void saveBestInd ()
 Append the genome of the best individual of the current population to the BdSd.gen file.
void saveFStat ()
 Save the average, minimal and maximal fitness by appending a line to the statSd.fit file.
virtual void setCurrentMutationRate (double mutation_rate)
 Set the current mutation rate to use.
void setInitialPopulation (int *)
 Overwrite the genome of all individuals with a manually specify vector of parameters (loaded from a .phe file) This enable to manually fix some of the parameters The Evonet::DEFAULT_VALUE value is used to indicate the parameters are not fixed and that are replaced with randomly generated value.
void setMutations (float *)
 Set the mutation rate of each parameter.
void setSeed (int s)
 Initialize the random number generator.
virtual QString statisticsFilename (unsigned int seed)
 Returns the name of the file with statistics (fitness) for the given seed.
void stop ()
 stop the running evolution process as soon as possible
void updateGenomeFromEvonet (int ind)
 update the genome of the individual to match the current weights of Evonet
- Public Member Functions inherited from ParameterSettableWithConfigureFunction
void addObserver (RuntimeParameterObserver *obs)
getRuntimeParameter (QString paramName)
virtual ParameterSettableUIgetUIManager ()
 ParameterSettable ()
void removeObserver (RuntimeParameterObserver *obs)
void setRuntimeParameter (QString paramName, T newvalue)
QString typeName () const
- Public Member Functions inherited from ConcurrentResourcesUser
void addUsableResource (QString resource)
void addUsableResources (QStringList resources)
void declareResource (QString name, T *resource, QString lockBuddy="")
void deleteResource (QString name)
T * getResource (QString name, bool *resourceExists=NULL)
bool hasResource (QString name) const
void removeAllUsableResources ()
void removeUsableResource (QString resource)
void removeUsableResources (QStringList resources)
virtual void shareResourcesWith (ResourcesUser *buddy)
void usableResources (QStringList resources)
bool usedResourcesExist (QStringList *nonExistingResources=NULL) const

Static Public Member Functions

static void describe (QString type)
 Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
- Static Public Member Functions inherited from ParameterSettableWithConfigureFunction
static QString fullParameterDescriptionPath (QString type, QString param)
static QString fullSubgroupDescriptionPath (QString type, QString sub)

Static Public Attributes

static const int MAXINDIVIDUALS = 1000
 constant defining the maximimum number of individuals that Evoga can manage
- Static Public Attributes inherited from ParameterSettableWithConfigureFunction
static const double Infinity
static const int MaxInteger
static const int MinInteger
- Static Public Attributes inherited from ParameterSettable
static const double Infinity
static const int MaxInteger
static const int MinInteger

Additional Inherited Members

- Public Types inherited from ParameterSettableWithConfigureFunction
enum  Property
- Public Types inherited from ConcurrentResourcesUser
typedef
Resource::ResourceChangeType 
ResourceChangeType
- Public Attributes inherited from ParameterSettableWithConfigureFunction
 AllowMultiple
 Default
 IsList
 IsMandatory
- Protected Member Functions inherited from ParameterSettableWithConfigureFunction
void notifyChangesToParam (QString paramName)
- Protected Member Functions inherited from ConcurrentResourcesUser
T * getResource ()
virtual void notifyResourceChange (ResourceHandler *resource, ResourceChangeType changeType)=0
ResourcesUseroperator= (const ResourcesUser &other)
virtual void resourceChanged (QString name, ResourceChangeType changeType)
 ResourcesUser ()
 ResourcesUser (const ResourcesUser &other)
- Static Protected Member Functions inherited from ParameterSettableWithConfigureFunction
static Descriptor addTypeDescription (QString type, QString shortHelp, QString longHelp=QString(""))
static void setGraphicalEditor (QString type)
- Protected Attributes inherited from ConcurrentResourcesUser
ResourceCollectionHolder m_resources

Detailed Description

Genetic algorithm from evorobot more or less (spare parts)

Mandatory Resources that the EvoRobotExperiment has to declare:

Optional Resources that the EvoRobotExperiment may declare:

  • "evonet": a pointer to the EvoNet

Definition at line 48 of file evoga.h.

Constructor & Destructor Documentation

Evoga ( )

Constructor.

Definition at line 187 of file evoga.cpp.

~Evoga ( )

Destructor.

Definition at line 203 of file evoga.cpp.

Member Function Documentation

QString bestsFilename ( unsigned int  seed)
virtual

Returns the name of the file with the best genomes for the given seed.

Parameters
seedthe seed from which the filename should be returned
Returns
the name of the file with the best genomes for the given seed

Definition at line 1388 of file evoga.cpp.

QString bestsFilename ( )
virtual

Returns the template name (regular expression) for "best genomes" files.

Definition at line 1393 of file evoga.cpp.

bool commitStep ( )

this method marks the point on which it is called as a commited step of evolution

This method allow to divide the code on blocks where each of it can be considered as a single step of the evolution process. These key points define the behaviour when the advancement step-by-step has been requested. When the advancement of the evolution is on "step-by-step" (enableStepByStep method), everytime this method is encountered the process will stop waiting to pass over when the user send a request to perform an another step.

This method handle also the stopping process of the evolution. In fact, it return true if the evolution process has been stopped with stop() This function return true only between the calls to stop() and to resetStop() methods:

stop(); commitStep(); // <– it will return true resetStop(); commitStep(); // <– it will return false

Note
resetStop() is not called automatically by the Evoga after the exit for a stop, but it's called by the EvoRobotComponent after the execution of action 'stop'; If you want to use the Evoga in your custom Component remember to call resetStop()

Definition at line 1290 of file evoga.cpp.

Referenced by EvoRobotExperiment::doAllTrialsForIndividual(), Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

void computeFStat ( )

Calculate the average, minimal and maximal fitness of the current population Assume that the fitness is always positive.

Definition at line 509 of file evoga.cpp.

References farsa::max(), and farsa::min().

Referenced by Evoga::mreproduce(), and Evoga::reproduce().

void computeFStat2 ( )

Calculate the average, minimal and maximal fitness of the current population Assume that the fitness can also be negative.

Definition at line 530 of file evoga.cpp.

References farsa::max(), and farsa::min().

Referenced by Evoga::evolveSteadyState().

void configure ( ConfigurationParameters params,
QString  prefix 
)
virtual

Configures the object using a ConfigurationParameters object.

Parameters
paramsthe configuration parameters object with parameters to use
prefixthe prefix to use to access the object configuration parameters. This is guaranteed to end with the separator character when called by the factory, so you don't need to add one

Implements ParameterSettableWithConfigureFunction.

Definition at line 1148 of file evoga.cpp.

References Logger::error(), ConfigurationHelper::getBool(), ConfigurationHelper::getDouble(), ConfigurationHelper::getInt(), ConfigurationParameters::getObjectFromGroup(), ConfigurationHelper::getString(), ConfigurationParameters::getValue(), Logger::info(), and EvoRobotExperiment::setEvoga().

void copyGenes ( int  from,
int  to,
int  mut 
)

Copy the genotype of an individual into the genotype of a second individual and introduce mutations This function is used by the steadystate genetic algorithm to store the child in the genome matrix at position population+1 and eventually to use the genome of the child to overwrite the genome of the worst individual or discarded.

Parameters
fromThe id of the individual genome to reproduce
toThe id of the location where the reproduced individual is stored
mutA binary flag that specify whether mutation should be introduced of not

Definition at line 297 of file evoga.cpp.

References Evonet::DEFAULT_VALUE, and Evoga::mutate().

Referenced by Evoga::evolveSteadyState().

unsigned int currentGeneration ( )
virtual

Returns the current generation.

Returns
the current generation

Definition at line 1336 of file evoga.cpp.

void describe ( QString  type)
static

Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.

Parameters
typeis the name of the type regarding the description. The type is used when a subclass reuse the description of its parent calling the parent describe method passing the type of the subclass. In this way, the result of the method describe of the parent will be the addition of the description of the parameters of the parent class into the type of the subclass

Reimplemented from ParameterSettableWithConfigureFunction.

Definition at line 1202 of file evoga.cpp.

References ParameterSettableWithConfigureFunction::addTypeDescription(), ParameterSettable::IntDescriptor::def(), ParameterSettable::RealDescriptor::def(), ParameterSettable::EnumDescriptor::def(), ParameterSettable::BoolDescriptor::def(), ParameterSettable::Descriptor::describeBool(), ParameterSettable::Descriptor::describeEnum(), ParameterSettable::Descriptor::describeInt(), ParameterSettable::Descriptor::describeReal(), ParameterSettable::Descriptor::describeSubgroup(), ParameterSettable::BoolDescriptor::help(), ParameterSettable::RealDescriptor::help(), ParameterSettable::SubgroupDescriptor::help(), ParameterSettable::IntDescriptor::help(), ParameterSettable::EnumDescriptor::help(), ParameterSettableWithConfigureFunction::IsMandatory, ParameterSettable::RealDescriptor::limits(), ParameterSettable::IntDescriptor::limits(), ParameterSettableWithConfigureFunction::MaxInteger, ParameterSettable::SubgroupDescriptor::props(), ParameterSettable::EnumDescriptor::props(), ParameterSettable::SubgroupDescriptor::type(), and ParameterSettable::EnumDescriptor::values().

void doNextStep ( )
slot

Go ahead of one step if the EvoGa is in step-by-step modality, otherwise do nothing.

Definition at line 1320 of file evoga.cpp.

void doNotUseMultipleThreads ( )
virtual

Forces execution of the GA using no threads (i.e., in the current thread)

Definition at line 1408 of file evoga.cpp.

Referenced by EvoRobotExperiment::postConfigureInitialization().

double drand ( )

return a random floating point value generated with an uniform distribution in the range[0.0, 1.0]

Parameters
iThe maximum value of the integer to be generated

Definition at line 225 of file evoga.cpp.

Referenced by Evoga::getNoise(), and Evoga::mutate().

void enableStepByStep ( bool  enable)
slot

enable/disable the step-by-step modality of evolution process

When the step-by-step modality is enabled, the evolution process will block in some specific points waiting the user command to go ahead

Parameters
enableif true enable the step-by-step, if false disable it

Definition at line 1308 of file evoga.cpp.

void endGeneration ( int  generation,
double  fmax,
double  faverage,
double  fmin 
)
signal

emitted when a generation is ended

Parameters
generationis the number of generation finished
fmaxis the maximum fitness value
faverageis the average fitness
fminis the minimum fitness value

Referenced by Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

void evolveAllReplicas ( )
virtual

Evolves all replications of the ga process.

Definition at line 1273 of file evoga.cpp.

References Logger::error(), Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

Referenced by EvoRobotComponent::evolve(), and EvolveOperation::run().

void evolveGenerational ( )

Main function of the Genetic Algorithm (Generational, Truncation Selection Version) The size of the population is set equal to nreproducing*noffspring Each individual is allowed to generate a variable number of offspring (noffspring parameter) Every generation the best "nreproducing" individuals are allowed to reproduce At reproduction the entire population is replaced by offspring unless the elitism parameter is greated than 0 When elitism is used, each individual is allowed to produce one or more offspring without mutations (i.e.

identical copies)

Definition at line 1051 of file evoga.cpp.

References Evoga::commitStep(), EvoRobotExperiment::doAllTrialsForIndividual(), Evoga::endGeneration(), EvoRobotExperiment::endGeneration(), EvoRobotExperiment::getFitness(), Evoga::getGenes(), Evoga::getPheParametersAndMutationsFromEvonet(), Evoga::getStartingSeed(), ConcurrentResourcesUser::hasResource(), Logger::info(), EvoRobotExperiment::initGeneration(), Evoga::loadallg(), Evoga::randomizePop(), Evoga::recoveredInterruptedEvolution(), Evoga::reproduce(), Evoga::resetGenerationCounter(), Evoga::saveallg(), EvoRobotExperiment::setNetParameters(), Evoga::setSeed(), and Evoga::startingReplication().

Referenced by Evoga::evolveAllReplicas().

void evolveSteadyState ( )

Main function of the Genetic Algorithm (Steady State Version) Each individual of the population is allowed to produce an offspring that is used to replace the current worst individual or discarded depending on whether its fitness is better or not of the worst individuals During each generation individuals are re-evaluated to avoid that individuals that happened to be luck in their first evaluation continue to be overestimated with respect to their real capacities The mutation rate is initially set to 50% and then progressively reduced of 1% each generation until it reach the value specified in the mutation rate parameter This initially hight mutation rate is used to explore many random solutions during the initial generations to avoid premature convergence The size of the population is set equal to nreproducing*noffspring however, the number of offsrping is always 1 (it is independent from the noffpring parameter)

Definition at line 777 of file evoga.cpp.

References Evoga::commitStep(), Evoga::computeFStat2(), Evoga::copyGenes(), EvoRobotExperiment::doAllTrialsForIndividual(), Evoga::endGeneration(), EvoRobotExperiment::endGeneration(), EvoRobotExperiment::getFitness(), Evoga::getGenes(), ConfigurationParameters::getObjectFromGroup(), Evoga::getPheParametersAndMutationsFromEvonet(), Evoga::getStartingSeed(), ConcurrentResourcesUser::hasResource(), Logger::info(), EvoRobotExperiment::initGeneration(), Evoga::isStopped(), Evoga::loadallg(), Evoga::randomizePop(), Evoga::recoveredInterruptedEvolution(), Evoga::resetGenerationCounter(), Evoga::saveallg(), Evoga::saveBestInd(), Evoga::saveFStat(), EvoRobotExperiment::setEvoga(), EvoRobotExperiment::setNetParameters(), Evoga::setSeed(), Evoga::startingReplication(), and Logger::warning().

Referenced by Evoga::evolveAllReplicas().

void finished ( )
signal

emitted when the evolution has been finished or stopped

QString generationFilename ( unsigned int  generation,
unsigned int  seed 
)
virtual

Returns the name of the file containing the given generation for the given seed.

Parameters
seedthe seed from which the filename should be returned
generationthe generation of interest
Returns
the name of the file with genomes for the given seed and generation

Definition at line 1398 of file evoga.cpp.

QString generationFilename ( )
virtual

Returns the template name (regular expression) for "generation" files.

Definition at line 1403 of file evoga.cpp.

int * getBestGenes ( int  ind)

Return a pointer to the genome of one individual stored in the bestgenome matrix.

Parameters
indThe id of the individual

Definition at line 721 of file evoga.cpp.

double getCurrentMutationRate ( )
virtual

Returns the current mutation rate.

Note
this can differ from generation to generation in the case of steadyState evolution
Returns
the current mutation rate

Definition at line 1360 of file evoga.cpp.

unsigned int getCurrentSeed ( )
virtual

Returns the current seed.

Returns
the current seed

Definition at line 1346 of file evoga.cpp.

EvoRobotExperiment * getEvoRobotExperiment ( )
virtual

Returns a pointer to the EvoRobotExperiment object.

It is not guaranteed that the returned object is effectively used for evolution, in some cases it could simply be a prototype used to generate objects (via cloning) that are used to evaluate agents. Use getExperimentPool() if you want to be sure to get objects used for evaluation

Returns
a pointer to the EvoRobotExperiment object

Definition at line 1324 of file evoga.cpp.

Referenced by TestRandom::buildRandomDNA(), EvoRobotComponent::evolve(), EvoRobotViewer::EvoRobotViewer(), EvolveOperation::run(), TestRandom::runTest(), TestIndividual::runTest(), and TestCurrent::runTest().

QVector< EvoRobotExperiment * > getEvoRobotExperimentPool ( )
virtual

Returns a list of pointers to the EvoRobotExperiment objects used by the ga to evaluate agents.

Objects returned by this function are those effectively used to evaluate individuals (see also getEvoRobotExperiment()). Note that the list could be empty.

Definition at line 1329 of file evoga.cpp.

int * getGenes ( int  ind)

Return a pointer to the genome of one individual of the current population.

Parameters
indThe id of the individual

Definition at line 713 of file evoga.cpp.

Referenced by Evoga::evolveGenerational(), Evoga::evolveSteadyState(), Evoga::getGenesForIndividual(), and EvaluatorThreadForEvoga::setGenotype().

int * getGenesForIndividual ( unsigned int  id)
virtual

Returns the array of genes for the given individual.

Parameters
indthe individual for whom genes are requested
Returns
the array of genes for the given individual

Definition at line 1378 of file evoga.cpp.

References Evoga::getGenes().

void getGenome ( int  frombestgenome,
int  togenome,
int  mut 
)

Copy a genome stored in the bestgenome matrix into the genome of the current population Apply mutation during the copy.

Parameters
frombestgenomeThe id of the genome in the best genome matrix
togenomeThe id of the individual that should receive the genome
mutA 0/1 flag that specify whether mutation should be applied or not

Definition at line 282 of file evoga.cpp.

References Evonet::DEFAULT_VALUE, and Evoga::mutate().

Referenced by Evoga::mreproduce(), and Evoga::reproduce().

void getLastFStat ( double &  min,
double &  max,
double &  average 
)

return the last value of min, max and average fitness

Parameters
minin this parameter will be returned the minimum fitness
maxin this parameter will be returned the maximum fitness
averagein this parameter will be returned the average fitness

Definition at line 602 of file evoga.cpp.

double getNoise ( double  minn,
double  maxn 
)

Unused function (to be removed)

Definition at line 230 of file evoga.cpp.

References Evoga::drand().

unsigned int getNumOfGenerations ( )
virtual

Returns the number of generations to do.

Returns
the number of generations

Definition at line 1356 of file evoga.cpp.

unsigned int getNumReplications ( )
virtual

Returns the number of replications.

Returns
the number of replications

Definition at line 1351 of file evoga.cpp.

void getPheParametersAndMutationsFromEvonet ( )

transfer .phe info inside GA

Warning
this function assume that the EvoRotobEvaluator has a resource named "evonet" returning a pointer to an Evonet object; it this constraint is not satisfied an exception will be raised

Definition at line 731 of file evoga.cpp.

References Evonet::copyPheParameters(), Evonet::freeParameters(), Evonet::getMutations(), Evonet::pheFileLoaded(), Evoga::setInitialPopulation(), and Evoga::setMutations().

Referenced by Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

unsigned int getStartingSeed ( )
virtual

Returns the starting seed.

Returns
the starting seed

Definition at line 1341 of file evoga.cpp.

Referenced by Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

bool isEnabledStepByStep ( )

return true is the step-by-step modality is enabled, false otherwise

Definition at line 1316 of file evoga.cpp.

bool isStopped ( )

return true if the evolution process has been stopped with stop()

This method handle also the stopping process of the evolution. In fact, it return true if the evolution process has been stopped with stop() This function return true only between the calls to stop() and to resetStop() methods:

stop(); commitStep(); // <– it will return true resetStop(); commitStep(); // <– it will return false

Note
resetStop() is not called automatically by the Evoga after the exit for a stop, but it's called by the EvoRobotComponent after the execution of action 'stop'; If you want to use the Evoga in your custom Component remember to call resetStop()

Definition at line 1300 of file evoga.cpp.

Referenced by EvoRobotExperiment::doAllTrialsForIndividual(), Evoga::evolveSteadyState(), EvolveOperation::run(), and TestOperation::run().

int loadallg ( int  gen,
const char *  filew 
)

Load the genome of the population from a file.

Parameters
genThe generation number used to create the GxS?.gen file name. If gen=0 the file name should be passed explicitly
indThe filename from which the genome should be load. When gen>0 this parameter is ignored

Definition at line 621 of file evoga.cpp.

References Logger::error(), Logger::info(), and Evoga::loadgenotype().

Referenced by Evoga::evolveGenerational(), Evoga::evolveSteadyState(), and Evoga::loadGenotypes().

void loadgenotype ( FILE *  fp,
int  ind 
)

Load the genome of one individual in a text file.

Parameters
*fpThe pointer to .gen file
indThe id of the individual

Definition at line 608 of file evoga.cpp.

Referenced by Evoga::loadallg().

unsigned int loadGenotypes ( QString  filename)
virtual

Loads genotypes from the given file.

Parameters
filenamethe name of the file to load
Returns
the number of individuals that have been loaded, 0 in case of errors

Definition at line 1368 of file evoga.cpp.

References Evoga::loadallg().

Referenced by TestIndividual::runTest(), and TestIndividual::setPopulationToTest().

int loadStatistics ( char *  filename)

Load the fitness statistics from a .fit file Return the number of loaded individuals (0 if the file does not exists)

Parameters
*filenameThe filename

Definition at line 659 of file evoga.cpp.

References farsa::max(), and farsa::min().

int mrand ( int  i)

return a random integer generated with an uniform distribution in the range [0, i-1]

Parameters
iThe maximum value of the integer to be generated

Definition at line 177 of file evoga.cpp.

Referenced by Evoga::randomizePop(), and Evoga::setInitialPopulation().

void mreproduce ( )

Identify the best individuals and copy their genotypes into the bestgenome Matrix It also save the best genotypes in the Bx.gen files Assume that the best individuals have the lowest fitness (minimization) This function is not used and it is to be removed.

Definition at line 420 of file evoga.cpp.

References Evoga::computeFStat(), Logger::error(), Evoga::getGenome(), Evoga::putGenome(), Evoga::saveagenotype(), and Evoga::saveFStat().

int mutate ( int  w,
double  mut 
)

Mutate one gene Since genes are store as integer, this function first trasform them into 8 bits and then mutate (i.e.

flip) each bit with a certain probability

  \param w The integer storing the gene value
  \param mut The mutation probability (i.e. the probability that each bit of the gene is flipped)

Definition at line 241 of file evoga.cpp.

References Evoga::drand().

Referenced by Evoga::copyGenes(), and Evoga::getGenome().

unsigned int numLoadedGenotypes ( ) const
virtual

Returns number of loaded genotypes.

Returns
the number of individuals that have been loaded

Definition at line 1373 of file evoga.cpp.

void postConfigureInitialization ( )
virtual
void printBest ( )

Print the fitness of the best individuals of the current population.

Definition at line 498 of file evoga.cpp.

References Logger::info().

void printPop ( )

Print the fitness of the individuals of the current population.

Definition at line 487 of file evoga.cpp.

References Logger::info().

void putGenome ( int  fromgenome,
int  tobestgenome 
)

Copy the genome of one individual to the bestgenome matrix in a specific position.

Parameters
fromgenomeThe id of the individual genome to be copies
tobestgenomeThe position in which the genome should be copied

Definition at line 271 of file evoga.cpp.

References Logger::error().

Referenced by Evoga::mreproduce(), and Evoga::reproduce().

void randomizePop ( )

Randomize the genome of the population.

Definition at line 682 of file evoga.cpp.

References Evoga::mrand().

Referenced by Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

void recoveredInterruptedEvolution ( QString  statfile)
signal

emitted when an interrupted evolution has been recovered and it's going to start from there

Parameters
statFileis the filename from which the evolution has been recovered

Referenced by Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

void reproduce ( )

Identify the best individuals and copy their genotypes into the bestgenome Matrix It also save the best genotypes in the Bx.gen files.

Definition at line 313 of file evoga.cpp.

References Evoga::computeFStat(), Logger::error(), Evoga::getGenome(), Evoga::putGenome(), Evoga::saveagenotype(), and Evoga::saveFStat().

Referenced by Evoga::evolveGenerational().

void resetGenerationCounter ( )

Reset the generation counter to 0.

Definition at line 726 of file evoga.cpp.

Referenced by Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

void resetStop ( )

reset the stopped status to false

Definition at line 1304 of file evoga.cpp.

Referenced by EvoRobotComponent::evolve(), EvolveOperation::run(), TestOperation::run(), and EvoRobotComponent::runTest().

void save ( ConfigurationParameters params,
QString  prefix 
)
virtual

Save the actual status of parameters into the ConfigurationParameters object passed.

This is not implemented, a call to this function will cause an abort

Parameters
paramsthe configuration parameters object on which save actual parameters
prefixthe prefix to use to access the object configuration parameters.

Implements ParameterSettableWithConfigureFunction.

Definition at line 1196 of file evoga.cpp.

References Logger::error().

Referenced by EvoRobotComponent::save().

void saveagenotype ( FILE *  fp,
int  ind 
)

Save the genome of one individual in a text file.

Parameters
*fpThe pointer to .gen file
indThe id of the individual

Definition at line 556 of file evoga.cpp.

Referenced by Evoga::mreproduce(), Evoga::reproduce(), Evoga::saveallg(), and Evoga::saveBestInd().

void saveallg ( )

Save the genome of the current population in a G?S?.gen file.

Definition at line 566 of file evoga.cpp.

References Logger::error(), and Evoga::saveagenotype().

Referenced by Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

void saveBestInd ( )

Append the genome of the best individual of the current population to the BdSd.gen file.

Definition at line 379 of file evoga.cpp.

References Logger::error(), and Evoga::saveagenotype().

Referenced by Evoga::evolveSteadyState().

void saveFStat ( )

Save the average, minimal and maximal fitness by appending a line to the statSd.fit file.

Definition at line 585 of file evoga.cpp.

References Logger::error().

Referenced by Evoga::evolveSteadyState(), Evoga::mreproduce(), and Evoga::reproduce().

void setCurrentMutationRate ( double  mutation_rate)
virtual

Set the current mutation rate to use.

Parameters
mutation_ratethe new mutation rate to use

Definition at line 1364 of file evoga.cpp.

void setInitialPopulation ( int *  ge)

Overwrite the genome of all individuals with a manually specify vector of parameters (loaded from a .phe file) This enable to manually fix some of the parameters The Evonet::DEFAULT_VALUE value is used to indicate the parameters are not fixed and that are replaced with randomly generated value.

Parameters
int*Pointer to the vector of parameter to be used to overwrite genes

Definition at line 691 of file evoga.cpp.

References Evonet::DEFAULT_VALUE, and Evoga::mrand().

Referenced by Evoga::getPheParametersAndMutationsFromEvonet().

void setMutations ( float *  mut)

Set the mutation rate of each parameter.

Parameters
float*Pointer to the vector of mutation rate to be used

Definition at line 706 of file evoga.cpp.

Referenced by Evoga::getPheParametersAndMutationsFromEvonet().

void setSeed ( int  s)

Initialize the random number generator.

Parameters
sThe seed use dto initialize the random number generator

Definition at line 217 of file evoga.cpp.

References farsa::globalRNG, and RandomGenerator::setSeed().

Referenced by Evoga::evolveGenerational(), Evoga::evolveSteadyState(), TestRandom::runTest(), TestIndividual::runTest(), and TestIndividual::setPopulationToTest().

void startingReplication ( int  replication)
signal

emitted when a replication is going to start

Parameters
replicationis the number of the replication that it's going to start

Referenced by Evoga::evolveGenerational(), and Evoga::evolveSteadyState().

QString statisticsFilename ( unsigned int  seed)
virtual

Returns the name of the file with statistics (fitness) for the given seed.

Parameters
seedthe seed from which the filename should be returned
Returns
the name of the file with statistics (fitness) for the given seed

Definition at line 1383 of file evoga.cpp.

void stop ( )

stop the running evolution process as soon as possible

Note
this method return immediately, but the evolution process may take some time before to quit depending on how many processing time last a step of the evolution process

Definition at line 1285 of file evoga.cpp.

Referenced by EvolveOperation::stop(), and TestOperation::stop().

void updateGenomeFromEvonet ( int  ind)

update the genome of the individual to match the current weights of Evonet

Parameters
indthe id of the individual to update

Definition at line 755 of file evoga.cpp.

References Evonet::getFreeParameter(), and Evonet::getWrange().

Member Data Documentation

const int MAXINDIVIDUALS = 1000
static

constant defining the maximimum number of individuals that Evoga can manage

Definition at line 71 of file evoga.h.

Referenced by Evoga::postConfigureInitialization().


The documentation for this class was generated from the following files: