Modernized GAlib
3.0.0 current
|
The base genome class just defines the genome interface - how to mutate, crossover, evaluate, etc. More...
#include <GAGenome.h>
Public Types | |
enum class | Dimension { LENGTH = 0 , WIDTH = 0 , HEIGHT = 1 , DEPTH = 2 } |
enum class | CloneMethod { CONTENTS = 0 , ATTRIBUTES = 1 } |
enum | { FIXED_SIZE = -1 , ANY_SIZE = -10 } |
using | Evaluator = float(*)(GAGenome &) |
using | Initializer = void(*)(GAGenome &) |
using | Mutator = int(*)(GAGenome &, float) |
using | Comparator = float(*)(const GAGenome &, const GAGenome &) |
using | SexualCrossover = int(*)(const GAGenome &, const GAGenome &, GAGenome *, GAGenome *) |
using | AsexualCrossover = int(*)(const GAGenome &, GAGenome *) |
![]() | |
enum | { BaseGA = 0 , SimpleGA , SteadyStateGA , IncrementalGA , DemeGA , Population = 10 , Scaling = 15 , NoScaling , LinearScaling , SigmaTruncationScaling , PowerLawScaling , Sharing , Selection = 40 , RankSelection , RouletteWheelSelection , TournamentSelection , UniformSelection , SRSSelection , DSSelection , Genome = 50 , BinaryStringGenome , BinaryStringGenome2D , BinaryStringGenome3D , Bin2DecGenome , ListGenome , TreeGenome , ArrayGenome , ArrayGenome2D , ArrayGenome3D , ArrayAlleleGenome , ArrayAlleleGenome2D , ArrayAlleleGenome3D , StringGenome , FloatGenome , IntGenome , DoubleGenome } |
Public Member Functions | |
GADefineIdentity ("GAGenome", GAID::Genome) | |
GAGenome (Initializer i=nullptr, Mutator m=nullptr, Comparator c=nullptr) | |
GAGenome (const GAGenome &orig) | |
GAGenome & | operator= (const GAGenome &arg) |
virtual GAGenome * | clone (CloneMethod flag=CloneMethod::CONTENTS) const |
virtual void | copy (const GAGenome &) |
virtual int | read (std::istream &) |
virtual int | write (std::ostream &) const |
virtual bool | equal (const GAGenome &) const |
virtual bool | notequal (const GAGenome &g) const |
int | nevals () const |
float | score () const |
float | score (float s) |
float | fitness () |
float | fitness (float f) |
GAGeneticAlgorithm * | geneticAlgorithm () const |
GAGeneticAlgorithm * | geneticAlgorithm (GAGeneticAlgorithm &g) |
void * | userData () const |
void * | userData (void *u) |
GAEvalData * | evalData () const |
GAEvalData * | evalData (const GAEvalData &o) |
float | evaluate (bool flag=false) const |
Evaluator | evaluator () const |
Evaluator | evaluator (Evaluator f) |
void | initialize () |
Initializer | initializer () const |
Initializer | initializer (Initializer op) |
int | mutate (float p) |
Mutator | mutator () const |
Mutator | mutator (Mutator op) |
float | compare (const GAGenome &g) const |
Comparator | comparator () const |
Comparator | comparator (Comparator c) |
SexualCrossover | crossover (SexualCrossover f) |
SexualCrossover | sexual () const |
AsexualCrossover | crossover (AsexualCrossover f) |
AsexualCrossover | asexual () const |
![]() | |
bool | sameClass (const GAID &b) const |
virtual const char * | className () const |
virtual int | classID () const |
Static Public Member Functions | |
static void | NoInitializer (GAGenome &) |
static int | NoMutator (GAGenome &, float) |
static float | NoComparator (const GAGenome &, const GAGenome &) |
Protected Attributes | |
float | _score |
float | _fitness |
bool | _evaluated |
unsigned int | _neval |
GAGeneticAlgorithm * | ga |
void * | ud |
Evaluator | eval |
GAEvalData * | evd |
Mutator | mutr |
Initializer | init |
Comparator | cmp |
SexualCrossover | sexcross |
AsexualCrossover | asexcross |
The base genome class just defines the genome interface - how to mutate, crossover, evaluate, etc.
When you create your own genome, multiply inherit from the base genome class and the data type that you want to use. Use the data type to store the information and use the genome part to tell the GA how it should operate on the data. See comments below for further details.