\hypertarget{classPopulation}{
\section{Population Class Reference}
\label{classPopulation}\index{Population@{Population}}
}


A population of individual solutions; this is the core of a Pareto-\/based memetic algorithm.  


{\ttfamily \#include $<$Population.hpp$>$}\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classPopulation_a808b87f26504515005c7abf81cebec24}{Population} (int nobj)
\begin{DoxyCompactList}\small\item\em Create a population for individuals that have nobj objectives. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_aaccf3417030811fa1db6a785a07a4407}{fromStream} (istream \&ist, const \hyperlink{classIndividualReader}{IndividualReader} $\ast$rdr)
\begin{DoxyCompactList}\small\item\em Insert individuals from a stream, using a concrete reader. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_a121e35f8e7d6695bc790e9674851cc14}{toStream} (ostream \&ost) const 
\begin{DoxyCompactList}\small\item\em Write all individuals to a stream. \item\end{DoxyCompactList}\item 
double \hyperlink{classPopulation_aaedf0bd0b968822b69d7e6b3c977bf3a}{getObjectiveValue} (int individualIndex, int objectiveIndex) const 
\begin{DoxyCompactList}\small\item\em Get one objective value from an indexed individual. \item\end{DoxyCompactList}\item 
vector$<$ double $>$ \hyperlink{classPopulation_ab51734c346d2b6d0948ff8fdd82dadb7}{getTrace} (int individualIndex) const 
\begin{DoxyCompactList}\small\item\em Get the vector of traced values from an indexed individual. \item\end{DoxyCompactList}\item 
int \hyperlink{classPopulation_ab9e2c0bbd0dd0752634b356d0e9715a0}{getIndividualID} (int individualIndex) const 
\begin{DoxyCompactList}\small\item\em Get the unique ID of an individual. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_a611533865c5a476c3b0f3043d311a8c7}{setIndividualID} (int individualIndex, int newID)
\begin{DoxyCompactList}\small\item\em Set the unique ID of an individual. \item\end{DoxyCompactList}\item 
size\_\-t \hyperlink{classPopulation_aa36f5ae24e3d345e60d8cd0a608ff7be}{size} () const 
\begin{DoxyCompactList}\small\item\em Get the current size of the population. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_ac69dc53dfaecace1d92ca425b241f3ae}{adopt} (unique\_\-ptr$<$ \hyperlink{classIndividual}{Individual} $>$ indiv)
\begin{DoxyCompactList}\small\item\em Insert a new individual, obtaining ownership. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_a5a42d2a59c007194fec4d3168807e54d}{clear} ()
\begin{DoxyCompactList}\small\item\em Clear contents; individuals become deleted. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_a70d465c17089d526b4f4fe46155676be}{adoptFrom} (\hyperlink{classPopulation}{Population} \&p1)
\begin{DoxyCompactList}\small\item\em Insert new individuals whose ownership is taken from the other pop. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_a292f40848be7c4ff4197622bed4c3ae0}{adoptFromTwo} (\hyperlink{classPopulation}{Population} \&p1, \hyperlink{classPopulation}{Population} \&p2)
\begin{DoxyCompactList}\small\item\em Insert new individuals whose ownership is taken from two other pops. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_a701c745cecb918e1089fecc1a783e2c6}{deepCopyFrom} (\hyperlink{classPopulation}{Population} \&p1)
\begin{DoxyCompactList}\small\item\em Insert new individuals that are cloned from the other pop. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_afd6e8f86c3fddfa31b0de3d05f9821d2}{evaluate} ()
\begin{DoxyCompactList}\small\item\em Command all individuals to evaluate their objectives. \item\end{DoxyCompactList}\item 
\hypertarget{classPopulation_ad742332f292448803976e57d2eb85501}{
void \hyperlink{classPopulation_ad742332f292448803976e57d2eb85501}{mutate} ()}
\label{classPopulation_ad742332f292448803976e57d2eb85501}

\begin{DoxyCompactList}\small\item\em Command all individuals to mutate, according to their (possibly individually evolving) rules. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_a57ef0c90d59eaf2519904102f2486b62}{improve} (mt19937 $\ast$mt)
\begin{DoxyCompactList}\small\item\em Command all individuals to do local improvement, according to their own, possibly individually evolving or stochastic, rules. \item\end{DoxyCompactList}\item 
int \hyperlink{classPopulation_a7ed23737ff61e82f05a5bf530bd6da10}{binaryTournament} (int ii1, int ii2, mt19937 $\ast$mt)
\begin{DoxyCompactList}\small\item\em Return the index of the winner of a binary tournament. \item\end{DoxyCompactList}\item 
void \hyperlink{classPopulation_a824c12d8fdfd24941990e565cafa2f91}{assignRankAndCrowdingDistance} ()
\begin{DoxyCompactList}\small\item\em Assign ranks and crowding distances to all individuals. \item\end{DoxyCompactList}\item 
\hypertarget{classPopulation_ab50074910888f661f435b6386c546a2b}{
void \hyperlink{classPopulation_ab50074910888f661f435b6386c546a2b}{fillNondominatedSortFrom} (\hyperlink{classPopulation}{Population} \&parent)}
\label{classPopulation_ab50074910888f661f435b6386c546a2b}

