Genetic Algorithm

A genetic algorithm has been implemented to select for the ability to follow a ball that moves at random with respect to the creature.  Creatures that have been evolved with the GA show “purposeful” behavior, which enhances their empathetic appeal.  The ball following task was chosen, because the resulting creatures appear to be “attracted” by the ball.  We can imagine that the ball could be replaced by another creature, such that creatures exhibit an attraction for one another.  Or the ball could be replaced by the user’s avatar so that the creatures would exhibit an attraction for the user.  This could lead to the evolution of virtual pets that show affection for the user.  The Genetic Algorithm dialog provides all the controls needed to use the GA.

 

We will introduce and explain each control available through the Genetic Algorithm dialog.

 

The Start With Creature radio-button group provides four different methods to start the GA.  The default setting is Random.  With this setting, the GA will generate and evaluate the number of genomes specified by the Population Size (default to 512) field.  Each genome will be evaluated for the number of time steps specified in the Time Steps field (default to 4800).  During this evaluation period, the ball will move into the number of different positions specified by the Number of Positions field (default to 6).

After all (Population Size) of the genomes have been evaluated, they will be ranked by fitness, and the least-fit half will be discarded.  The remaining half will be re-evaluated for the same number of Time Steps as before.  The newly computed fitness value will be averaged with the previously computed fitness value(s).  Then the remaining half will be ranked by their average fitness values, and the least-fit half will be discarded again.  This cycle will be repeated until the population has been reduced to the size specified in the Number Selected field (default to 16).  If Population Size is set at 512 and Number Selected at 16, this will result in the final sixteen genomes each having been evaluated five times (by default, each of the five evaluations would involve six ball positions over 4800 Time Steps, for a total of thirty ball positions over 24,000 time steps).  These (sixteen by default) genomes form the seed population for the evolution of the GA.

When the Start With Creature radio-button is set to Current, the creature currently displayed in the render window will provide the seed genome for the GA.  This seed genome will be replicated Number Selected – 1 times, to form the seed population of Number Selected genomes (the seed genome is retained in the seed population).  The Num Mutations field (default to 8) specifies the number of mutations introduced into the genome in each reproduction.  Each of the Number Selected genomes in the seed population will be evaluated the number of times specified in the Num Evaluations field (default to 5).

When the Start With Creatures radio-button is set to All, all of the genomes currently stored in memory will be used in the seed population.  Each genome will be evaluated the number of times specified in the Num Evaluations field.

When the Start With Creatures radio-button is set to Restart, the GA will read a log file saved in a previous run, and will continue that run.  When the user clicks the Run button, they will be prompted to select the log file to use in restarting the run.

 

The Termination By control group determines when the GA will terminate automatically.  By default, the Cumulative Number radio-button is selected, which causes the GA to terminate when the number of genomes specified in the edit box have been evaluated (exploding genomes are not counted).  If the Generations radio-button is selected, the GA will terminate after the specified number of generations.  Generations are not discrete in this GA, so a generation is counted when Number Selected new genomes have been recruited into the population (recruitment is explained elsewhere).

 

The green ball is used to select for the ability to be attracted (to follow).  The green ball moves at random with respect to the creature.  The Object Movement radio-button group controls one aspect of the movement of the ball.  The default setting is Random, which means that the x, y, and z coordinates of the ball are all chosen completely at random each time the ball moves.  In this mode, the position of the ball on the three principal axes are determined independently.  The position of the ball on each axis can range from minus Object Distance (default to 6) to plus Object Distance.  However, the ball is excluded from the –1 to + 1 range in each axis.  In fact the ball position is set by choosing a uniform random variate between 1 and Object Distance, then randomly choosing between positive or negative values.  The same method is used to set the position on each of the three axes.

When the Object Movement radio-button is set to Random Six, the ball will move randomly to positions on each of the six principal axes (+x, -x, +y, -y, +z, -z).  The position on the axis is determined by generating a random number between 1 and Object Distance.  In every six ball positions, all six principal axes are guaranteed to be visited, but the order of visitation is random.

 

When the ball moves, the maximum position that it can occupy on each axis is determined by the Object Distance field (default to 6).

 

The fitness evaluation takes place over a period of time specified by the Time Steps field.  During this period of time, the ball will move so that it occupies the number of random positions specified by the Number of Positions field (default to 6).  The evaluation interval will be divided evenly so that the ball spends approximately equal amounts of time at each position.

 

Population Size determines the initial number of random genomes to be generated and evaluated in the case that the Start With Creature radio-button is set to Random (default to 512).

 

Num Mutations determines the number of mutations that are applied to each daughter genome produced by the GA (default to 8).

 

