00001 #include "BinaryPopulation.h" 00002 00003 namespace gplib 00004 { 00005 BinaryPopulation::BinaryPopulation(const int popsize, const int genesize, 00006 GeneralRNG &LocalRandom, const bool init) : 00007 GeneralPopulation(popsize, genesize), Random(LocalRandom) 00008 { 00009 if (init) 00010 InitPop(); 00011 } 00012 00013 BinaryPopulation::~BinaryPopulation() 00014 { 00015 } 00016 00017 void BinaryPopulation::InitPop() 00018 { 00019 const size_t popsize = Population.size1(); 00020 const size_t genesize = Population.size2(); 00021 for (size_t i = 0; i < popsize; ++i) 00022 for (size_t j = 0; j < genesize; ++j) 00023 Population(i, j) = (Random.GetNumber() > 0.5); 00024 } 00025 00026 BinaryPopulation& BinaryPopulation::operator=( 00027 const BinaryPopulation &source) 00028 { 00029 if (this == &source) 00030 return *this; 00031 GeneralPopulation::operator=(source); 00032 Random = source.Random; 00033 return *this; 00034 } 00035 }
1.5.8