\begin{DoxyCompactList}\small\item\em Insert copies of individuals from a parent population, as per the nondominated fill of NSGA-\/II. \item\end{DoxyCompactList}\item 
\hypertarget{classPopulation_a475667b9e5c97bebbe697b745262ff82}{
void {\bfseries selectAndCrossFrom} (\hyperlink{classPopulation}{Population} \&parent, mt19937 $\ast$mt)}
\label{classPopulation_a475667b9e5c97bebbe697b745262ff82}

\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classPopulation_a21f577e03b38fa5a2c498682e638629b}{
void {\bfseries quicksortFrontObj} (int objcount, int $\ast$obj\_\-array, int front\_\-size) const }
\label{classPopulation_a21f577e03b38fa5a2c498682e638629b}

\item 
\hypertarget{classPopulation_a94e1ae20df83a694c374e9e072c51bc6}{
void {\bfseries quicksortDist} (int $\ast$dist, int front\_\-size) const }
\label{classPopulation_a94e1ae20df83a694c374e9e072c51bc6}

\item 
\hypertarget{classPopulation_a537d6d9c2ac4898e1019bf22b488886b}{
void {\bfseries crowdingFillFrom} (\hyperlink{classPopulation}{Population} \&mixed, int count, int front\_\-size, void $\ast$plstelite)}
\label{classPopulation_a537d6d9c2ac4898e1019bf22b488886b}

\item 
\hypertarget{classPopulation_aae7896893db6165d0ad181b5c191bf37}{
void {\bfseries assignCrowdingDistance} (int $\ast$dist, int $\ast$$\ast$obj\_\-array, int front\_\-size)}
\label{classPopulation_aae7896893db6165d0ad181b5c191bf37}

\item 
\hypertarget{classPopulation_a0ed07fc3c7318d32dd754595aef6ee41}{
void {\bfseries assignCrowdingDistanceList} (void $\ast$plst, int front\_\-size)}
\label{classPopulation_a0ed07fc3c7318d32dd754595aef6ee41}

\item 
\hypertarget{classPopulation_a9758cde6889307ef3794feb54b4205eb}{
void {\bfseries assignCrowdingDistanceIndices} (int c1, int c2)}
\label{classPopulation_a9758cde6889307ef3794feb54b4205eb}

\item 
\hypertarget{classPopulation_ab3d56e9d531f0435274b6fb6831ebd8f}{
int {\bfseries binaryTournament} (int a, int b, mt19937 $\ast$mt) const }
\label{classPopulation_ab3d56e9d531f0435274b6fb6831ebd8f}

\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
vector$<$ unique\_\-ptr$<$ \hyperlink{classIndividual}{Individual} $>$ $>$ \hyperlink{classPopulation_a6d2fb60c87a2f768a46fb679df16bd11}{\_\-individuals}
\begin{DoxyCompactList}\small\item\em Pointers to individuals. \item\end{DoxyCompactList}\item 
size\_\-t \hyperlink{classPopulation_a1d79e127aabe18c766de5fb262be2a4c}{\_\-nobj}
\begin{DoxyCompactList}\small\item\em Number of objectives. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
A population of individual solutions; this is the core of a Pareto-\/based memetic algorithm. The population is responsible for the storage of individuals, and dispatching the the operations that produce the next population. The population can also be used as an archive of any number of historical solutions. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classPopulation_a808b87f26504515005c7abf81cebec24}{
\index{Population@{Population}!Population@{Population}}
\index{Population@{Population}!Population@{Population}}
\subsubsection[{Population}]{\setlength{\rightskip}{0pt plus 5cm}Population::Population (int {\em nobj})}}
\label{classPopulation_a808b87f26504515005c7abf81cebec24}


Create a population for individuals that have nobj objectives. 

\subsection{Member Function Documentation}
\hypertarget{classPopulation_ac69dc53dfaecace1d92ca425b241f3ae}{
\index{Population@{Population}!adopt@{adopt}}
\index{adopt@{adopt}!Population@{Population}}
\subsubsection[{adopt}]{\setlength{\rightskip}{0pt plus 5cm}void Population::adopt (unique\_\-ptr$<$ {\bf Individual} $>$ {\em indiv})}}
\label{classPopulation_ac69dc53dfaecace1d92ca425b241f3ae}


