• Main Page
  • Namespaces
  • Classes
  • Files
  • Class List
  • Class Hierarchy
  • Class Members

BinaryIntegerGene Class Reference

Class representing a binary-coded integer gene.

#include <BinaryIntegerGene.h>

Inheritance diagram for BinaryIntegerGene:

Gene BinaryGrayIntegerGene List of all members.

Public Member Functions

 BinaryIntegerGene (int numberOfBits, int lowerBound, int upperBound, Random *random)
 Constructor.
 BinaryIntegerGene (BinaryIntegerGene &BinaryIntegerGene)
 Copy constructor.
 BinaryIntegerGene (BinaryIntegerGene *BinaryIntegerGene)
 Copy constructor.
virtual ~BinaryIntegerGene ()
 Destructor.
int bitFlipMutation (double mutationProbability)
void singlePointCrossover (int point, Gene *gene)
 Bitwise crossover between two genes.
int getNumberOfBits ()
double getRealAllele ()
void setRealAllele (double value)
 Set the value of the real allele.
void writeGenotype (ofstream &outputFile)
void printGenotype ()
int decodeToInteger ()
 Decodes a binary string into an integer value.
void codeToBinary ()
 Codes an integer value into a binary string THIS PROCEDURE MUST BE TESTED TO ENSURE IT WORKS PROPERLY.
BinaryIntegerGene & operator= (const BinaryIntegerGene &gene)
bool operator== (const BinaryIntegerGene &gene)
bool operator!= (const BinaryIntegerGene &gene)

Public Attributes

bitset< MAX_LENGTH > binaryAllele_
int numberOfBits_
int integerAllele_
int lowerBound_
int upperBound_

Static Public Attributes

static const int MAX_LENGTH = 30

Friends

ostream & operator<< (ostream &outputStream, BinaryIntegerGene &gene)

Detailed Description

Definition at line 20 of file BinaryIntegerGene.h.


Constructor & Destructor Documentation

BinaryIntegerGene::BinaryIntegerGene (  int  numberOfBits,
int  lowerBound,
int  upperBound,
Random *  random
) 
 

Parameters:
numberOfBits Bits of the binary allele
lowerBound Lower limit of the gene value
upperBound Upper limit of the gene value
random Pointer to the random number generator
Constructor of the class

Definition at line 20 of file BinaryIntegerGene.cpp.

References binaryAllele_, decodeToInteger(), integerAllele_, lowerBound_, MAX_LENGTH, numberOfBits_, Gene::random_, Random::rnd(), and upperBound_.

BinaryIntegerGene::BinaryIntegerGene (  BinaryIntegerGene &  gene  ) 
 

Parameters:
gene The gene to copy
Constructor of the class

Definition at line 56 of file BinaryIntegerGene.cpp.

References binaryAllele_, integerAllele_, lowerBound_, numberOfBits_, and upperBound_.

BinaryIntegerGene::BinaryIntegerGene (  BinaryIntegerGene *  gene  ) 
 

Parameters:
gene The gene to copy
Constructor of the class

Definition at line 77 of file BinaryIntegerGene.cpp.

References binaryAllele_, integerAllele_, lowerBound_, numberOfBits_, and upperBound_.

BinaryIntegerGene::~BinaryIntegerGene (   )  [virtual]
 

Destructor of the class

Definition at line 95 of file BinaryIntegerGene.cpp.


Member Function Documentation

int BinaryIntegerGene::bitFlipMutation (  double  mutationProbability  )  [virtual]
 

Reimplemented from Gene.

Definition at line 127 of file BinaryIntegerGene.cpp.

References binaryAllele_, Random::flip(), numberOfBits_, and Gene::random_.

void BinaryIntegerGene::codeToBinary (   ) 
 

Definition at line 205 of file BinaryIntegerGene.cpp.

References binaryAllele_, integerAllele_, lowerBound_, numberOfBits_, and upperBound_.

Referenced by setRealAllele().

int BinaryIntegerGene::decodeToInteger (   ) 
 

Reimplemented in BinaryGrayIntegerGene.

Definition at line 233 of file BinaryIntegerGene.cpp.

References binaryAllele_, and numberOfBits_.

Referenced by BinaryIntegerGene().

int BinaryIntegerGene::getNumberOfBits (   )  [virtual]
 

