diff options
| author | Mike Buland <mike@xagasoft.com> | 2012-07-09 12:01:50 -0600 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2012-07-09 12:01:50 -0600 |
| commit | 1f7c135934b6604c5409d4b6f34861105c0a64cb (patch) | |
| tree | cc421e2e8620b72e202f0eddf2cd5f1478d3bc06 /src/explicitsimulation.h | |
| parent | 40ee7ad5aeadeb9823e1cd6e1218a1999c608a65 (diff) | |
| download | libgenetic-1f7c135934b6604c5409d4b6f34861105c0a64cb.tar.gz libgenetic-1f7c135934b6604c5409d4b6f34861105c0a64cb.tar.bz2 libgenetic-1f7c135934b6604c5409d4b6f34861105c0a64cb.tar.xz libgenetic-1f7c135934b6604c5409d4b6f34861105c0a64cb.zip | |
It works well enough to solve polynomial maxima.
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 | ||