The MinNumSegments field sets a lower limit on the number of boxes that are allowed in the phenotypic bodies of the creatures (default to 8).  If a creature is generated with fewer boxes, it will be rejected.

The MaxNumSegments field sets an upper limit on the number of boxes that are allowed in the phenotypic bodies of the creatures (default to 16).  If a creature is generated with more boxes, it will be rejected.

 

During the fitness evaluation, the creature gets positive points for moving towards the ball and negative points for moving away from the ball.  However, the Minimum Approach field allows the user to specify a minimum distance threshold for assigning positive fitness points (default to 0.0001).  This prevents creatures from accumulating fitness when their positive movements are infinitesimally small.

 

The Leaf class of neurons includes three separate types of neurons that are able to sense the position of the ball.  The three classes of neuron are listed in the lower right of the Leaf Mutation Parameters dialog window: AttractorX, AttractorY, and AttractorZ.  The probability that mutation of a Leaf neuron will result in one of these neurons which can sense the ball are specified in the Leaf Mutation Parameters dialog.  However, it is recognized that in order to follow the ball, the creatures presumably need these neurons.  Therefore, the GA dialog provides the Sensor Prob field as an easy way to increase the relative probability of generating the ball-sensing neurons through mutation.  This default value is eight, which causes the probability of each of the three ball-sensor neurons to be set to that value.  This function can be confirmed during the running of the GA by opening the Leaf Mutation Parameters dialog.  The values show in the fields associated with AttractorX, AttractorY, and AttractorZ should match the value in the Sensor Prob field.

 

 

 

 

The Number Selected field determines the size of the population that is maintained for the duration of the GA (default to 16).

 

The Time Steps field determines the number of time steps over which the fitness is evaluated (default to 4800).

 

While the duration of each fitness evaluation is determined by the Time Steps field, before a creature can be recruited into the population (of Number Selected genomes), it must be evaluated Num Evaluations times (default to 5).  The fitness is independently calculated Num Evaluations times, and then averaged.  In order to be recruited into the population, the average fitness must be greater that the fitness of the least fit genome in the current population.  In that case, the least fit genome will be replaced by the newly recruited genome.

 

The initial parameters of the GA (as set in the Genetic Algorithm dialog) are recorded in a file of the name indicated in the Name: field, with the .log extension.  The .log extension is automatically added and should not be included in this edit box.  This file will also contain a log of all the genomes recruited into the population.

 

The Time – Generation – Distance output fields monitor the progress of the GA.  The Time: field indicates how many time steps have elapsed in the current fitness evaluation.  The Generation: field indicates how many generations have elapsed in this GA run (a generation is counted when Number Selected genomes have been recruited).  The Dist: field indicates the current distance between the ball and the center of mass of the creature.  This is the distance by which the fitness is calculated.

 

The Fitness output fields monitor the progress of fitness during the run of the GA.  The Max: field shows the maximum fitness value achieved by any genome during the run.  The Min: field show the lowest fitness of the Number Selected genomes in the current population.  The Current: field shows the moment-to-moment fitness of the genome currently being evaluated.  The Current: field is recalculated and updated after each time step.

 

The Number output fields monitor aspects of the number of genomes evaluated.  The Cumulative: field reports the total number of genomes evaluated in this run of the GA (exploded genomes are not counted).  The This Gen: field reports the number of genomes evaluated in this generation (where generations are counted when Number Selected genomes have been recruited).  The Recruited: field reports the number of genomes recruited so far in this generation.

 

The Run button starts the GA running, with the parameters set in the Genetic Algorithm dialog.

 

The GA typically runs for long periods of time.  Most of the time, the user will not be watching, so rendering will not be necessary.  The Rendering button toggles the rendering on and off.  Turning off of rendering greatly increases the speed of the GA.

 

After the GA has run, it is fun to read the evolved genomes from the Zoo and watch them follow the ball.  Therefore there needs to be a way of introducing the ball even when the GA is not running.  The Object button will cause the ball to appear in the render window.  Used in this way, the ball has no connection to the GA.  However, the Object button has been placed in the Genetic Algorithm dialog because the behavior of the ball will be affected by the Object Movement radio-buttons, and by the ratio of the Time Steps and the Number of Positions fields, and by the Object Distance field.

 

The Cancel button allows the user to exit from the Genetic Algorithm dialog without running the GA.

 

The File menu of the GA is currently not used.

 

The View menu of the Genetic Algorithm dialog provides access to five tools that aid in the post-mortem analysis of the results of the GA run.  The analysis provided by each of these tools will be explained and illustrated below:

 

