00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freESPopulation_txx
00023 #define __freESPopulation_txx
00024
00025 #include "freESPopulation.h"
00026
00027 namespace FREE
00028 {
00029 namespace ES
00030 {
00031
00032 template <class TIndividual>
00033 Population<TIndividual> ::
00034 Population(): m_UniqueID(0), m_GenerationID(0)
00035 {
00036 m_StrategicParameters = StrategicParametersType::New();
00037 m_BestIndividualEver = NULL;
00038 m_BestIndividual = NULL;
00039 }
00040
00041 template <class TIndividual>
00042 void
00043 Population<TIndividual> ::
00044 PrintSelf(std::ostream& os, itk::Indent indent) const
00045 {
00046 os << indent << "GID: " << this->GetGenerationID() << std::endl;
00047 os << indent << "last unique IID: " << this->m_UniqueID << std::endl;
00048 os << indent << "Individuals: " << std::endl;
00049
00050 typename Self::const_iterator pos;
00051 for (pos = this->begin(); pos!=this->end(); ++pos)
00052 {
00053 (*pos)->Print(os, indent.GetNextIndent());
00054 os << std::endl;
00055 }
00056 };
00057
00058 template <class TIndividual>
00059 typename Population<TIndividual>::IndividualType*
00060 Population<TIndividual> ::
00061 GetIndividualByUniqueID(IndividualIDType iID)
00062 {
00063 typename Self::iterator pos;
00064 for (pos = this->begin(); pos!=this->end(); ++pos)
00065 {
00066 if ((*pos)->GetIndividualID()== iID) return (*pos).GetPointer();
00067 }
00068 return 0;
00069 };
00070
00071 template <class TIndividual>
00072 typename Population<TIndividual>::Pointer
00073 Population<TIndividual> ::
00074 Clone() const
00075 {
00076 Pointer newPopulation = Self::New();
00077 *(newPopulation.GetPointer()) = *this;
00078 return newPopulation;
00079 };
00080
00081 template <class TIndividual>
00082 void
00083 Population<TIndividual> ::
00084 operator=(Self const& population)
00085 {
00086 m_UniqueID = population.GetLastUniqueIndividualID();
00087 m_GenerationID = population.GetGenerationID();
00088
00089 this->clear();
00090
00091 for (typename Self::const_iterator pos = population.begin(); pos!=population.end(); ++pos)
00092 {
00093 IndividualPointer indi = (*pos)->Clone();
00094 InsertElement(indi->GetIndividualID(), indi);
00095 }
00096 };
00097
00098 }
00099 }
00100
00101
00102 #endif // __freESPopulation_txx