diff options
Diffstat (limited to '')
-rw-r--r-- | src/explicitsimulation.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
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; | |||
13 | 13 | ||
14 | Genetic::ExplicitSimulation::ExplicitSimulation( Genetic::Operator *pOper, | 14 | Genetic::ExplicitSimulation::ExplicitSimulation( Genetic::Operator *pOper, |
15 | Genetic::FitnessFunction *pFunc, int iThreads, int iPopSize, | 15 | Genetic::FitnessFunction *pFunc, int iThreads, int iPopSize, |
16 | float fKeep, float fRandom, bool bKeepBest ) : | 16 | float fKeep, float fRandom, bool bKeepBest, bool bRecalcSurvivors ) : |
17 | pOper( pOper ), | 17 | pOper( pOper ), |
18 | iPopSize( iPopSize ), | 18 | iPopSize( iPopSize ), |
19 | fKeep( fKeep ), | 19 | fKeep( fKeep ), |
20 | fRandom( fRandom ), | 20 | fRandom( fRandom ), |
21 | bKeepBest( bKeepBest ), | 21 | bKeepBest( bKeepBest ), |
22 | bRecalcSurvivors( bRecalcSurvivors ), | ||
22 | bRunning( true ) | 23 | bRunning( true ) |
23 | { | 24 | { |
24 | for( int j = 0; j < iPopSize; j++ ) | 25 | for( int j = 0; j < iPopSize; j++ ) |
@@ -102,7 +103,10 @@ void Genetic::ExplicitSimulation::timestep() | |||
102 | 103 | ||
103 | // Refill the population | 104 | // Refill the population |
104 | mFitness.lock(); | 105 | mFitness.lock(); |
105 | hFitness = hTempFitness; | 106 | if( bRecalcSurvivors ) |
107 | hFitness.clear(); | ||
108 | else | ||
109 | hFitness = hTempFitness; | ||
106 | mFitness.unlock(); | 110 | mFitness.unlock(); |
107 | xPop.clear(); | 111 | xPop.clear(); |
108 | xPop.timestep(); | 112 | xPop.timestep(); |