BinaryPopulation.cpp

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

Generated on Fri Jul 4 15:30:20 2008 for GPLIB++ by  doxygen 1.5.5