From 1f7c135934b6604c5409d4b6f34861105c0a64cb Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 9 Jul 2012 12:01:50 -0600 Subject: It works well enough to solve polynomial maxima. --- src/explicitsimulation.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/explicitsimulation.h (limited to 'src/explicitsimulation.h') 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 @@ +#ifndef GENETIC_EXPLICIT_SIMULATION_H +#define GENETIC_EXPLICIT_SIMULATION_H + +#include "genetic/population.h" +#include "genetic/config.h" + +namespace Genetic +{ + class Operator; + class FitnessFunction; + + class ExplicitSimulation + { + public: + ExplicitSimulation( Operator *pOper, FitnessFunction *pFunc, + int iPopSize, float fKeep, float fRandom, bool bKeepBest=true ); + virtual ~ExplicitSimulation(); + + void timestep(); + + Genetic::PhenotypeId selectWeighted(); + + double getMinFitness() const { return dMinFitness; } + double getMaxFitness() const { return dMaxFitness; } + + protected: + void updateFitness(); + + protected: + Population xPop; + Operator *pOper; + FitnessFunction *pFunc; + + private: + int iPopSize; + float fKeep; + float fRandom; + bool bKeepBest; + typedef Bu::Hash FitnessHash; + FitnessHash hFitness; + double dMinFitness; + double dMaxFitness; + double dTotalFitness; + PhenotypeId uMaxFitness; + }; +}; + +#endif -- cgit v1.2.3