package cecj.archive; import java.util.List; import cecj.eval.ArchivingCoevolutionaryEvaluator; import cecj.eval.TDLImprovingEvaluator; import ec.EvolutionState; import ec.Individual; import ec.Setup; import ec.util.Parameter; /** * The abstract class representing any archive used with coevolutionary algorithm. Archive * mechanisms play 3 important roles during the course of evolution: * *
ArchivingEvaluator
ArchivingSubpopulation
objects and there are stored
* archival individuals of the same specie as the original population. In subclasses of
* CoevolutionaryArchive
only the method specifying how archives should be updated is
* defined.
*
* @author Marcin Szubert
*
*/
public abstract class CoevolutionaryArchive implements Setup {
private static final String P_POP = "pop";
private static final String P_SIZE = "subpops";
/**
* Number of coevolving populations.
*/
protected int numSubpopulations;
/**
* Checks if ArchivingCoevolutionaryEvaluator
is used and reads the number of
* populations from the configuration.
*/
public void setup(EvolutionState state, Parameter base) {
if (!(state.evaluator instanceof ArchivingCoevolutionaryEvaluator)
&& !(state.evaluator instanceof TDLImprovingEvaluator)) {
state.output.fatal("This archive can be used only with ArchivingEvaluator.\n");
}
Parameter popSizeParameter = new Parameter(P_POP).push(P_SIZE);
numSubpopulations = state.parameters.getInt(popSizeParameter, null, 0);
}
/**
* Gets the list of archival individuals from given subpopulation.
*
* @param state
* the current evolution state
* @param subpop
* the index of subpopulation
* @return the list of archival individuals of the subpopulation
*/
protected List