Changed the populator to be a) more efficient and b) more useable
It is no longer derived from eoPop, it now gets a destination population. This saves a lot of copying. The semantics has changed a little as well. It is now an _infinite_ iterator. operator++ will *not* dispense new individuals, but will merely stay at the end. To get a new indy, use operator*() as before. eoEasyEA now checks the checkpoint *after* making a generation and clears the offspring eoGeneralBreeder is changed to reflect the changes in eoPopulator eoSequentialSelect now uses setup() rather than init()
This commit is contained in:
parent
a27aa7112a
commit
ead2ac2c62
4 changed files with 88 additions and 57 deletions
|
|
@ -69,17 +69,15 @@ class eoGeneralBreeder: public eoBreed<EOT>
|
|||
{
|
||||
unsigned target = howMany(_parents.size());
|
||||
|
||||
eoSelectivePopulator<EOT> it(_parents, select);
|
||||
_offspring.clear();
|
||||
eoSelectivePopulator<EOT> it(_parents, _offspring, select);
|
||||
|
||||
select.setup(_parents);
|
||||
while (_offspring.size() < target)
|
||||
{
|
||||
op(it);
|
||||
++it;
|
||||
}
|
||||
|
||||
while (it.size() < target)
|
||||
{
|
||||
op(it);
|
||||
++it;
|
||||
}
|
||||
|
||||
swap(_offspring, it);
|
||||
_offspring.resize(target); // you might have generated a few more
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue