[galib] replacement of best individual
matthew wall
mwall at oculustech.com
Wed Aug 20 08:51:15 EDT 2008
On 18 Aug 2008, at 20:02, Kupfer, Michael (ARC-AFA)[UC SANTA CRUZ]
wrote:
> Dear all,
>
> Under certain conditions, I would like to replace the current best
> individual with another one:
>
> Each time a new best individual is found I want to run a local
> search heuristic to improve this current best.
> If this improvement routine was successful, I would like to replace
> the current best with the result of the local search.
> How can I do the replacement? How can I replace pop.best() with the
> gene-values found in the improvement routine?
>
hi michael,
one approach is to create your own genetic algorithm object, since it
has access to and complete control over the population. for example,
this is a derivative of a simple ga that does repair
class MyGA : public GASimpleGA {
public:
virtual void step();
}
void
MyGA::step() {
// let the simple ga do its logic for a single step of evolution
GASimpleGA::step();
// this is the genome into which you stick the repairs
MyGenome genome;
genome.copy(pop->individual(x));
// do your heuristic to improve the best here
genome.setSomeValue();
genome.modifySomeAttribute();
// insert the genome into the population at the appropriate location
pop->individual(x).copy(genome);
}
More information about the galib
mailing list