Reimplemented from Gene.

Definition at line 148 of file BinaryIntegerGene.cpp.

References numberOfBits_.

double BinaryIntegerGene::getRealAllele (   )  [virtual]
 

Reimplemented from Gene.

Definition at line 144 of file BinaryIntegerGene.cpp.

References integerAllele_.

bool BinaryIntegerGene::operator!= (  const BinaryIntegerGene &  gene  ) 
 

Definition at line 168 of file BinaryIntegerGene.cpp.

References binaryAllele_, and numberOfBits_.

BinaryIntegerGene & BinaryIntegerGene::operator= (  const BinaryIntegerGene &  gene  ) 
 

Definition at line 98 of file BinaryIntegerGene.cpp.

References binaryAllele_, integerAllele_, lowerBound_, numberOfBits_, and upperBound_.

bool BinaryIntegerGene::operator== (  const BinaryIntegerGene &  gene  ) 
 

Definition at line 160 of file BinaryIntegerGene.cpp.

References binaryAllele_, and numberOfBits_.

void BinaryIntegerGene::printGenotype (   )  [virtual]
 

Implements Gene.

Definition at line 156 of file BinaryIntegerGene.cpp.

References integerAllele_.

void BinaryIntegerGene::setRealAllele (  double  value  )  [virtual]
 

Parameters:
value The new value of the real allele

Reimplemented from Gene.

Definition at line 196 of file BinaryIntegerGene.cpp.

References codeToBinary(), and integerAllele_.

void BinaryIntegerGene::singlePointCrossover (  int  point,
Gene *  gene
)  [virtual]
 

Parameters:
point The crossover point
gene The other gene

Reimplemented from Gene.

Definition at line 113 of file BinaryIntegerGene.cpp.

References numberOfBits_.

void BinaryIntegerGene::writeGenotype (  ofstream &  outputFile  )  [virtual]
 

Implements Gene.

Definition at line 152 of file BinaryIntegerGene.cpp.

References integerAllele_.


Friends And Related Function Documentation

ostream& operator<< (  ostream &  outputStream,
BinaryIntegerGene &  gene
)  [friend]
 

Definition at line 176 of file BinaryIntegerGene.cpp.


Member Data Documentation

bitset<MAX_LENGTH> BinaryIntegerGene::binaryAllele_
 

Definition at line 24 of file BinaryIntegerGene.h.

Referenced by BinaryIntegerGene(), bitFlipMutation(), codeToBinary(), decodeToInteger(), BinaryGrayIntegerGene::grayToBinary(), operator!=(), operator<<(), operator=(), and operator==().

int BinaryIntegerGene::integerAllele_
 

Definition at line 26 of file BinaryIntegerGene.h.

Referenced by BinaryIntegerGene(), codeToBinary(), getRealAllele(), operator<<(), operator=(), printGenotype(), setRealAllele(), and writeGenotype().

int BinaryIntegerGene::lowerBound_
 

Definition at line 27 of file BinaryIntegerGene.h.

Referenced by BinaryIntegerGene(), codeToBinary(), and operator=().

const int BinaryIntegerGene::MAX_LENGTH = 30 [static]
 

Definition at line 22 of file BinaryIntegerGene.h.

Referenced by BinaryIntegerGene().

int BinaryIntegerGene::numberOfBits_
 

Definition at line 25 of file BinaryIntegerGene.h.

Referenced by BinaryIntegerGene(), bitFlipMutation(), codeToBinary(), decodeToInteger(), BinaryGrayIntegerGene::decodeToInteger(), getNumberOfBits(), BinaryGrayIntegerGene::grayToBinary(), operator!=(), operator<<(), operator=(), operator==(), and singlePointCrossover().

int BinaryIntegerGene::upperBound_
 

Definition at line 28 of file BinaryIntegerGene.h.

Referenced by BinaryIntegerGene(), codeToBinary(), and operator=().


The documentation for this class was generated from the following files:
  • BinaryIntegerGene.h
  • BinaryIntegerGene.cpp

Our Software

orangebox Mallba

orangebox ssGA

orangebox JGDS

orangebox xxGA

orangebox JCell

orangebox MHTB

orangebox DEME

orangebox JMetal

orangebox More...

orangebox Go Back