Print

Print


works great, thanks Sean!

On Mon, Apr 14, 2008 at 6:31 PM, Sean Luke <[log in to unmask]> wrote:

> On Apr 14, 2008, at 4:41 PM, Shane wrote:
>
>  I would like to see the results of each gp individual in the out.stat
> > file, instead of just the best individual in each generation.   I
> > specifically want to see the string representation of the tree for each
> > individual.  Is this possible?  I will be using a small population size for
> > testing.
> >
>
> It's not built-in.  But it's very simple to write your own Statistics
> object, and then you just add it to the Statistics chain.  Or if you're just
> adding to the existing statistics file, you can just subclass from
> KozaStatistics and override it:
>
> public class MyStatistics extends KozaStatistics
>        {
>        // we're going to steal KozaStatistics's 'statisticslog' variable,
> which makes this easy
>        // since KozaStatistics sets the log to point to out.stat for us
> already
>
>        // let's override this one function
>        public void postEvaluationStatistics(final Evaluation state)
>                {
>                super.postEvaluationStatistics();
>                state.output.println("========== CHILDREN ===========",
>                        Output.V_NO_GENERAL, statisticslog);
>                for(int x=0;x<state.population.subpops.length;x++)
>                        {
>                        state.output.println("+++++ Subpop " + x + "
> +++++",
>                                Output.V_NO_GENERAL, statisticslog);
>                        for(int y=0; y<
> state.population.subpops[x].individuals.length; y++)
>                                {
>                                state.output.println("----- Individual " +
> y + " -----",
>                                        Output.V_NO_GENERAL,
> statisticslog);
>
>                                // notice log and output verbosity are
> switched here, it's a
>                                // historical stupidity in ECJ
>
>  state.population.subpops[x].individuals[y].printIndividualForHumans(state,
>                                        statisticslog,
> Output.V_NO_GENERAL);
>                                }
>
>                        }
>                }
>        }
>
>
> Something like that.  Now you can replace KozaStatistics with
> MyStatistics, something like adding the parameter:
>
>        stat = edu.gmu.cs.MyStatistics
>
> Your other option is to just write a direct subclass of Statistics and
> output to a separate file (you need to ask Output to create a log for you in
> your setup() method).  Look at SimpleStatistics and how it does it.  Then
> you can add that new Statistics object to your statistics chain.  Each
> Statistics object has N children (typically at most 1) who are also called.
>  So you could do:
>
>        ;;; keep this as before:
>        ;;; stat = ec.gp.koza.KozaStatistics
>        stat.num-children = 1
>        stat.0 = edu.gmu.cs.MyOtherStatistics
>
> Now you have two statistics objects.
>
> Sean
>