Hi Mehran, it'd ordinarily be straightforward to create a BreedingPipeline object which produced an individual and returned it only if it was fitter than its parent. The procedure would be to produce the individual from a child BreedingPipeline object, then clone a Problem instance from the Evaluator's Problem prototype, then test the individual and see how good it is. But that's not the big problem. The big problem is: what is the "parent"?
ECJ allows arbitrarily complex breeding pipelines. So you could have a child generated from a series of crossover and mutation objects involving, I dunno, 20 parents. Who do you compare against?
So let's say you've got that figured out. Your next issue would be to figure out how to keep around the parent (or an index pointing to it in the population) so you know who to compare to. ECJH doesn't pass that through its breeding pipelines, so we'd have to hack it. The obvious hack would be to store in each Individual a pointer to its "parent", perhaps best as an index, not a real pointer. Selection methods would store the index to the individual itself. Crossover operators and mutation operators would decide which parent was the "parent" of the new child. Then when it bubbled up to your BreedingPipeline object, you'd know what Individual to compare against.
On Jan 2, 2013, at 3:21 PM, Mehran Maghoumi wrote:
> I'm trying to add a feature to ECJ for a project. When doing a crossover or
> mutation, I want to keep the resulting individuals only if their fitness is
> better than that of their parents.
> I pretty much know what I have to do and have pinpointed the location that
> I would need to put my decision code in (in the produce method of the
> CrossoverPipeline class for when the crossover is done)
> However, since the new individual has no fitness value associated with it, I
> would need to somehow evaluate it at that early stage and toss it if its
> fitness is not better than its parent. I know that the an Evaluator instance is
> responsible for evaluating a population, but what should I do for a single
> individual? What do you recommend?
> Thank you very much in advance.
> Mehran Maghoumi