/*
  Copyright 2006 by Sean Luke
  Licensed under the Academic Free License version 3.0
  See the file "LICENSE" for more information
*/


package ec;
import ec.steadystate.*;
import ec.util.*;

/* 
 * Statistics.java
 * 
 * Created: Tue Aug 10 21:10:48 1999
 * By: Sean Luke
 */

/**
 * Statistics and its subclasses are Cliques which generate statistics
 * during the run.  Statistics are arranged in a tree hierarchy -- 
 * The root statistics object may have "children", and when the root is
 * called, it calls its children with the same message.  You can override
 * this behavior however you see fit.
  
 * 

There are lots of places where statistics might be nice to print out. * These places are implemented as hooks in the Statistics object which you * can override if you like; otherwise they call the default behavior. If * you plan on allowing your Statistics subclass to contain children, you * should remember to call the appropriate super.foo() if you * override any foo() method. * *

While there are lots of hooks, various EvolutionState objects only * implement a subset of them. You'll need to look at the EvolutionState * code to see which ones are implemented to make sure that your statistics * hooks are called appropriately! * *

Statistics objects should set up their statistics logs etc. during * setup(...). Remember to make the log restartable in * case of restarting from a checkpoint. * *

Steady-State Statistics. For convenience, Statistics contains * default implementations of the SteadyStateStatisticsForm methods but * does not implement SteadyStateStatisticsForm. This mostly is intended * to keep SteadyStateStatistcsForm implementations from having to call * functions on all their children: instead they can just call foo.super(); *

Parameters

base.num-children
int >= 0
(number of child statistics objects)
base.child.n
classname, inherits or equals ec.Statistics
(the class of child statistics object number n)

Parameter bases

base.child.n species (child statistics object number n)
* @author Sean Luke * @version 2.0 */ public class Statistics implements Singleton { private static final long serialVersionUID = 1; public static final String P_NUMCHILDREN = "num-children"; public static final String P_CHILD = "child"; public static final String P_SILENT = "silent"; public static final String P_MUZZLE = "muzzle"; // deprecated public static final String P_SILENT_PRINT = "silent.print"; public static final String P_SILENT_FILE = "silent.file"; public Statistics[] children; public boolean silentFile; public boolean silentPrint; public void setup(final EvolutionState state, final Parameter base) { int t = state.parameters.getIntWithDefault(base.push(P_NUMCHILDREN),null,0); if (t < 0) state.output.fatal("A Statistics object cannot have negative number of children", base.push(P_NUMCHILDREN)); silentFile = silentPrint = state.parameters.getBoolean(base.push(P_SILENT), null, false); // yes, we're stating them a second time. It's correct logic. silentFile = state.parameters.getBoolean(base.push(P_SILENT_FILE), null, silentFile); silentPrint = state.parameters.getBoolean(base.push(P_SILENT_PRINT), null, silentPrint); if (state.parameters.exists(base.push(P_MUZZLE), null)) state.output.warning("" + base.push(P_MUZZLE) + " has been deprecated. We suggest you use " + base.push(P_SILENT) + " or similar newer options."); silentFile = silentFile || state.parameters.getBoolean(base.push(P_MUZZLE), null, false); // load the trees children = new Statistics[t]; for (int x=0;xresult is either state.R_FAILURE, indicating that an ideal individual was not found, or state.R_SUCCESS, indicating that an ideal individual was found. */ public void finalStatistics(final EvolutionState state, final int result) { for(int x=0;x

Ads help maintain this website.