Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

simplepopulation.h

Go to the documentation of this file.
00001 
00002 #include <population.h>
00003 
00005 //                                                                           //
00006 //  ---- o            |       ----                  |           o            //
00007 // (              --  |  ___  |   )       --        |  ___   |           _   //
00008 //  ---  | |/|/| |  ) | /   ) |---   __  |  ) |   | |  ___| -+- |  __  |/ \  //
00009 //     ) | | | | |--  | |---  |     /  \ |--  |   | | (   |  |  | /  \ |   | //
00010 // ___/  | | | | |    |  \__  |     \__/ |     \__! |  \__|   \ | \__/ |   | //
00011 //                                                                           //
00013 
00014 class SimplePopulation : public Population {
00015     // The current set of individuals in the population
00016     Array<Individual>*      population;
00017 
00018     // Some statistics of the current population
00019     FitnessStats            mFitnessStats;
00020 
00021     // Number of elites, individuals who will survive intact to the
00022     // next generation
00023     int                     mElites;
00024     bool                    mUseGlobalElites;
00025 
00026     SelectionPrms           mSelectionParams;
00027     
00028     // Global micro portion The number of potential parents. The
00029     // semantics are dependent on the evolutionary strategy used
00030     bool                    mUseGlobalMicro;
00031 
00032     // Global q parameter for tournament selection
00033     bool                    mUseGlobalQ;
00034 
00035     // Global etaPlus parameter for linear ranking selection
00036     bool                    mUseGlobalEtaPlus;
00037     
00038     // Global mutation rate in the population. This is coefficient for
00039     // the mutation rate of each individual gene and defaults to 1.0
00040     MutationRate            mGlobalMutationRate;
00041 
00042     // Should the global mutation rate be adjusted automatically?
00043     bool                    autoadj_gmr;
00044 
00045   public:
00046 
00047     // Minimum allowed similarity between genomes
00048     double                  minsimilarity;
00049     
00050     // Constructs a binary population of the given size
00051                             SimplePopulation        (EAEnvironment& envr,
00052                                              const StringMap& params);
00053 
00054                             ~SimplePopulation       ();
00055     
00056     double                  evolve          (int generations, const char* savefile=NULL,
00057                                          double trg_fitn=-1);
00058 
00059     // Returns an individual in the population by it's index number
00060     const Individual&       operator[]		(int i) const {return (*population)[i];}
00061 
00062     // Same non-const
00063     Individual&             operator[]		(int i) {return (*population)[i];}
00064     
00065     // Returns the number of individuals in the population
00066     int                     size            () const {return population->size;}
00067 
00068     // Dumps the population to given output
00069     void                    print           (DataOStream& out) const;
00070 
00071     // Writes an one-line generation report to the given stream
00072     void                    report          (OStream& log) const;
00073 
00074     // Returns the current strategy
00075     const EAStrategy&       getstrategy     () const {return *strategy;}
00076 
00077     // Returns the number of times the population has been evaluated
00078     // (i.e., the generation)
00079     int                     getAge          () const {return mAge;}
00080 
00081     // Set the global mutation rate
00082     MutationRate&           mutRate         () {return mGlobalMutationRate;}
00083 
00084     SelectionPrms&          selParams       () {return mSelectionParams;}
00085     const SelectionPrms&    selParams       () const {return mSelectionParams;}
00086 
00087     // Resets the fitness averaging of individuals. Useful when
00088     // changing the objective function (old fitness values would be
00089     // invalid).
00090     void                    resetFitnesses  ();
00091 
00092     void                    check           () const;
00093     
00094   private:
00095 
00096     // Evaluates the population in an environment
00097     void                    evaluate        (EAEnvironment& envr, OStream& out);
00098 
00099     // Add population-dependent features to a genome. I suppose there
00100     // might be some use for this. Maybe.
00101     void                    addFeaturesTo   (Genome& genome) const;
00102 
00103     friend EAStrategy;
00104     /*
00105     friend CommonStrategy;
00106     friend CommaStrategy;
00107     friend PlusStrategy;
00108     */
00109     friend SelectionMatrix;
00110 };
00111 

Generated on Thu Feb 10 20:12:01 2005 for NeHeP by doxygen1.2.18