Print

Print


Thank you for the pointer.
I don't really get point 2. The whole inner run will run inside the evaluate
method from the outer GP. Why do I need to 'hack up globals'?

In the evaluate method I have now this:
NestedGPInitializer init = (NestedGPInitializer) state.initializer;
EvolutionState state2 = Evolve.initialize(
                init.innerLoopDatabase, init.gaRandomOffset++);
Evolve.startFresh(state2, null);

State2 will be passed around as parameters in all method calls and not
accesable through any 'globals', right? They are two independant state
objects, as far as I can tell. State2 will also be garbage collected when
we leave the evaluate method. So point 5 is not needed.

You also mention that I should change startFresh so it won't close
the output. But I checked the code. It makes a new output every time I call
initialize. And it checks to make sure that it will never close stdout.

As for how to get the information back. I created a statistics object, which
tracks the best individuals inside the inner loop. And when the run is over
I collect the best individual from him.

Evolve.startFresh(state2, null);
BestSelector bs = (BestSelector)state2.statistics;
ObjectVectorIndividual ovInd = (ObjectVectorIndividual)bs.best_of_run[0];

On 9/19/05, Sean Luke <[log in to unmask]> wrote:
> Assuming you want to use ECJ for both your GP and GA, and it's truly a
> *nested* GA (a whole GA run when evaluating a single individual), you
> should be able to do it something like this:
>
> -1. Make a special subclass of Initialializer, which you will use.
>
> 0. Make a global integer gaRandomOffset in your Initializer, starting
> at 0.
>
> 1. At the beginning of your GP run -- during Initializer's setup
> perhaps, load and store somewhere (in the Initializer) a
> ParameterDatabase which holds the parameters for your GA runs.  Let's
> say it's called 'database'.  You can get
> a parameter database easily with new ParameterDatabase(filename).
>
> 2. On evaluation, call
>
>         EvolutionState state2 = Evolve.initialize(state.initializer.database,
>                                                         state.initializer.gaRandomOffset++);
>
> 3. You'll need to stash YOUR EvolutionState in state2 somewhere so
> state2's Problem can find it -- or hack globals up somehow.
>
> 4. Then call
>
>         Evolve.startFresh(state2,null);
>
> You may want to modify the startFresh method (or create another one) so
> it doesn't do state.output.close(); at the very end, as that'll close
> stdout while your original EvolutionState is still using it.
>
> 5. Do your post-hoc analysis, then
>
>         state2 = null;          // let gc
>
> Sean
>
>
>
>
> On Sep 19, 2005, at 3:07 PM, Arjan Seesing wrote:
>
> > Hi,
> >
> > I'm going to use a nested GA inside my GP run. So to evaluate my GP
> > programs, I'm first going to run a small GA run on a some extra data
> > to be able to evaluate the individuals.
> > My question is what would be the easiest way to call ECJ with the
> > lowest overhead possible.
> >
> > I've been looking at the Console app which starts ECJ itself, but it's
> > all so correlated to the gui, it is impossible to use the code there.
> > I will be using the parameter database to pass data to the inner GA
> > but I haven't decided how to pass data back.
> >
> > Some hints would be appreciated!
> >
> > Arjan
>