diff options
Diffstat (limited to 'src/explicitsimulation.h')
-rw-r--r-- | src/explicitsimulation.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/explicitsimulation.h b/src/explicitsimulation.h new file mode 100644 index 0000000..ebddd62 --- /dev/null +++ b/src/explicitsimulation.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #ifndef GENETIC_EXPLICIT_SIMULATION_H | ||
2 | #define GENETIC_EXPLICIT_SIMULATION_H | ||
3 | |||
4 | #include "genetic/population.h" | ||
5 | #include "genetic/config.h" | ||
6 | |||
7 | namespace Genetic | ||
8 | { | ||
9 | class Operator; | ||
10 | class FitnessFunction; | ||
11 | |||
12 | class ExplicitSimulation | ||
13 | { | ||
14 | public: | ||
15 | ExplicitSimulation( Operator *pOper, FitnessFunction *pFunc, | ||
16 | int iPopSize, float fKeep, float fRandom, bool bKeepBest=true ); | ||
17 | virtual ~ExplicitSimulation(); | ||
18 | |||
19 | void timestep(); | ||
20 | |||
21 | Genetic::PhenotypeId selectWeighted(); | ||
22 | |||
23 | double getMinFitness() const { return dMinFitness; } | ||
24 | double getMaxFitness() const { return dMaxFitness; } | ||
25 | |||
26 | protected: | ||
27 | void updateFitness(); | ||
28 | |||
29 | protected: | ||
30 | Population xPop; | ||
31 | Operator *pOper; | ||
32 | FitnessFunction *pFunc; | ||
33 | |||
34 | private: | ||
35 | int iPopSize; | ||
36 | float fKeep; | ||
37 | float fRandom; | ||
38 | bool bKeepBest; | ||
39 | typedef Bu::Hash<Genetic::PhenotypeId, double> FitnessHash; | ||
40 | FitnessHash hFitness; | ||
41 | double dMinFitness; | ||
42 | double dMaxFitness; | ||
43 | double dTotalFitness; | ||
44 | PhenotypeId uMaxFitness; | ||
45 | }; | ||
46 | }; | ||
47 | |||
48 | #endif | ||