Desc. & Idea | Warnings | Methods | Atributes | Operators | Specials |
Class representing a population. It is realized as array of TGen objects. The gens have a position (index) in population, but this can vary during the life of population.
TPopulation has two two different atributes specifing its size. First is size that means the number of actually present gens in population. Second allocated is the size of space prepared for gens created in future.
Public:
TPopulation(uint ialloc,TFitness* AFitFunc,uint iinc = 1)
TPopulation(uint isize, uint ialloc, uint igenlength, TFitness* AFitFunc,uint iinc=1, ini_type itype=rndm)
TPopulation(TPopulation& pop)
TPopulation(TGen& gen)
TPopulation(BYTE** rawbytes,uint len,BOOL subclass=FALSE)
virtual ~TPopulation()
virtual char* Dump()
virtual uint GetSerSize(BOOL subclass=FALSE)
virtual uint Serialize(BYTE **rawbytes,BOOL subclass=FALSE)
uint GetSize()
uint GetAllocated()
uint GetInc()
uint SetInc(uint i)
virtual TFitness *GetFitFunc()
virtual void SetFitFunc(TFitness *val)
BOOL Insert (TGen& gen)
BOOL Delete (uint i, BOOL destroy = TRUE)
BOOL InsertPop (TPopulation& pop)
BOOL FillToSize (TPopulation& from, uint nsize = 0)
void Empty()
Protected:
Private:
TPopulation(uint isize, uint ialloc, uint igenlength, TFitness* AFitFunc,uint iinc=1, ini_type itype=rndm)
Constructor of TPopulation.
Allocates requested space and requested number of gens is created and initialized.
Arguments:
isize ... number of gens to create
ialloc ... number of gens (TGen*) to allocate space for
igenlength ... bit length of the gen
AFitFunc ... pointer to the fitness function
iinc ... expansion increment (default 1)
iini ... type of gen initialization (default rndm)
TPopulation(TPopulation& pop)
Copy constructor.
Arguments:
pop ... source population
BOOL Insert (TGen& gen)
Inserts copy of argument into population.
If there is not enough allocated space,then the population's space will be expanded by inc
Public:
TGen **individual
Protected:
uint size
uint inc
uint allocated
Private:
TFitness *FitFunc
TGen **individual
An array of pointers to the population members.
uint size
The actual number of gens present in the population.
uint inc
The allocation increment used when the population should expand.
uint allocated
The size of the allocated array of gens. Not all must be actualy present!
TFitness *FitFunc
Pointer to the object representing fitness function. See TFitness class for more info.
Public:
operator TGen&()
TGen& operator [] (uint i)
TPopulation& operator = (TPopulation& pop)
TPopulation& operator << (TGen& gen)
TPopulation& operator << (TPopulation& pop)
Protected:
Private:
None.