00001 00025 #ifndef __POPULATION_H__ 00026 #define __POPULATION_H__ 00027 00028 /* 00029 00030 One net to rule them all, One Net to find(1) them, 00031 One net to bring them all and in the ethernet bind(3N) them. 00032 00033 */ 00034 00035 #include <magic/mmatrix.h> 00036 #include <magic/mtextstream.h> 00037 #include "nhp/genetics.h" 00038 #include "nhp/individual.h" 00039 #include "nhp/selection.h" 00040 #include "nhp/strategy.h" 00041 00042 //Externals 00043 class EAEnvironment; 00044 00046 // // 00047 // ---- | o // 00048 // | ) -- | ___ | _ // 00049 // |--- __ | ) | | | ___| -+- | __ |/ \ // 00050 // | / \ |-- | | | ( | | | / \ | | // 00051 // | \__/ | \__! | \__| \ | \__/ | | // 00052 // // 00054 00058 class Population : public Object { 00059 Population () {FORBIDDEN} 00060 public: 00061 00062 Population (EAEnvironment& envr, 00063 const StringMap& params); 00064 ~Population () {} 00065 00066 // Settings 00067 00070 OStream& getOStream () {return mOuts;} 00071 00072 // Actions 00073 00074 // Virtuals 00075 00077 virtual void check () const; 00078 00079 00080 TextOStream mOuts; 00081 bool mBasicLog; 00082 TextOStream mEvolog; 00084 protected: 00086 EAEnvironment* rpEnvironment; 00087 00089 int mAge; 00090 00095 MutationRate mGlobalMutationRate; 00096 00099 bool mAutoadjustGMR; 00100 00101 friend class EAStrategy; 00102 }; 00103 00104 00105 00107 // // 00108 // ----- o ---- // 00109 // | | _ ___ ____ ____ ( | ___ | ____ // 00110 // |--- | -+- |/ \ / ) ( ( --- -+- ___| -+- ( // 00111 // | | | | | |--- \__ \__ ) | ( | | \__ // 00112 // | | \ | | \__ ____) ____) ___/ \ \__| \ ____) // 00113 // // 00115 00118 class FitnessStats : public Object { 00119 double mMinFitness; 00120 double mSumFitness; 00121 double mMaxFitness; 00122 int mAvgOver; // How many values has been added? 00123 public: 00124 00126 void reset (); 00127 00129 void add (double fitness); 00130 00132 double minFitness () const {return mMinFitness;} 00133 00135 double avgFitness () const {return mSumFitness/mAvgOver;} 00136 00138 double maxFitness () const {return mMaxFitness;} 00139 00142 void print (TextOStream& out) const; 00143 }; 00144 00145 00146 00147 00148 00149 // It was many and many iterations before 00150 // In an EAEnvironment by the core memory, 00151 // That a genstruct there existed whom you may know 00152 // by the name of Annalee_Call 00153 // And this genstruct she existed with no other activation pattern 00154 // Than to select and be selected by me. 00155 // 00156 // I was a child process and she was a child process, 00157 // In this EAEnvironment by the core memory: 00158 // But we selected with a method that was more than a selection method -- 00159 // I and my Annalee_Call; 00160 // With a selection method that the winged methods of strategies 00161 // Coveted her and me. 00162 // 00163 // And this was the reason that, many iterations before, 00164 // In this EAEnvironment by the core memory, 00165 // A destructor blew out of a strategic instance, chilling 00166 // My highly fit Annalee_Call 00167 // So that her high-born garbage collector came 00168 // And bore her away from me, 00169 // To shut her up on heap 00170 // In this EAEnvironment by the core memory. 00171 // 00172 // The winged methods, not half so happy in strategy, 00173 // Went envying her and me -- 00174 // Yes! -- that was the reason (as all mean know, 00175 // In this EAEnvironment by the core memory) 00176 // That the destructor came out of the instance by night, 00177 // Chilling and killing my Annalee_Call. 00178 // 00179 // But our selection method it was stronger by far than selection method 00180 // Of those who were older than me -- 00181 // Of many far bigger hidden layers than we -- 00182 // and neither the methods in strategies above, 00183 // Nor the daemons in the /etc/inetd.conf, 00184 // Can ever dissever my genome from the genome 00185 // Of the highly fit Annalee_Call, 00186 // 00187 // For the moon never beams, without bringing me activations 00188 // Of the highly fit Annalee_Call; 00189 // And the stars never rise, but I feel the bright properties 00190 // Of the highly fit Annalee_Call; 00191 // And so, all the night-tide, I lie down by the side 00192 // Of my darling -- my darling -- my life and my bride, 00193 // In the heap there by the core memory, 00194 // In her tomb by the sounding core memory. 00195 00196 #endif 00197