diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2019-08-08 15:30:47 -0700 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2019-08-08 15:30:47 -0700 |
| commit | 042038dff89fa3a63e6613ade4540c7347cab953 (patch) | |
| tree | 8dc67b22f9c4255adb30ccecbd5db56b14e854df | |
| parent | ca9f059a4295db6269728b0b747036f995c777a9 (diff) | |
| download | libgenetic-042038dff89fa3a63e6613ade4540c7347cab953.tar.gz libgenetic-042038dff89fa3a63e6613ade4540c7347cab953.tar.bz2 libgenetic-042038dff89fa3a63e6613ade4540c7347cab953.tar.xz libgenetic-042038dff89fa3a63e6613ade4540c7347cab953.zip | |
| -rw-r--r-- | src/explicitsimulation.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/explicitsimulation.cpp b/src/explicitsimulation.cpp index 3e4edc3..b9693b5 100644 --- a/src/explicitsimulation.cpp +++ b/src/explicitsimulation.cpp | |||
| @@ -131,11 +131,18 @@ Genetic::PhenotypeId Genetic::ExplicitSimulation::selectWeighted() | |||
| 131 | if( dSel < dRun ) | 131 | if( dSel < dRun ) |
| 132 | return i.getKey(); | 132 | return i.getKey(); |
| 133 | } | 133 | } |
| 134 | 134 | /* | |
| 135 | sio << "Genetic::ExplicitSimulation::selectWeighted() - failed, picked max" | 135 | sio << "Genetic::ExplicitSimulation::selectWeighted() - failed, picked random" |
| 136 | << sio.nl; | 136 | << sio.nl; |
| 137 | sio << " " << dMinFitness << " - " << dMaxFitness << " -- " << dTotalFitness << " > " << dRun << " > " << dSel << sio.nl; | 137 | sio << " " << dMinFitness << " - " << dMaxFitness << " -- " << dTotalFitness << " > " << dRun << " > " << dSel << sio.nl; |
| 138 | abort(); | 138 | // abort(); |
| 139 | */ | ||
| 140 | int iSel = Bu::Random::rand( hFitness.getSize() ); | ||
| 141 | for( FitnessHash::iterator i = hFitness.begin(); i; i++ ) | ||
| 142 | { | ||
| 143 | if( --iSel <= 0 ) | ||
| 144 | return i.getKey(); | ||
| 145 | } | ||
| 139 | 146 | ||
| 140 | return uMaxFitness; | 147 | return uMaxFitness; |
| 141 | } | 148 | } |