The Fitness tool generated a file which contains a line of data for each genome that was recruited into the population.  There are two data columns.  The left column indicates the count of genomes evaluated, and the right column contains the fitness of that genome.  The graph above illustrates how the data looks when it is plotted as a scatter diagram in Excell.  This show how fitness changes over time during the run.  Note that time is plotted on a logarithmic axis.  When the fitness tool is selected, the user will be prompted to select the input file, which should be a .log file containing the history of a GA run.

The Activity tool utilizes an analytical technique developed by Mark Bedau to visualize waves of adaptive activity during evolution.  The tool writes a file to disk, and also generates a visualization of the data.  During the GA, each gene in each genome of each creature is marked with a counter.  When the creature reproduces, the counters are copied from mother to daughter, unless the genes are mutated.  Mutated genes are assigned new unique counters.  The visualization shows the integral of gene frequencies over time.  The Activity visualization window includes three buttons and thrity-five check boxes in the upper-left corner.

The thirty-five check boxes correspond to the thirty-five classes of genes that make up the genomes of the creatures.  Each class of genes is displayed in a different color, and each class can be turned on or off.  In addition, the three buttons permit the clearing or resetting (turning off and on) of all classes of genes, or only those of the brain or the body.  The three buttons can be combined with the thirty-five check boxes to determine which sub-set of genes to view.  The close-up of the buttons and check boxes illustrates the use of the Clear Body button which turns off the display of all genes affecting the body, and facilitates the viewing of only those genes that affect the brain.

 

The Activity visualization above illustrates the use of the individual check boxes, which permits the viewing of the evolutionary activity patterns of selected genes.  In this example we are visualizing only those three genes that affect connections between neurons.

When the user selects the Activity tool, they will be prompted to specify the name of an input file.  The Open file selection dialog will default to looking only at files with the .txt extension.  Initially, the user should use the Files of type: drop down to select the .log extension, and select the log file of the GA run that they wish to analyze.  The user will also be prompted for the name of a file in which the Activity output will be saved.  The Activity file will have a .txt extension, and later the user can select this file to more rapidly view the Activity statistics.

The Convergence tool looks back thirty-two recruited genomes, and determines how many ancestral genomes there are for the current population of Number Selected genomes.  The maximum convergence is the case in which there is only a single genome ancestral to the entire current population.  The minimum convergence is the case that every genome in the current population has a different ancestral genome.  A high convergence (few ancestors) is an indication of high evolutionary activity.  Genomes that contain innovations that bestow a relatively high fitness will take over the population.  The convergence data is displayed in red above, on a plot of fitness data.

 

 

 

The Ancestry tool finds the last recruited genome in a GA run, and traces its ancestry.  It then writes a file that contains a list of the genomes in the ancestry, and it loads all of those genomes into memory so that the evolutionary sequence can be viewed in the render window.  The figure above highlights the ancestry in red, in a plot of fitness data.

The Fitness Change tool examines the recent ancestry of each genome that is recruited, and outputs a file that lists the change in fitness between the new recruit and its parent, grand-parent, and great-grand-parent.  The fitness change data is displayed above in red, together with the fitness data in blue.

 

 

The GA includes an option to run a Null Model.  In the Null Model, there is no selection.  Creatures are chosen for reproduction at random, every genome evaluated is recruited, and the genome to be replaced by a recruited genome is chosen at random.  The Null Model is used to help in distinguishing evolutionary patterns due to selection from patterns due to random effects.

Miscellaneous

 

The miscellaneous dialog provides control of a mix of features, which will be detailed below.

 

Control of Gravity – By default, The Strength of Gravity is: –0.1, which indicates a weak downward force.  The The Strength of Gravity is: field of the Miscellaneous menu provides the opportunity to experiment with different values of gravity.

 

Control of Viscosity – The simple fluid dynamics algorithm provides an opposing force on surfaces moving against the simulated water.  The opposing force is normal to the surface, and proportional to the normal velocity vector and the area of the surface.  The Viscosity of Water is: implemented through a constant that is multiplied by the surface area and its velocity vector.  By default The Viscosity of Water is: 1, and this value can be changed through the Miscellaneous menu.

 

Control of the Number of Creatures Held in Memory – By default, The memory can hold 16 Creatures. The simulation will store up to the last sixteen creatures that have appeared in the render window.  The number of creatures that can be stored in memory is adjustable through the The memory can hold field of the Miscellaneous menu.

 

 

Control of Rendering – If there is no need to view the creatures during a run, such as when a GA is used, the rendering system can be completely avoided by the use of the Rendering check box in the Miscellaneous menu.  This setting should be made before the run is begun, to avoid initiation of the rendering system.

 

Control of Neural Weights – At the time of the writing of this report, a method of implementing Neural Weights has been provisionally implemented as an experiment.  The Neural Weights field of the Miscellaneous menu provides a way to turn this option on and off.

 

 

