Modernized GAlib  3.0.0 current
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
GAGenome Class Reference

The base genome class just defines the genome interface - how to mutate, crossover, evaluate, etc. More...

#include <GAGenome.h>

Inheritance diagram for GAGenome:
[legend]
Collaboration diagram for GAGenome:
[legend]

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 *)
 
- Public Types inherited from GAID
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)
 
GAGenomeoperator= (const GAGenome &arg)
 
virtual GAGenomeclone (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)
 
GAGeneticAlgorithmgeneticAlgorithm () const
 
GAGeneticAlgorithmgeneticAlgorithm (GAGeneticAlgorithm &g)
 
void * userData () const
 
void * userData (void *u)
 
GAEvalDataevalData () const
 
GAEvalDataevalData (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
 
- Public Member Functions inherited from GAID
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
 
GAGeneticAlgorithmga
 
void * ud
 
Evaluator eval
 
GAEvalDataevd
 
Mutator mutr
 
Initializer init
 
Comparator cmp
 
SexualCrossover sexcross
 
AsexualCrossover asexcross
 

Detailed Description

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.


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