Insert a new individual, obtaining ownership. \hypertarget{classPopulation_a70d465c17089d526b4f4fe46155676be}{
\index{Population@{Population}!adoptFrom@{adoptFrom}}
\index{adoptFrom@{adoptFrom}!Population@{Population}}
\subsubsection[{adoptFrom}]{\setlength{\rightskip}{0pt plus 5cm}void Population::adoptFrom ({\bf Population} \& {\em p1})}}
\label{classPopulation_a70d465c17089d526b4f4fe46155676be}


Insert new individuals whose ownership is taken from the other pop. \hypertarget{classPopulation_a292f40848be7c4ff4197622bed4c3ae0}{
\index{Population@{Population}!adoptFromTwo@{adoptFromTwo}}
\index{adoptFromTwo@{adoptFromTwo}!Population@{Population}}
\subsubsection[{adoptFromTwo}]{\setlength{\rightskip}{0pt plus 5cm}void Population::adoptFromTwo ({\bf Population} \& {\em p1}, \/  {\bf Population} \& {\em p2})}}
\label{classPopulation_a292f40848be7c4ff4197622bed4c3ae0}


Insert new individuals whose ownership is taken from two other pops. \hypertarget{classPopulation_a824c12d8fdfd24941990e565cafa2f91}{
\index{Population@{Population}!assignRankAndCrowdingDistance@{assignRankAndCrowdingDistance}}
\index{assignRankAndCrowdingDistance@{assignRankAndCrowdingDistance}!Population@{Population}}
\subsubsection[{assignRankAndCrowdingDistance}]{\setlength{\rightskip}{0pt plus 5cm}void Population::assignRankAndCrowdingDistance ()}}
\label{classPopulation_a824c12d8fdfd24941990e565cafa2f91}


Assign ranks and crowding distances to all individuals. \hypertarget{classPopulation_a7ed23737ff61e82f05a5bf530bd6da10}{
\index{Population@{Population}!binaryTournament@{binaryTournament}}
\index{binaryTournament@{binaryTournament}!Population@{Population}}
\subsubsection[{binaryTournament}]{\setlength{\rightskip}{0pt plus 5cm}int Population::binaryTournament (int {\em ii1}, \/  int {\em ii2}, \/  mt19937 $\ast$ {\em mt})}}
\label{classPopulation_a7ed23737ff61e82f05a5bf530bd6da10}


Return the index of the winner of a binary tournament. Needs a random generator to resolve ties. \hypertarget{classPopulation_a5a42d2a59c007194fec4d3168807e54d}{
\index{Population@{Population}!clear@{clear}}
\index{clear@{clear}!Population@{Population}}
\subsubsection[{clear}]{\setlength{\rightskip}{0pt plus 5cm}void Population::clear ()}}
\label{classPopulation_a5a42d2a59c007194fec4d3168807e54d}


Clear contents; individuals become deleted. \hypertarget{classPopulation_a701c745cecb918e1089fecc1a783e2c6}{
\index{Population@{Population}!deepCopyFrom@{deepCopyFrom}}
\index{deepCopyFrom@{deepCopyFrom}!Population@{Population}}
\subsubsection[{deepCopyFrom}]{\setlength{\rightskip}{0pt plus 5cm}void Population::deepCopyFrom ({\bf Population} \& {\em p1})}}
\label{classPopulation_a701c745cecb918e1089fecc1a783e2c6}


Insert new individuals that are cloned from the other pop. \hypertarget{classPopulation_afd6e8f86c3fddfa31b0de3d05f9821d2}{
\index{Population@{Population}!evaluate@{evaluate}}
\index{evaluate@{evaluate}!Population@{Population}}
\subsubsection[{evaluate}]{\setlength{\rightskip}{0pt plus 5cm}void Population::evaluate ()}}
\label{classPopulation_afd6e8f86c3fddfa31b0de3d05f9821d2}


Command all individuals to evaluate their objectives. \hypertarget{classPopulation_aaccf3417030811fa1db6a785a07a4407}{
\index{Population@{Population}!fromStream@{fromStream}}
\index{fromStream@{fromStream}!Population@{Population}}
\subsubsection[{fromStream}]{\setlength{\rightskip}{0pt plus 5cm}void Population::fromStream (istream \& {\em ist}, \/  const {\bf IndividualReader} $\ast$ {\em rdr})}}
\label{classPopulation_aaccf3417030811fa1db6a785a07a4407}


Insert individuals from a stream, using a concrete reader. \hypertarget{classPopulation_ab9e2c0bbd0dd0752634b356d0e9715a0}{
\index{Population@{Population}!getIndividualID@{getIndividualID}}
\index{getIndividualID@{getIndividualID}!Population@{Population}}
\subsubsection[{getIndividualID}]{\setlength{\rightskip}{0pt plus 5cm}int Population::getIndividualID (int {\em individualIndex}) const}}
\label{classPopulation_ab9e2c0bbd0dd0752634b356d0e9715a0}