Control of the Sound – By default, a notification sound is made when a creature is about to be recruited by the GA.  The sound option can be turned off, and the specific sound can be changed through the Sound control group of the Miscellaneous menu.

 

Log Data

The Log Data dialog permits a variety of ways to log data to files on disk, either on the dynamic activity of the running simulation, or the structure of the genotypes and phenotypes.  The Log Data dialog includes several independent groups of controls that will be described below.

 

The Log Dynamic Data control group permits data on the position of boxes, and/or joint angles of the creature that is currently active in the render window, to be written to disk at each time step.  Alternatively, the tool permits the time to be written to disk at intervals determined by the Time Interval field.  In order for any of these logging functions to be activated, the Log Data box must be checked.

The dynamic data logging functions take place over a time interval (measured in simulator time steps) specified by the Start Tick: and Stop Tick: fields.  The dynamic data logging has two mutually exclusive functions: logging of positions and joint angles, or a timer.  The control groups do not currently enforce the either or logic, so the user should be cautious to avoid attempting to utilize both the timer and position/angle logging functions simultaneously.

The logging of position and joint angle data has three options, each of which can independently be turned on or off.  The Centroid Position check box controls logging of the centroid position of the entire body of the creature.  The Segment Positions check box controls logging of the positions of each box in the body.  The Segment Joint Angles check box controls logging of the yaw, pitch, and roll angles of all of the joints connecting all the boxes of the body.

 

The Log Neural Nets control group supports the generation of a file on disk that contains a complete description of the neural circuitry of the creature in the render window.  The Log Genome and Log Phenotype check boxes should be implemented as radio-buttons, because they are mutually exclusive.  The Log Phenotype check box controls the generation of a file that lists all the neurons in all the segments of the body, and their connections to other neurons.  This reveals the complete neural circuitry of a creature.

The Log Genome check box controls the generation of a file that attempts to do the same for the genotype rather than the phenotype.  However, this function has proved unsatisfactory, because the relationship between the neural genotype and the neural phenotype is too complex.  The structure of the neural net is not fully specified in the genotype, and thus it is not practical to attempt to view the structure of the neural net at the genotypic level.

The Actuator Only check box determines if the listing of the neural net includes all neurons that are used, or only those that are used in controlling the actuator joints.

 

The Log Entire Genome control group provides a facility to generate a file on disk with a complete listing of every gene in the genome.  The Used Only check box will limit the output to those genes that are “used”, in the sense that they are expressed in the phenotype.  Used genes are essentially exons, while unused genes are essentially introns.

 

The Log Actuator Inputs control permits the generation of a file in which the neural inputs to the joint actuators are completely traced and reported.  While the data is normally generated for the creature that is currently active in the render window, the Find Input File List button provides a facility to apply the logging function to a list of genome files (.gen extension).

 

The OK button starts the logging function, while the Cancel button allows the exit of the Log Data dialog without causing the logging function.

 

 

 

 

 

 

 

 

 

 

 

 

 

Network

 

The Network dialog provides a networked version of the aesthetic selection model.  Experience showed that it was possible to evolve creatures with aesthetic selection on a single computer, by viewing and evaluating one creature at a time.  However, the process was somewhat tedious.  Therefore a networked version was implemented to permit the simultaneous use of any number of computers to present genetically related creatures for selection.  This greatly accelerates and facilitates the aesthetic selection process.  The image above show a user interacting with an eight-machine network.

 

The Find IPMap File button provides the first step in using the network version.  This button will open an Open File-Selection dialog restricted to files with the .map extension.  You will need a file of this kind that lists the IP addresses of the computer that will be used in your networked implementation.  After the IPMap.map file has been selected, the Run As Network check box will be activated:

 

If the user wishes to start the networked version, they should check the Run As Network check box, and then click the OK button.  If the user clicks the Cancel button, the Network dialog will exit without starting the network version.  The user will need to use the Network dialog to activate the network mode on each machine that will participate in the network

Diff Genomes

 

 

The Diff Genomes dialog provides access to a tool that will examine two genomes and write a file that lists the differences between the two.  The Genome 1 and Genome 2 buttons will open Open File-Selection dialogs restricted to reading genome files (with the .gen extension).  In this way the user can select the two genomes to be compared.

However, it is possible to use Genome 1 button, in conjuction with the Files of type: drop-down of the Open File – Selection dialog, which allows a choice between .gen files and .txt files, to open a file containing a list of genome files.  Currently, the tool can only properly interpret file lists generated by the Genetic Algorithm – Ancestry tool.  In this mode, the Diff Genomes tool will generate a listing of the differences between all the successive genomes in an ancestry.

 

 

 

  Back to Contents Page