Presuming that you're doing a generational EA, all you need to do is
change the size of the subpopulation somewhere. One place to do this
is in the breedPopulation(...) method of your particular breeder
subclass -- if you're using SimpleBreeder, just replace the array in
the new subpopulation with an appropriately-sized one. But since most
generational breeders create new empty Populations (and thus new
Subpopulations) using the emptyClone() method, perhaps the simplest
approach is to override the Subpopulation class to return an
appropriately-sized Subpopulation in its emptyClone method.
MySubpopulation extends Subpopulation
public int myNewLength = 100; // or whatever
public Group emptyClone()
Subpopulation s = (Subpopulation)(super.emptyClone());
s.individuals = new Individual[myNewLength];
Don't do this with SPEA2, as it maintains a specially-organized and
sized array. But it should work fine with, for example, SimpleBreeder.
A good place to set myNewLength is in the Breeder's breedPopulation
method. You can do something like
MyBreeder extends SimpleBreeder
public Population breedPopulation(EvolutionState state) throws
Of course you'll need to add these two classes in the appropriate
places in your parameter file.
On Apr 25, 2004, at 5:42 PM, Morten Revsbæk wrote:
> I want to make an EA where the size of my subpopulation is variable and
> not just the fixed size which is put in the .params file. How is it
> possible to make such an EA in ECJ?