Get the unique ID of an individual. \hypertarget{classPopulation_aaedf0bd0b968822b69d7e6b3c977bf3a}{
\index{Population@{Population}!getObjectiveValue@{getObjectiveValue}}
\index{getObjectiveValue@{getObjectiveValue}!Population@{Population}}
\subsubsection[{getObjectiveValue}]{\setlength{\rightskip}{0pt plus 5cm}double Population::getObjectiveValue (int {\em individualIndex}, \/  int {\em objectiveIndex}) const}}
\label{classPopulation_aaedf0bd0b968822b69d7e6b3c977bf3a}


Get one objective value from an indexed individual. \hypertarget{classPopulation_ab51734c346d2b6d0948ff8fdd82dadb7}{
\index{Population@{Population}!getTrace@{getTrace}}
\index{getTrace@{getTrace}!Population@{Population}}
\subsubsection[{getTrace}]{\setlength{\rightskip}{0pt plus 5cm}vector$<$ double $>$ Population::getTrace (int {\em individualIndex}) const}}
\label{classPopulation_ab51734c346d2b6d0948ff8fdd82dadb7}


Get the vector of traced values from an indexed individual. \hypertarget{classPopulation_a57ef0c90d59eaf2519904102f2486b62}{
\index{Population@{Population}!improve@{improve}}
\index{improve@{improve}!Population@{Population}}
\subsubsection[{improve}]{\setlength{\rightskip}{0pt plus 5cm}void Population::improve (mt19937 $\ast$ {\em mt})}}
\label{classPopulation_a57ef0c90d59eaf2519904102f2486b62}


Command all individuals to do local improvement, according to their own, possibly individually evolving or stochastic, rules. A thread-\/specific random generator must always be given, because some operators may require randomization. \hypertarget{classPopulation_a611533865c5a476c3b0f3043d311a8c7}{
\index{Population@{Population}!setIndividualID@{setIndividualID}}
\index{setIndividualID@{setIndividualID}!Population@{Population}}
\subsubsection[{setIndividualID}]{\setlength{\rightskip}{0pt plus 5cm}void Population::setIndividualID (int {\em individualIndex}, \/  int {\em newID})}}
\label{classPopulation_a611533865c5a476c3b0f3043d311a8c7}


Set the unique ID of an individual. \hypertarget{classPopulation_aa36f5ae24e3d345e60d8cd0a608ff7be}{
\index{Population@{Population}!size@{size}}
\index{size@{size}!Population@{Population}}
\subsubsection[{size}]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t Population::size () const}}
\label{classPopulation_aa36f5ae24e3d345e60d8cd0a608ff7be}


Get the current size of the population. \hypertarget{classPopulation_a121e35f8e7d6695bc790e9674851cc14}{
\index{Population@{Population}!toStream@{toStream}}
\index{toStream@{toStream}!Population@{Population}}
\subsubsection[{toStream}]{\setlength{\rightskip}{0pt plus 5cm}void Population::toStream (ostream \& {\em ost}) const}}
\label{classPopulation_a121e35f8e7d6695bc790e9674851cc14}


Write all individuals to a stream. 

\subsection{Member Data Documentation}
\hypertarget{classPopulation_a6d2fb60c87a2f768a46fb679df16bd11}{
\index{Population@{Population}!\_\-individuals@{\_\-individuals}}
\index{\_\-individuals@{\_\-individuals}!Population@{Population}}
\subsubsection[{\_\-individuals}]{\setlength{\rightskip}{0pt plus 5cm}vector$<$unique\_\-ptr$<${\bf Individual}$>$ $>$ {\bf Population::\_\-individuals}\hspace{0.3cm}{\ttfamily  \mbox{[}protected\mbox{]}}}}
\label{classPopulation_a6d2fb60c87a2f768a46fb679df16bd11}


Pointers to individuals. FIXME: Expect some brainwork with the pointers and the issue of who should own each individual! \hypertarget{classPopulation_a1d79e127aabe18c766de5fb262be2a4c}{
\index{Population@{Population}!\_\-nobj@{\_\-nobj}}
\index{\_\-nobj@{\_\-nobj}!Population@{Population}}
\subsubsection[{\_\-nobj}]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t {\bf Population::\_\-nobj}\hspace{0.3cm}{\ttfamily  \mbox{[}protected\mbox{]}}}}
\label{classPopulation_a1d79e127aabe18c766de5fb262be2a4c}


Number of objectives. FIXME: Shouldn't require this in the general \hyperlink{classPopulation}{Population}, but only in some friend class that operates on the population? 

The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
src/Population.hpp\item 
src/Population.cpp\item 
src/Population\_\-Old.cpp\end{DoxyCompactItemize}
