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

BinaryRealGene Class Reference

Class representing a binary-coded real gene.

#include <BinaryRealGene.h>

Inheritance diagram for BinaryRealGene:

Gene BinaryGrayRealGene List of all members.

Public Member Functions

 BinaryRealGene (int numberOfBits, double lowerBound, double upperBound, Random *random)
 Constructor.
 BinaryRealGene (BinaryRealGene &binaryRealGene)
 Copy constructor.
 BinaryRealGene (BinaryRealGene *binaryRealGene)
 Copy constructor.
virtual ~BinaryRealGene ()
 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 ()
double decodeToReal ()
 Decodes a binary string into a real value.
void codeToBinary ()
 Codes a real value into a binary string THIS PROCEDURE MUST BE TESTED TO ENSURE IT WORKS PROPERLY.
BinaryRealGene & operator= (const BinaryRealGene &gene)
bool operator== (const BinaryRealGene &gene)
bool operator!= (const BinaryRealGene &gene)

Public Attributes

bitset< MAX_LENGTH > binaryAllele_
int numberOfBits_
double realAllele_
double lowerBound_
double upperBound_

Static Public Attributes

static const int MAX_LENGTH = 30

Friends

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

Detailed Description

Definition at line 20 of file BinaryRealGene.h.


Constructor & Destructor Documentation

BinaryRealGene::BinaryRealGene (  int  numberOfBits,
double  lowerBound,
double  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 BinaryRealGene.cpp.

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

BinaryRealGene::BinaryRealGene (  BinaryRealGene &  gene  ) 
 

Parameters:
gene The gene to copy
Constructor of the class

Definition at line 56 of file BinaryRealGene.cpp.

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

BinaryRealGene::BinaryRealGene (  BinaryRealGene *  gene  ) 
 

Parameters:
gene The gene to copy
Constructor of the class

Definition at line 77 of file BinaryRealGene.cpp.

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

BinaryRealGene::~BinaryRealGene (   )  [virtual]
 

Destructor of the class

Definition at line 95 of file BinaryRealGene.cpp.


Member Function Documentation

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

Reimplemented from Gene.

Definition at line 127 of file BinaryRealGene.cpp.

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

void BinaryRealGene::codeToBinary (   ) 
 

Definition at line 223 of file BinaryRealGene.cpp.

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

Referenced by setRealAllele().

double BinaryRealGene::decodeToReal (   ) 
 

Reimplemented in BinaryGrayRealGene.

Definition at line 204 of file BinaryRealGene.cpp.

References binaryAllele_, and numberOfBits_.

Referenced by BinaryRealGene().

int BinaryRealGene::getNumberOfBits (   )  [virtual]
 

Reimplemented from Gene.

Definition at line 148 of file BinaryRealGene.cpp.

References numberOfBits_.

double BinaryRealGene::getRealAllele (   )  [virtual]
 

Reimplemented from Gene.

Definition at line 144 of file BinaryRealGene.cpp.

References realAllele_.

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

Definition at line 168 of file BinaryRealGene.cpp.

References binaryAllele_, and numberOfBits_.

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

Definition at line 98 of file BinaryRealGene.cpp.

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

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

Definition at line 160 of file BinaryRealGene.cpp.

References binaryAllele_, and numberOfBits_.

void BinaryRealGene::printGenotype (   )  [virtual]
 

Implements Gene.

Definition at line 156 of file BinaryRealGene.cpp.

References realAllele_.

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

Parameters:
value The new value of the real allele

Reimplemented from Gene.

Definition at line 196 of file BinaryRealGene.cpp.

References codeToBinary(), and realAllele_.

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

Parameters:
point The crossover point
gene The other gene

Reimplemented from Gene.

Definition at line 113 of file BinaryRealGene.cpp.

References numberOfBits_.

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

Implements Gene.

Definition at line 152 of file BinaryRealGene.cpp.

References realAllele_.


Friends And Related Function Documentation

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

Definition at line 176 of file BinaryRealGene.cpp.


Member Data Documentation

bitset<MAX_LENGTH> BinaryRealGene::binaryAllele_
 

Definition at line 24 of file BinaryRealGene.h.

Referenced by BinaryRealGene(), bitFlipMutation(), codeToBinary(), decodeToReal(), BinaryGrayRealGene::grayToBinary(), operator!=(), operator<<(), operator=(), and operator==().

double BinaryRealGene::lowerBound_
 

Definition at line 27 of file BinaryRealGene.h.

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

const int BinaryRealGene::MAX_LENGTH = 30 [static]
 

Definition at line 22 of file BinaryRealGene.h.

Referenced by BinaryRealGene().

int BinaryRealGene::numberOfBits_
 

Definition at line 25 of file BinaryRealGene.h.

Referenced by BinaryRealGene(), bitFlipMutation(), codeToBinary(), decodeToReal(), BinaryGrayRealGene::decodeToReal(), getNumberOfBits(), BinaryGrayRealGene::grayToBinary(), operator!=(), operator<<(), operator=(), operator==(), and singlePointCrossover().

double BinaryRealGene::realAllele_
 

Definition at line 26 of file BinaryRealGene.h.

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

double BinaryRealGene::upperBound_
 

Definition at line 28 of file BinaryRealGene.h.

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


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

Our Software

orangebox Mallba

orangebox ssGA

orangebox JGDS

orangebox xxGA

orangebox JCell

orangebox MHTB

orangebox DEME

orangebox JMetal

orangebox More...

orangebox Go Back