00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GENOME_H
00021 #define GENOME_H
00022
00023 #include "gaconfig.h"
00024 #include "parametersettable.h"
00025 #include "core/genotype.h"
00026 #include <QVector>
00027
00028 namespace farsa {
00029
00040 class FARSA_GA_API Genome : public ParameterSettableWithConfigureFunction {
00041 public:
00043 Genome();
00048 Genome( unsigned int numGenotype, unsigned int numBits );
00055 Genome( unsigned int numGenotype, const Genotype* prototype );
00057 Genome( const Genome& genome );
00062 ~Genome();
00064 Genome& operator=( const Genome& right );
00071 virtual void configure( ConfigurationParameters& params, QString prefix );
00078 virtual void save( ConfigurationParameters& params, QString prefix );
00080 static void describe( QString type );
00081
00083 unsigned int size() const;
00087 void clearAll();
00089 void append( const Genotype* );
00091 Genotype* at( unsigned int i );
00093 const Genotype* at( unsigned int i ) const;
00095 Genotype* last();
00097 const Genotype* last() const;
00101 unsigned int find( const Genotype* g );
00103 void set( unsigned int i, Genotype* g );
00105 const Genotype* operator[]( unsigned int i ) const;
00107 Genotype* operator[]( unsigned int i );
00109 Genotype* prototypeGenotype() {
00110 return prototype;
00111 };
00113 void randomize();
00115 QVector<Genotype*>::iterator begin() {
00116 return data.begin();
00117 };
00119 QVector<Genotype*>::const_iterator begin() const {
00120 return data.begin();
00121 };
00123 QVector<Genotype*>::iterator end() {
00124 return data.end();
00125 };
00127 QVector<Genotype*>::const_iterator end() const {
00128 return data.end();
00129 };
00130
00131 private:
00133 QVector<Genotype*> data;
00135 Genotype* prototype;
00136 };
00137
00138 }
00139
00140 #endif