Gene.cpp
Go to the documentation of this file.00001 00009 #include <Gene.h> 00010 00018 Gene::Gene(VariableType geneType, Random * random) { 00019 random_ = random ; 00020 geneType_ = geneType ; 00021 } // Gene::Gene( 00022 00029 Gene::Gene(Gene & gene) { 00030 random_ = gene.random_ ; 00031 geneType_ = gene.geneType_ ; 00032 } // Gene::Gene 00033 00040 Gene::Gene(Gene * gene) { 00041 random_ = gene->random_ ; 00042 geneType_ = gene->geneType_ ; 00043 } // Gene::Gene 00044 00050 Gene::~Gene() { 00051 } // Gene::~Gene 00052 00053 void Gene::singlePointCrossover(int point, Gene * gene) { 00054 cerr << "Single point crossover cannot be applied to a gene of type " 00055 << geneType_ << endl ; 00056 exit(-1) ; 00057 } // Gene::singlePointCrossover 00058 00059 int Gene::bitFlipMutation(double mutationProbability) { 00060 cerr << "Bit-flip mutation cannot be applied to a gene of type " 00061 << geneType_ << endl ; 00062 exit(-1) ; 00063 } // Gene::bitFlipMutation 00064 00065 int Gene::twoPointsInterchange(double mutationProbability) { 00066 cerr << "Two points interchange mutation cannot be applied to a gene of type " 00067 << geneType_ << endl ; 00068 exit(-1) ; 00069 } // Gene::singlePointCrossover 00070 00071 int Gene::randomMutation(double mutationProbability) { 00072 cerr << "Random mutation cannot be applied to a gene of type " 00073 << geneType_ << endl ; 00074 exit(-1) ; 00075 } // Gene::randomMutation 00076 00077 int Gene::polynomialMutation(double mutationProbability, 00078 double distributionIndex) { 00079 cerr << "Polynomial mutation cannot be applied to a gene of type " 00080 << geneType_ << endl ; 00081 exit(-1) ; 00082 } // Gene::polynomialMutationint 00083 00084 int Gene::uniformMutation(double mutationProbability, 00085 double perturbation) { 00086 cerr << "Uniform mutation cannot be applied to a gene of type " 00087 << geneType_ << endl ; 00088 exit(-1) ; 00089 } // Gene::uniformMutation 00090 00091 int Gene::nonUniformMutation(double mutationProbability, 00092 double perturbation, 00093 int iteration, 00094 int maximumNumberOfIterations) { 00095 cerr << "Non-uniform mutation cannot be applied to a gene of type " 00096 << geneType_ << endl ; 00097 exit(-1) ; 00098 } // Gene::nonUniformMutation 00099 00100 double Gene::getRealAllele() { 00101 cerr << "getRealAllele() cannot be applied to a gene of type " 00102 << geneType_ << endl ; 00103 exit(-1) ; 00104 } // Gene::getRealAllele 00105 00106 void Gene::setRealAllele(double value) { 00107 cerr << "setRealAllele() cannot be applied to a gene of type " 00108 << geneType_ << endl ; 00109 exit(-1) ; 00110 } // Gene::setRealAllele 00111 00112 int Gene::getNumberOfBits() { 00113 cerr << "getNumberOfBits() cannot be applied to a gene of type " 00114 << geneType_ << endl ; 00115 exit(-1) ; 00116 } // Gene::getNumberOfBits 00117 00121 Gene & Gene::operator=(const Gene& gene) { 00122 random_ = gene.random_ ; 00123 geneType_ = gene.geneType_ ; 00124 00125 return *this ; 00126 } // Gene::operator= 00127 00131 ostream& operator<< (ostream& outputStream, Gene& gene) { 00132 outputStream << "Gene type: " << gene.geneType_ ; 00133 00134 return outputStream ; 00135 } // operator<< 00136