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/population.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/population.h') diff --git a/src/population.h b/src/population.h index 0fdad32..c2d1bec 100644 --- a/src/population.h +++ b/src/population.h @@ -1,13 +1,49 @@ #ifndef GENETIC_POPULATION_H #define GENETIC_POPULATION_H +#include +#include +#include + +#include "genetic/config.h" + namespace Genetic { + class Phenotype; + class Population { public: Population(); virtual ~Population(); + + typedef Bu::Hash PhenotypeHash; + typedef PhenotypeHash::iterator iterator; + typedef PhenotypeHash::const_iterator const_iterator; + + iterator begin() { return hPhenotype.begin(); } + const_iterator begin() const { return hPhenotype.begin(); } + int getSize() const { return hPhenotype.getSize(); } + + PhenotypeId addPhenotype( Phenotype *pNew ); + Phenotype *getPhenotype( PhenotypeId id ) + { return hPhenotype.get( id ); } + bool hasProperty( PhenotypeId id, const Bu::String &sKey ) const; + Bu::Variant getProperty( PhenotypeId id, const Bu::String &sKey ) const; + void setProperty( PhenotypeId id, const Bu::String &sKey, + Bu::Variant vValue ); + void delPhenotype( PhenotypeId id ); + Phenotype *takePhenotype( PhenotypeId id ); + void clear(); + + PhenotypeId timestep(); + PhenotypeId time() const; + + private: + PhenotypeId uNextId; + PhenotypeId uTime; + PhenotypeHash hPhenotype; + mutable Bu::Mutex mGeneral; }; }; -- cgit v1.2.3