From 8a0d33b5ebb3497d158f2d5c050c69be3fcd1e0d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 5 Aug 2012 01:26:45 -0600 Subject: Added option to recalculate survivors. This accomidates simulations where the test conditions can change as the simulation runs, which would effect the scores of phenotypes that have already been tested. --- src/explicitsimulation.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/explicitsimulation.cpp') diff --git a/src/explicitsimulation.cpp b/src/explicitsimulation.cpp index 98df0b0..95b721b 100644 --- a/src/explicitsimulation.cpp +++ b/src/explicitsimulation.cpp @@ -13,12 +13,13 @@ using namespace Bu; Genetic::ExplicitSimulation::ExplicitSimulation( Genetic::Operator *pOper, Genetic::FitnessFunction *pFunc, int iThreads, int iPopSize, - float fKeep, float fRandom, bool bKeepBest ) : + float fKeep, float fRandom, bool bKeepBest, bool bRecalcSurvivors ) : pOper( pOper ), iPopSize( iPopSize ), fKeep( fKeep ), fRandom( fRandom ), bKeepBest( bKeepBest ), + bRecalcSurvivors( bRecalcSurvivors ), bRunning( true ) { for( int j = 0; j < iPopSize; j++ ) @@ -102,7 +103,10 @@ void Genetic::ExplicitSimulation::timestep() // Refill the population mFitness.lock(); - hFitness = hTempFitness; + if( bRecalcSurvivors ) + hFitness.clear(); + else + hFitness = hTempFitness; mFitness.unlock(); xPop.clear(); xPop.timestep(); -- cgit v1.2.3