freESDominantRecombinator.txx

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: freESDominantRecombinator.txx,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 _freESDominantRecombinator_txx
00023 #define _freESDominantRecombinator_txx
00024 
00025 #include "freESDominantRecombinator.h"
00026 
00027 namespace FREE
00028 {
00029   namespace ES
00030   {
00031 
00032 
00033     template <class TIndividual>
00034     DominantRecombinator<TIndividual>
00035       ::DominantRecombinator()
00036     {
00037       m_RandomGenerator = VariateGeneratorType::New();
00038       m_RandomGenerator->Initialize((int)clock());
00039     }
00040 
00041     template <class TIndividual>
00042     typename DominantRecombinator<TIndividual>::IndividualPointer
00043       DominantRecombinator<TIndividual>
00044       ::Recombine(const ParentSelectionType& parents) const
00045     {
00046       if (!(parents.size()>0)) throwExceptionMacro("Error. At least one parent is needed for recombination.");
00047 
00048       IndividualPointer newIndividual = parents[0]->Clone();
00049 
00050       for (unsigned int index = 0; index<newIndividual->ObjectiveParameters().size(); index++)
00051       {
00052         VariateGeneratorType::IntegerType parentIndex = m_RandomGenerator->GetIntegerVariate(parents.size()-1);
00053         (newIndividual->ObjectiveParameters())[index] = (parents[parentIndex]->ObjectiveParameters())[index];
00054       }
00055       
00056       for (unsigned int index = 0; index<newIndividual->StrategicParameters().size(); index++)
00057       {
00058         if ( newIndividual->StrategicParameters().at(index)->GetHandling()!= IndividualType::StrategicParameterType::HDynamic)
00059         {
00060           VariateGeneratorType::IntegerType parentIndex = m_RandomGenerator->GetIntegerVariate(parents.size()-1);
00061           (newIndividual->StrategicParameters())[index] = (parents[parentIndex]->StrategicParameters())[index];
00062         }
00063       }
00064       return newIndividual;
00065     }
00066 
00067     template <class TIndividual>
00068     typename DominantRecombinator<TIndividual>::WeightVectorType
00069     DominantRecombinator<TIndividual>
00070     ::GetWeights(const unsigned long lParentCount) const
00071     {
00072       WeightVectorType weights;
00073       weights.resize(lParentCount,0.0);
00074       if (lParentCount) weights[0] = 1.0;
00075       return weights;
00076     };
00077 
00078   } // end of namespace ES
00079 } // end of namespace FREE
00080 
00081 #endif

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