freESIndividual.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freESIndividual.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 #ifndef __freESIndividual_h
00023 #define __freESIndividual_h
00024 
00025 #include "freESStrategicParameters.h"
00026 
00027 #include "itkLightObject.h"
00028 
00029 namespace FREE
00030 {
00031 
00032   namespace ES
00033   {
00037     template <class TOPValueType, class TSPValueType, class TOValueType>
00038     class ITK_EXPORT Individual :
00039       public itk::LightObject
00040     {
00041     public:
00042       /* Standard class typedefs. */
00043       typedef Individual<TOPValueType, TSPValueType, TOValueType> Self;
00044       typedef itk::LightObject Superclass;
00045       typedef itk::SmartPointer<Self> Pointer;
00046       typedef itk::SmartPointer<const Self> ConstPointer;
00047 
00048       /* Method for creation through the object factory. */
00049       itkNewMacro(Self);
00050 
00051       /* Run-time type information (and related methods). */
00052       itkTypeMacro(Individual, LightObject);
00053 
00054       /* Other typedefs */
00055       typedef TOPValueType                                            ObjectiveParameterType;
00056       typedef std::vector<ObjectiveParameterType>                     ObjectiveParametersType;
00057 
00058       typedef TSPValueType                                            StrategicParameterValueType;
00059       typedef StrategicParameter<TSPValueType>                        StrategicParameterType;
00060       typedef typename StrategicParameterType::Pointer                StrategicParameterPointer;
00061       typedef StrategicParameters<TSPValueType>                       StrategicParametersType;
00062       typedef typename StrategicParametersType::Pointer               StrategicParametersPointer;
00063       typedef typename StrategicParameter<TSPValueType>::OriginIDType StrategicOriginIDType;
00064       typedef typename StrategicParameter<TSPValueType>::HandlingType StrategicParameterHandlingType;
00065 
00066       typedef TOValueType                                             ObjectiveValueType;
00067 
00068       typedef unsigned long ParameterIDType;
00069       typedef std::vector<ParameterIDType> ParameterIDsType;
00070 
00071       typedef unsigned long GenerationIDType;
00072 
00073       typedef unsigned long IndividualIDType;
00074 
00075       const ObjectiveParametersType& ObjectiveParameters() const
00076       {
00077         return m_ObjectiveParameters;
00078       };
00079 
00080       ObjectiveParametersType& ObjectiveParameters()
00081       {
00082         return m_ObjectiveParameters;
00083       };
00084 
00085       void ResetObjectiveParameters()
00086       {
00087         m_ObjectiveParameters.clear();
00088       };
00089 
00090       const StrategicParametersType& StrategicParameters() const
00091       {
00092         return *(m_StrategicParameters.GetPointer());
00093       };
00094 
00095       StrategicParametersType& StrategicParameters()
00096       {
00097         return *(m_StrategicParameters.GetPointer());
00098       };
00099 
00100       void ResetStrategicParameters()
00101       {
00102         m_StrategicParameters->clear();
00103       };
00104 
00105       GenerationIDType GetGenerationID() const {return m_GenerationID;};
00106       void SetGenerationID(GenerationIDType id) {m_GenerationID = id;};
00107       
00108       IndividualIDType GetIndividualID() const {return m_IndividualID;};
00109       void SetIndividualID(IndividualIDType id) {m_IndividualID = id;};
00110 
00111       ObjectiveValueType GetObjectiveValue() const {return m_ObjectiveValue;};
00112       void SetObjectiveValue(ObjectiveValueType value)
00113       {
00114         m_ObjectiveValue = value;
00115         m_ObjectiveValueIsSet = true;
00116       };
00117 
00118       bool GetObjectiveValueIsSet() const {return m_ObjectiveValueIsSet;};
00119 
00120       void ResetObjectiveValue()
00121       {
00122         m_ObjectiveValue = 0.0;
00123         m_ObjectiveValueIsSet = false;
00124       }
00125 
00126       virtual Pointer Clone() const;
00127 
00128       void operator=(Self const& individual);
00129 
00130       static bool ObjectiveValueIsGreater(const Self* pInd1, const Self* pInd2)
00131       {
00132         if (pInd1==0) throwStaticExceptionMacro("Error, passed individual 1 pointer is NULL.");
00133         if (pInd2==0) throwStaticExceptionMacro("Error, passed individual 2 pointer is NULL.");
00134         return pInd1->GetObjectiveValue() > pInd2->GetObjectiveValue(); 
00135       };
00136 
00137       static bool ObjectiveValueIsLesser(const Self* pInd1, const Self* pInd2)
00138       {
00139         if (pInd1==0) throwStaticExceptionMacro("Error, passed individual 1 pointer is NULL.");
00140         if (pInd2==0) throwStaticExceptionMacro("Error, passed individual 2 pointer is NULL.");
00141         return pInd1->GetObjectiveValue() < pInd2->GetObjectiveValue(); 
00142       };
00143     
00144     protected:
00147       Individual();
00148 
00149       virtual ~Individual(){};
00150 
00151       ObjectiveParametersType     m_ObjectiveParameters;
00152       StrategicParametersPointer  m_StrategicParameters;
00153 
00154       GenerationIDType m_GenerationID;
00155 
00156       IndividualIDType m_IndividualID;
00157 
00158       ObjectiveValueType m_ObjectiveValue;
00159 
00160       bool m_ObjectiveValueIsSet;
00161 
00162       virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
00163 
00164     private:
00165       Individual(Self const&); // Purposely not implemented.
00166     };
00167 
00168   } //end namspsace ES
00169 } // end namespace FREE
00170 
00171 #ifndef ITK_MANUAL_INSTANTIATION
00172 #include "freESIndividual.txx"
00173 #endif
00174 
00175 #endif // __freESIndividuals_h

Generated at Sat Oct 13 15:53:36 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000