Modernized GAlib  3.0.0 current
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
GA1DArrayAlleleGenome< T > Class Template Reference
Inheritance diagram for GA1DArrayAlleleGenome< T >:
[legend]
Collaboration diagram for GA1DArrayAlleleGenome< T >:
[legend]

Public Member Functions

 GADefineIdentity ("GA1DArrayAlleleGenome", GAID::ArrayAlleleGenome)
 
 GA1DArrayAlleleGenome (unsigned int length, const GAAlleleSet< T > &s, GAGenome::Evaluator f=nullptr, void *u=nullptr)
 
 GA1DArrayAlleleGenome (const GAAlleleSetArray< T > &sa, GAGenome::Evaluator f=nullptr, void *u=nullptr)
 
 GA1DArrayAlleleGenome (const GA1DArrayAlleleGenome< T > &orig)
 
GA1DArrayAlleleGenome< T > & operator= (const GAGenome &arr)
 
GA1DArrayAlleleGenome< T > & operator= (const T array[])
 
GAGenomeclone (GAGenome::CloneMethod=GAGenome::CloneMethod::CONTENTS) const override
 
void copy (const GAGenome &orig) override
 
int read (std::istream &is) override
 
int write (std::ostream &os) const override
 
bool equal (const GAGenome &c) const override
 
int resize (int len) override
 If we resize to a larger length then we need to set the contents to a valid value (ie one of our alleles) More...
 
const GAAlleleSet< T > & alleleset (unsigned int i=0) const
 
int size () const
 
- Public Member Functions inherited from GA1DArrayGenome< T >
 GADefineIdentity ("GA1DArrayGenome", GAID::ArrayGenome)
 
 GA1DArrayGenome (unsigned int length, GAGenome::Evaluator f=nullptr, void *u=nullptr)
 
 GA1DArrayGenome (const GA1DArrayGenome< T > &orig)
 
GA1DArrayGenome< T > & operator= (const GAGenome &orig)
 
GA1DArrayGenome< T > & operator= (const T array[])
 
const T & gene (unsigned int x=0) const
 
T & gene (unsigned int x, const T &value)
 
int length () const
 
int length (int x)
 
int resizeBehaviour (unsigned int lower, unsigned int upper)
 
int resizeBehaviour () const
 
void copy (const GA1DArrayGenome< T > &orig, unsigned int r, unsigned int x, unsigned int l)
 
void swap (unsigned int i, unsigned int j)
 
- Public Member Functions inherited from GAArray< T >
 GAArray (unsigned int s)
 
 GAArray (const GAArray< T > &orig)
 
GAArray< T > & operator= (const GAArray< T > &orig)
 
GAArray< T > * clone ()
 
const T & operator[] (unsigned int i) const
 
T & operator[] (unsigned int i)
 
void copy (const GAArray< T > &orig)
 
void copy (const GAArray< T > &orig, unsigned int dest, unsigned int src, unsigned int length)
 
void move (unsigned int dest, unsigned int src, unsigned int length)
 
void swap (unsigned int i, unsigned int j)
 
int size () const
 
int size (unsigned int n)
 
bool equal (const GAArray< T > &b, unsigned int dest, unsigned int src, unsigned int length) const
 
template<class U >
bool operator== (const GAArray< U > &rhs) const
 
template<class U >
bool operator!= (const GAArray< U > &rhs) const
 
- Public Member Functions inherited from GAGenome
 GADefineIdentity ("GAGenome", GAID::Genome)
 
 GAGenome (Initializer i=nullptr, Mutator m=nullptr, Comparator c=nullptr)
 
 GAGenome (const GAGenome &orig)
 
GAGenomeoperator= (const GAGenome &arg)
 
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 UniformInitializer (GAGenome &c)
 
static void OrderedInitializer (GAGenome &c)
 
static int FlipMutator (GAGenome &c, float pmut)
 
- Static Public Member Functions inherited from GA1DArrayGenome< T >
static int SwapMutator (GAGenome &c, float pmut)
 Randomly swap elements in the array. More...
 
static float ElementComparator (const GAGenome &a, const GAGenome &b)
 How similar are two genomes. More...
 
static int UniformCrossover (const GAGenome &p1, const GAGenome &p2, GAGenome *c1, GAGenome *c2)
 Randomly take bits from each parent. More...
 
static int OnePointCrossover (const GAGenome &p1, const GAGenome &p2, GAGenome *c1, GAGenome *c2)
 
static int TwoPointCrossover (const GAGenome &p1, const GAGenome &p2, GAGenome *c1, GAGenome *c2)
 
static int EvenOddCrossover (const GAGenome &p1, const GAGenome &p2, GAGenome *c1, GAGenome *c2)
 
static int PartialMatchCrossover (const GAGenome &p1, const GAGenome &p2, GAGenome *c1, GAGenome *c2)
 
static int OrderCrossover (const GAGenome &p1, const GAGenome &p2, GAGenome *c1, GAGenome *c2)
 
static int CycleCrossover (const GAGenome &p1, const GAGenome &p2, GAGenome *c1, GAGenome *c2)
 
- Static Public Member Functions inherited from GAGenome
static void NoInitializer (GAGenome &)
 
static int NoMutator (GAGenome &, float)
 
static float NoComparator (const GAGenome &, const GAGenome &)
 

Protected Attributes

std::vector< GAAlleleSet< T > > aset
 the allele set(s) for this genome
 
- Protected Attributes inherited from GA1DArrayGenome< T >
unsigned int nx
 
unsigned int minX
 
unsigned int maxX
 
- Protected Attributes inherited from GAArray< T >
std::vector< T > a
 the contents of the array
 
- Protected Attributes inherited from GAGenome
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
 

Additional Inherited Members

- Public Types inherited from GAGenome
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
}
 

Member Function Documentation

◆ resize()

template<class T >
int GA1DArrayAlleleGenome< T >::resize ( int  len)
inlineoverridevirtual

If we resize to a larger length then we need to set the contents to a valid value (ie one of our alleles)

Parameters
len
Returns
int

Reimplemented from GA1DArrayGenome< T >.


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