6 GeneralPopulation::GeneralPopulation(
const int popsize,
const int genesize) :
7 Probabilities(popsize), CrowdingDistances(popsize), Population(popsize,
18 OldPopulation(Old.OldPopulation), Probabilities(Old.Probabilities),
19 CrowdingDistances(Old.CrowdingDistances), Population(Old.Population)
21 OldStored = Old.OldStored;
26 OldPopulation(FirstHalf.size1() + SecondHalf.size1(), FirstHalf.size2()),
27 Probabilities(FirstHalf.size1() + SecondHalf.size1()),
28 CrowdingDistances(FirstHalf.size1() + SecondHalf.size1()),
29 Population(FirstHalf.size1() + SecondHalf.size1(), FirstHalf.size2())
32 ublas::matrix_range<tpopulation> PopFirstHalf(
Population, ublas::range(
33 0, FirstHalf.size1()), ublas::range(0, FirstHalf.size2()));
34 ublas::matrix_range<tpopulation> PopSecondHalf(
Population,
35 ublas::range(FirstHalf.size1(), FirstHalf.size1()
36 + SecondHalf.size1()), ublas::range(0, FirstHalf.size2()));
37 PopFirstHalf = FirstHalf;
38 PopSecondHalf = SecondHalf;
46 OldPopulation = source.OldPopulation;
48 Probabilities = source.Probabilities;
49 CrowdingDistances = source.CrowdingDistances;
59 output << popsize <<
" " << genesize << endl;
60 for (i = 0; i < popsize; ++i)
62 for (j = 0; j < genesize; ++j)
69 OldPopulation.resize(popsize, genesize);
71 Probabilities.resize(popsize);
72 CrowdingDistances.resize(popsize);
77 unsigned int popsize, genesize, dummy;
80 input >> popsize >> genesize;
82 for (i = 0; i < popsize; ++i)
84 for (j = 0; j < genesize; ++j)
93 for (
unsigned int i = 0; i < Probabilities.size(); ++i)
95 output << Probabilities(i) <<
" ";
102 for (
unsigned int i = 0; i < CrowdingDistances.size(); ++i)
104 output << CrowdingDistances(i) <<
" ";
The base class for the population of a genetic algorithm, implements storage and access functions...
tpopulation Population
The population of the current iteration.
void PrintProbabilities(std::ostream &output) const
GeneralPopulation(const int popsize, const int genesize)
void PrintDistances(std::ostream &output) const
void ReadPopulation(std::istream &input)
virtual GeneralPopulation & operator=(const GeneralPopulation &source)
void PrintPopulation(std::ostream &output) const
void ResizePop(const int popsize, const int genesize)
Change the population size.
virtual ~GeneralPopulation()