Mime-Version: |
1.0 (Apple Message framework v622) |
Sender: |
|
Date: |
Sat, 13 Aug 2005 22:53:42 -0400 |
Reply-To: |
|
Subject: |
|
From: |
|
Content-Transfer-Encoding: |
7bit |
In-Reply-To: |
|
Content-Type: |
text/plain; charset=US-ASCII; format=flowed |
Comments: |
|
Parts/Attachments: |
|
|
On Aug 12, 2005, at 4:29 PM, Steve Butcher (Steve-O) wrote:
> I'm wondering where I have to intercede to add restarts to the ES/
> Hill Climber.
There are generally two strategies. Either you restart the entire ECJ
job, which case I'd modify Evolve's main() loop -- there's code and
instructions in there to help get you started. Or (I think this is the
better approach) you just simulate a "restart" by randomizing your
individuals. If you're using the standard Statistics objects, you'll
probably already have code for keeping around the best-so-far
individual. In either case you'll need a test to determine if you
*should* restart. This test should probably be done in the Evaluator.
Just subclass Evaluator with a new evaluatePopulation like this:
public class MyEvaluator extends Evaluator
{
public boolean shouldRestart = false;
public void evaluatePopulation(final EvolutionState state)
{
shouldRestart = false;
super.evaluatePopulation(state);
if ( <<< test >>> ) shouldRestart = true;
}
}
Now you'd check to see if you need to restart with
((MyEvaluator)(state.evaluator)).shouldRestart
> Where is the child or parent chosen as the parent or "1" for the next
> generation?
This is done in the Breeder. The Breeder sets up a BreedingPipeline
(or multiple ones if you're doing multiple threads) and sucks new
individuals out of it to fill up the new population. The
BreedingPipeline will have SelectionMethods at one end which hand off
individuals from the old population to various BreedingPipeline
subclasses which copy and mutate those indiviuals to form new ones.
While you can modify the BreedingPipeline etc., if you just need to do
a restart, I'd suggest just resetting the individuals in the population
in your Evaluator, so you do something like:
public void evaluatePopulation(final EvolutionState state)
{
if ( <<< test >>> )
{
<<< reset here >>>
}
super.evaluatePopulation(state);
}
I can think of a few ways to reset your population. The simplest
approach is to fire up the Initializer and create a new population
entirely:
state.population = state.initializer.initialPopulation(state);
You could also plausibly call state.population.populate(state), or
grab each subpopulations' Species and have them do a
newIndividual(...), or last but not least, if your Individuals support
the reset() function (VectorIndividuals do), you can just call reset()
on 'em.
Sean
|
|
|