Print

Print


On Jan 6, 2005, at 7:04 PM, Elena Popovici wrote:

>        I am trying to implement a version of 2 populations
> co-evolution where
> during one generation only one population goes through evaluation and
> breeding (e.g. have one pop run for 10 generation while keeping the
> other one frozen, then vice versa and so on). I've updated my custom
> evaluator to evaluate only one population per generation.
>        Do I need to write my own custom breeder to have only one of the
> populations breeding in each generation or is there some other simpler
> way to hack this?

Hi, Elena.  That is of course a very common form of coevolution, so we
should probably add some feature to ECJ to make this trivial.  At any
rate, I think the easiest way to do it is to modify the breeder so that
it only breeds one subpopulation at a time.  That's pretty easy.  If
you're using SimpleBreeder, it'd look something like this.  Change:

             while(x<upperbound)
                 x += bp.produce(1,upperbound-x,x,subpop,
                                 newpop.subpops[subpop].individuals,
                                 state,threadnum);
to

             while(x<upperbound)
                          if (shouldSkipSubpop(subpop,state))  // you implement this method
                                        {
                                        newpop.subpops[subpop].individuals[x] =
                                                state.population.subpops[subpop].individuals[x];
                                        x++;
                                        }
                          else
                                x += bp.produce(1,upperbound-x,x,subpop,
                                 newpop.subpops[subpop].individuals,
                                 state,threadnum);

... or something like that.  I'm just writing off the top of my head,
so there could be a bug there.

You could also create a SelectionMethod subclass which returns each
subpopulation member in turn.  Then you'd create a BreedingPipeline
subclass which selects which source it's going to use based on whether
the generation is even or odd.  On one source you hang your normal
breeding pipeline, and in the other source you hang your
SelectionMethod.  In SelectionMethod.prepareToProduce() you can reset
your internal counter to 0 again so it starts at the beginning of the
population.  If you do that, be sure to only run in single-thread
breeding mode.

Sean