#include <D:/Temp/vs/gal/source/BinaryChromosome.h>
Inherits Chromosome::GaDynamicOperationChromosome, Chromosome::Representation::GaSwapableCode, Chromosome::Representation::GaSizableCode, Chromosome::Representation::GaMutableCode, and Chromosome::Representation::GaMultiValueCode.
Public Member Functions | |
virtual GAL_API void GACALL | Remove (int start, int size) |
More details are given in specification of GaSizableCode::Remove method. | |
virtual GAL_API void GACALL | Insert (int start, GaCodeValue *data, int size) |
More details are given in specification of GaSizableCode::Insert method. | |
virtual GAL_API void GACALL | Swap (int start1, int size1, int start2, int size2) |
More details are given in specification of GaSwapableCode::Swap method. | |
virtual GAL_API void GACALL | Flip (int start, int size) |
More details are given in specification of GaMutableCode::Flip method. | |
virtual GAL_API void GACALL | Invert (int start, int size) |
More details are given in specification of GaMutableCode::Invert method. | |
virtual GAL_API GaCodeValuesBuffer *GACALL | MakeBuffer (int size) const |
More details are given in specification of GaMultiValueCode::MakeBuffer method. | |
virtual GAL_API void GACALL | FillBuffer (int pos, int size, GaCodeValuesBuffer &buffer) const |
More details are given in specification of GaMultiValueCode::FillBuffer method. | |
virtual GAL_API void GACALL | FromBuffer (const GaCodeValuesBuffer &buffer) |
More details are given in specification of GaMultiValueCode::FromBuffer method. | |
GAL_API | GaBinaryChromosome (GaChromosomeOperationsBlock *configBlock) |
This constructor initializes chromosome with CCB. | |
GAL_API | GaBinaryChromosome (int size, GaChromosomeOperationsBlock *configBlock) |
This constructor initializes chromosome with CCB and makes random chromosome's code with defined size. | |
GAL_API | GaBinaryChromosome (bool *code, int size, GaChromosomeOperationsBlock *configBlock) |
This constructor initializes chromosome with CCB and its code. | |
GAL_API | GaBinaryChromosome (const GaBinaryChromosome &c, bool setupOnly) |
This is copy constructor. | |
virtual GAL_API | ~GaBinaryChromosome () |
Destructor frees memory used by chromosome's code and backup code. | |
virtual GAL_API GaChromosomePtr GACALL | MakeCopy (bool setupOnly) const |
More details are given in specification of GaChromosome::MakeCopy method. | |
virtual GAL_API GaChromosomePtr GACALL | MakeNewFromPrototype () const |
This method uses MakeCopy method to create chromosome's object, so if additional steps are not needed for creating chromosome from prototype, classes which inherits this class don't have to override this method. | |
virtual int GACALL | GetCodeSize () const |
This method is not thread-safe. | |
GAL_API void GACALL | SetBitState (int bit, bool state) |
SetBitState method sets state of bit at specified position. | |
GAL_API bool GACALL | GetBit (int bit) |
GetBit method returns state of specified bit. | |
bool *GACALL | GetCode () |
This method is not thread-safe. | |
virtual GAL_API GaChromosome &GACALL | operator= (const GaChromosome &rhs) |
More details are given in specification of GaChromosome::operator =. | |
virtual GAL_API float GACALL | operator== (const GaChromosome &c) const |
More details are given in specification of GaChromosome::operator ==. | |
GAL_API char GACALL | GetChar (int pos=0) const |
GetChar method use sizeof(char)*8 number of bits from pos position of chromosome's code to create char value. | |
GAL_API void GACALL | GetChar (char *output, int pos=0, int size=0) const |
GetChar method fills array of char values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0. | |
GAL_API short GACALL | GetShort (int pos=0) const |
GetShort method use sizeof(short)*8 number of bits from pos position of chromosome's code to create short value. | |
GAL_API void GACALL | GetShort (short *output, int pos=0, int size=0) const |
GetShort method fills array of short values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0. | |
GAL_API int GACALL | GetInt (int pos=0) const |
GetInt method use sizeof(int)*8 number of bits from pos position of chromosome's code to create int value. | |
GAL_API void GACALL | GetInt (int *output, int pos=0, int size=0) const |
GetInt method fills array of int values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0. | |
GAL_API float GACALL | GetFloat (int pos=0) const |
GetFloat method use sizeof(float)*8 number of bits from pos position of chromosome's code to create float value. | |
GAL_API void GACALL | GetFloat (float *output, int pos=0, int size=0) const |
GetFloat method fills array of float values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0. | |
GAL_API double GACALL | GetDouble (int pos=0) const |
GetDouble method use sizeof(double)*8 number of bits from pos position of chromosome's code to create double value. | |
GAL_API void GACALL | GetDouble (double *output, int pos=0, int size=0) const |
GetDouble method fills array of double values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0. | |
Static Public Member Functions | |
static GAL_API bool *GACALL | FromChar (char *input, int size) |
FromChar method creates array of booleans which is equal to binary representation of array of input values of char type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array. | |
static GAL_API bool *GACALL | FromShort (short *input, int size) |
FromShort method creates array of booleans which is equal to binary representation of array of input values of short type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array. | |
static GAL_API bool *GACALL | FromInt (int *input, int size) |
FromInt method creates array of booleans which is equal to binary representation of array of input values of int type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array. | |
static GAL_API bool *GACALL | FromFloat (float *input, int size) |
FromFloat method creates array of booleans which is equal to binary representation of array of input values of float type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array. | |
static GAL_API bool *GACALL | FromDouble (double *input, int size) |
FromDouble method creates array of booleans which is equal to binary representation of array of input values of double type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array. | |
Protected Member Functions | |
virtual GAL_API void GACALL | PreapareForMutation () |
PreapareForMutation method creates backup of current code and saves its size. | |
virtual GAL_API void GACALL | AcceptMutation () |
This method only deletes backup copy. | |
virtual GAL_API void GACALL | RejectMutation () |
RejectMutation method deletes current chromosome's code and restores it from backup copy. | |
Protected Attributes | |
bool * | _bits |
Array of booleans which represents binary code. | |
int | _codeSize |
Number of bits in code. | |
bool * | _backupBits |
Array of backed-up bits of chromosome's code. | |
int | _backupSize |
Number of bits in backed-up code. |
This class has no built-in synchronizator, so LOCK_OBJECT
and LOCK_THIS_OBJECT
macros cannot be used with instances of this class. No public or private methods are thread-safe.
Chromosome::Representation::GaBinaryChromosome::GaBinaryChromosome | ( | GaChromosomeOperationsBlock * | configBlock | ) |
This constructor initializes chromosome with CCB.
configBlock | pointer to CCB. |
Chromosome::Representation::GaBinaryChromosome::GaBinaryChromosome | ( | int | size, | |
GaChromosomeOperationsBlock * | configBlock | |||
) |
This constructor initializes chromosome with CCB and makes random chromosome's code with defined size.
size | size of chromosome's code. | |
configBlock | pointer to CCB. |
Chromosome::Representation::GaBinaryChromosome::GaBinaryChromosome | ( | bool * | code, | |
int | size, | |||
GaChromosomeOperationsBlock * | configBlock | |||
) |
This constructor initializes chromosome with CCB and its code.
code | array of bits which is copied to chromosome's code. | |
size | size of chromosome's code. | |
configBlock | pointer to CCB. |
Chromosome::Representation::GaBinaryChromosome::GaBinaryChromosome | ( | const GaBinaryChromosome & | c, | |
bool | setupOnly | |||
) |
This is copy constructor.
c | reference to chromosome which is copied. | |
setupOnly | if this parameter is true , only pointer to CCB is copied. If this parameter is false , chromosome's data and CCB is copied. |
Chromosome::Representation::GaBinaryChromosome::~GaBinaryChromosome | ( | ) | [virtual] |
Destructor frees memory used by chromosome's code and backup code.
void Chromosome::Representation::GaBinaryChromosome::Remove | ( | int | start, | |
int | size | |||
) | [virtual] |
More details are given in specification of GaSizableCode::Remove method.
This method is not thread-safe.
Implements Chromosome::Representation::GaSizableCode.
void Chromosome::Representation::GaBinaryChromosome::Insert | ( | int | start, | |
GaCodeValue * | data, | |||
int | size | |||
) | [virtual] |
More details are given in specification of GaSizableCode::Insert method.
This method is not thread-safe.
Implements Chromosome::Representation::GaSizableCode.
void Chromosome::Representation::GaBinaryChromosome::Swap | ( | int | start1, | |
int | size1, | |||
int | start2, | |||
int | size2 | |||
) | [virtual] |
More details are given in specification of GaSwapableCode::Swap method.
This method is not thread-safe.
Implements Chromosome::Representation::GaSwapableCode.
void Chromosome::Representation::GaBinaryChromosome::Flip | ( | int | start, | |
int | size | |||
) | [virtual] |
More details are given in specification of GaMutableCode::Flip method.
This method is not thread-safe.
Implements Chromosome::Representation::GaMutableCode.
void Chromosome::Representation::GaBinaryChromosome::Invert | ( | int | start, | |
int | size | |||
) | [virtual] |
More details are given in specification of GaMutableCode::Invert method.
This method is not thread-safe.
Implements Chromosome::Representation::GaMutableCode.
GaCodeValuesBuffer * Chromosome::Representation::GaBinaryChromosome::MakeBuffer | ( | int | size | ) | const [virtual] |
More details are given in specification of GaMultiValueCode::MakeBuffer method.
This method is not thread-safe.
Implements Chromosome::Representation::GaMultiValueCode.
void Chromosome::Representation::GaBinaryChromosome::FillBuffer | ( | int | pos, | |
int | size, | |||
GaCodeValuesBuffer & | buffer | |||
) | const [virtual] |
More details are given in specification of GaMultiValueCode::FillBuffer method.
This method is not thread-safe.
Implements Chromosome::Representation::GaMultiValueCode.
void Chromosome::Representation::GaBinaryChromosome::FromBuffer | ( | const GaCodeValuesBuffer & | buffer | ) | [virtual] |
More details are given in specification of GaMultiValueCode::FromBuffer method.
This method is not thread-safe.
Implements Chromosome::Representation::GaMultiValueCode.
virtual GAL_API GaChromosomePtr GACALL Chromosome::Representation::GaBinaryChromosome::MakeCopy | ( | bool | setupOnly | ) | const [inline, virtual] |
More details are given in specification of GaChromosome::MakeCopy method.
This method is not thread-safe.
Implements Chromosome::GaChromosome.
GaChromosomePtr Chromosome::Representation::GaBinaryChromosome::MakeNewFromPrototype | ( | ) | const [virtual] |
This method uses MakeCopy method to create chromosome's object, so if additional steps are not needed for creating chromosome from prototype, classes which inherits this class don't have to override this method.
More details are given in specification of GaChromosome::MakeNewFromPrototype method.
Implements Chromosome::GaChromosome.
virtual int GACALL Chromosome::Representation::GaBinaryChromosome::GetCodeSize | ( | ) | const [inline, virtual] |
This method is not thread-safe.
Implements Chromosome::GaChromosome.
void Chromosome::Representation::GaBinaryChromosome::SetBitState | ( | int | bit, | |
bool | state | |||
) |
SetBitState
method sets state of bit at specified position.
This method is not thread safe.
bit | position of bit. | |
state | new state of the bit. |
bool Chromosome::Representation::GaBinaryChromosome::GetBit | ( | int | bit | ) |
GetBit
method returns state of specified bit.
This method is not thread-safe.
bit | position of bit which state is queried. |
bool* GACALL Chromosome::Representation::GaBinaryChromosome::GetCode | ( | ) | [inline] |
This method is not thread-safe.
GaChromosome & Chromosome::Representation::GaBinaryChromosome::operator= | ( | const GaChromosome & | rhs | ) | [virtual] |
More details are given in specification of GaChromosome::operator =.
This method is not thread-safe.
Reimplemented from Chromosome::GaDefaultChromosome.
float Chromosome::Representation::GaBinaryChromosome::operator== | ( | const GaChromosome & | c | ) | const [virtual] |
More details are given in specification of GaChromosome::operator ==.
This method is not thread-safe.
Implements Chromosome::GaChromosome.
char Chromosome::Representation::GaBinaryChromosome::GetChar | ( | int | pos = 0 |
) | const |
GetChar
method use sizeof(char)*8
number of bits from pos
position of chromosome's code to create char
value.
This method is not thread-safe.
pos | starting position in chromosome's code array of bits. |
void Chromosome::Representation::GaBinaryChromosome::GetChar | ( | char * | output, | |
int | pos = 0 , |
|||
int | size = 0 | |||
) | const |
GetChar
method fills array of char
values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0.
This method is not thread-safe.
output | output array of values. | |
pos | starting position in chromosome's code array of bits. | |
size | number of values which should be extracted. |
short Chromosome::Representation::GaBinaryChromosome::GetShort | ( | int | pos = 0 |
) | const |
GetShort
method use sizeof(short)*8
number of bits from pos
position of chromosome's code to create short
value.
This method is not thread-safe.
pos | starting position in chromosome's code array of bits. |
void Chromosome::Representation::GaBinaryChromosome::GetShort | ( | short * | output, | |
int | pos = 0 , |
|||
int | size = 0 | |||
) | const |
GetShort
method fills array of short
values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0.
This method is not thread-safe.
output | output array of values. | |
pos | starting position in chromosome's code array of bits. | |
size | number of values which should be extracted. |
int Chromosome::Representation::GaBinaryChromosome::GetInt | ( | int | pos = 0 |
) | const |
GetInt
method use sizeof(int)*8
number of bits from pos
position of chromosome's code to create int
value.
This method is not thread-safe.
pos | starting position in chromosome's code array of bits. |
void Chromosome::Representation::GaBinaryChromosome::GetInt | ( | int * | output, | |
int | pos = 0 , |
|||
int | size = 0 | |||
) | const |
GetInt
method fills array of int values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0.
This method is not thread-safe.
output | output array of values. | |
pos | starting position in chromosome's code array of bits. | |
size | number of values which should be extracted. |
float Chromosome::Representation::GaBinaryChromosome::GetFloat | ( | int | pos = 0 |
) | const |
GetFloat
method use sizeof(float)*8
number of bits from pos
position of chromosome's code to create float
value.
This method is not thread-safe.
pos | starting position in chromosome's code array of bits. |
void Chromosome::Representation::GaBinaryChromosome::GetFloat | ( | float * | output, | |
int | pos = 0 , |
|||
int | size = 0 | |||
) | const |
GetFloat
method fills array of float values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0.
This method is not thread-safe.
output | output array of values. | |
pos | starting position in chromosome's code array of bits. | |
size | number of values which should be extracted. |
double Chromosome::Representation::GaBinaryChromosome::GetDouble | ( | int | pos = 0 |
) | const |
GetDouble
method use sizeof(double)*8
number of bits from pos
position of chromosome's code to create double
value.
This method is not thread-safe.
pos | starting position in chromosome's code array of bits. |
void Chromosome::Representation::GaBinaryChromosome::GetDouble | ( | double * | output, | |
int | pos = 0 , |
|||
int | size = 0 | |||
) | const |
GetDouble
method fills array of double values by extracting them from chromosome's code. If output array is bigger then chromosome's code, remaining values in output are set to 0.
This method is not thread-safe.
output | output array of values. | |
pos | starting position in chromosome's code array of bits. | |
size | number of values which should be extracted. |
bool * Chromosome::Representation::GaBinaryChromosome::FromChar | ( | char * | input, | |
int | size | |||
) | [static] |
FromChar
method creates array of booleans which is equal to binary representation of array of input values of char
type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array.
This method is not thread-safe.
input | pointer to array of input values. | |
size | number of values in input array. |
sizeof(char)*8
.bool * Chromosome::Representation::GaBinaryChromosome::FromShort | ( | short * | input, | |
int | size | |||
) | [static] |
FromShort
method creates array of booleans which is equal to binary representation of array of input values of short
type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array.
This method is not thread-safe.
input | pointer to array of input values. | |
size | number of values in input array. |
sizeof(short)*8
.bool * Chromosome::Representation::GaBinaryChromosome::FromInt | ( | int * | input, | |
int | size | |||
) | [static] |
FromInt
method creates array of booleans which is equal to binary representation of array of input values of int
type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array.
This method is not thread-safe.
input | pointer to array of input values. | |
size | number of values in input array. |
sizeof(int)*8
.bool * Chromosome::Representation::GaBinaryChromosome::FromFloat | ( | float * | input, | |
int | size | |||
) | [static] |
FromFloat
method creates array of booleans which is equal to binary representation of array of input values of float
type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array.
This method is not thread-safe.
input | pointer to array of input values. | |
size | number of values in input array. |
sizeof(float)*8
.bool * Chromosome::Representation::GaBinaryChromosome::FromDouble | ( | double * | input, | |
int | size | |||
) | [static] |
FromDouble
method creates array of booleans which is equal to binary representation of array of input values of double
type. Produced array can be used as chromosome's code of binary chromosome. Caller is responsible for memory allocated by this method for output array.
This method is not thread-safe.
input | pointer to array of input values. | |
size | number of values in input array. |
sizeof(double)*8
.void Chromosome::Representation::GaBinaryChromosome::PreapareForMutation | ( | ) | [protected, virtual] |
PreapareForMutation
method creates backup of current code and saves its size.
This method is not thread-safe.
Implements Chromosome::GaDefaultChromosome.
void Chromosome::Representation::GaBinaryChromosome::AcceptMutation | ( | ) | [protected, virtual] |
This method only deletes backup copy.
This method is not thread-safe.
Implements Chromosome::GaDefaultChromosome.
void Chromosome::Representation::GaBinaryChromosome::RejectMutation | ( | ) | [protected, virtual] |
RejectMutation
method deletes current chromosome's code and restores it from backup copy.
This method is not thread-safe.
Implements Chromosome::GaDefaultChromosome.
bool* Chromosome::Representation::GaBinaryChromosome::_bits [protected] |
Array of booleans which represents binary code.
int Chromosome::Representation::GaBinaryChromosome::_codeSize [protected] |
Number of bits in code.
bool* Chromosome::Representation::GaBinaryChromosome::_backupBits [protected] |
Array of backed-up bits of chromosome's code.
int Chromosome::Representation::GaBinaryChromosome::_backupSize [protected] |
Number of bits in backed-up code.