Created by Scott Robert Ladd at Coyote Gulch Productions.
#include <evoreal.h>
Inheritance diagram for libevocosm::evoreal:
In the purest sense, a GA should have no knowledge of the format of the data it is modifying; however, natural chromosomes do encode some structure in their sequence; for example, crossover appears to take place in specific positions along the chromosome. And while mutation doesn't care about a chromosome's structure, it does affect that structure. In context of a computer program, the structure of a chromosome isn't so important as the ability to logically modify its bits through crossover and mutation.
I built tools for the mutation and crossover of encoded floating-point values of types float and double. The code that follows assumes we are working with 32-bit floats and 64-bit IEEE-754 doubles, which, in my experience, the norm for many C and C++ compilers. Yes, I'm aware of the VAX and other systems; this code is explicitly non-portable outside implementations of IEC 60559/IEEE-754.
libevocosm::evoreal::evoreal | ( | float | a_sign_weight = 5.0F , |
|
float | a_exponent_weight = 5.0F , |
|||
float | a_mantissa_weight = 90.0F | |||
) |
Creates a new evoreal object based on a set of weights that define the chance of mutation in various components of a floating-point value. The default weights have worked well in a variety of applications, but are (of course) settable for specific application and experimentation.
Each weight is a percentage of the total of all three weights; for example, if the three weights add to 100 (as they do by efault), and a_sign_weight is 12, the chance of a mutation in the sign bit is 12%. The default weights were chosen based on experience in using these tools in a variety of applications.
a_sign_weight | - Weight assigned to changes in sign | |
a_exponent_weight | - Weight assigned to changes in the exponent | |
a_mantissa_weight | - Weight assigned to changes in the mantissa |
libevocosm::evoreal::evoreal | ( | evoreal & | a_source | ) |
Creates a new evoreal with the same states as an existing one.
a_source | - The source object |
double libevocosm::evoreal::crossover | ( | double | a_d1, | |
double | a_d2 | |||
) |
Creates a new double by combining two values through a real-specialized form of crossover.
a_d1 | - First parent number | |
a_d2 | - Second parent number |
float libevocosm::evoreal::crossover | ( | float | a_f1, | |
float | a_f2 | |||
) |
Creates a new float by combining two values through a real-specialized form of crossover.
a_f1 | - First parent number | |
a_f2 | - Second parent number |
double libevocosm::evoreal::mutate | ( | double | a_d | ) |
Returns a new float that is a mutated version of the argument.
a_d | - Number to be cloned; the result is then mutated |
float libevocosm::evoreal::mutate | ( | float | a_f | ) |
Returns a new float that is a mutated version of the argument.
a_f | - Number to be cloned; the result is then mutated |
Assigns the state of one evoreal to another.
a_source | - The source object |
© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.