00001 /***************************************************************************** 00002 * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch) 00003 ***************************************************************************** 00004 * Project : Zeus Math Library 00005 * Module : GAIndividual 00006 * Package : Zeus.ZeusMath.Intel 00007 * Author : Benjamin Hadorn 00008 * Date : 27.12.2011 00009 * System : Zeus-Framework 00010 ***************************************************************************** 00011 * Licence: * 00012 * This library is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU Lesser General Public License as * 00014 * published by the Free Software Foundation; either version * 00015 * 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 * Changes: 00029 * 27.12.2011 bha: created zeus 2.0 00030 *****************************************************************************/ 00031 00032 #ifndef GAIndividualH 00033 #define GAIndividualH 00034 00035 #include <zeusmath/Intel/Interfaces/IGAIndividual.hpp> 00036 #include <zeusbase/System/ZObject.h> 00037 #include <zeusbase/System/ArrayList.hpp> 00038 00039 BEGIN_NAMESPACE_Zeus 00040 00041 /**************************************************************************/ 00044 /**************************************************************************/ 00045 zeusmath_class TGAIndividual : public TZObject, public IGAIndividual 00046 { 00047 public: 00048 TGAIndividual(); 00049 00050 //Methods of IGAIndividual 00051 virtual Float MQUALIFIER getFitness()const=0; 00052 virtual Int MQUALIFIER getChromosomeCount()const; 00053 virtual Retval MQUALIFIER getChromosome(Int iIndex, IGAChromosome*& rpChromosome) const; 00054 virtual void MQUALIFIER addChromosome(IGAChromosome& rChromosome); 00055 virtual void MQUALIFIER createChromosomes()=0; 00056 virtual void MQUALIFIER getDescription(IString& rValue)const; 00057 virtual bool MQUALIFIER canMutate() const; 00058 00059 //Methods of IZUnknown 00060 MEMORY_MANAGER_DECL 00061 00062 protected: 00063 virtual ~TGAIndividual(); 00064 00066 TArrayList<IGAChromosome*> m_lstChromosomes; 00068 bool m_bCanMutate; 00069 }; 00070 00071 //Inline methods 00072 /**************************************************************************/ 00075 /**************************************************************************/ 00076 inline long MQUALIFIER TGAIndividual::getChromosomeCount() const 00077 { 00078 return m_lstChromosomes.getCount(); 00079 } 00080 00081 /**************************************************************************/ 00084 /**************************************************************************/ 00085 inline void MQUALIFIER TGAIndividual::addChromosome(IGAChromosome& rChromosome) 00086 { 00087 m_lstChromosomes.add(&rChromosome); 00088 rChromosome.addRef(); 00089 } 00090 00091 /**************************************************************************/ 00094 /**************************************************************************/ 00095 inline void MQUALIFIER TGAIndividual::getDescription(IString& rValue)const 00096 { 00097 rValue.assign(L"none"); 00098 } 00099 00100 /**************************************************************************/ 00103 /**************************************************************************/ 00104 inline bool MQUALIFIER TGAIndividual::canMutate() const 00105 { 00106 return m_bCanMutate; 00107 } 00108 00109 00110 END_NAMESPACE_Zeus 00111 00112 #endif