package org.dgpf.search.algorithms.ga.p2p;
import java.io.Serializable;
import org.dgpf.search.algorithms.ga.GeneticStateBag;
import org.dgpf.search.api.SearchState;
import org.dgpf.search.api.p2p.P2PStateBag;
/**
* <p>
* This state bag hosts a genetic peer-to-peer state.
* </p><p>
* The genetic state bag contains the state of the evolution. It is the
* only instance able to access the data of the <code>GeneticState</code>.
* You should place variables like the statistic bags into instances of
* <code>GeneticStateBag</code> while putting the statistic info records
* into <code>GeneticState</code>. This way you prevent them from being
* serialized/cloned/copied/accessed whenever this is done to a genetic
* state.
* </p>
*
* @param <Genotype> The sort of genotype used to represent individuals.
* This must be a serializable type.
* @see P2PGeneticState
* @author Thomas Weise
*/
public class P2PGeneticStateBag<Genotype extends Serializable>
extends GeneticStateBag<Genotype>
{
/**
* The serial version uid.
*/
private static final long serialVersionUID = 1;
/**
* The peer-to-peer state extension.
*/
P2PStateBag m_p2p_state;
/**
* Create a new p2p genetic state bag.
* @param p_ff_count The count of fitness functions evaluated by this
* search.
*/
protected P2PGeneticStateBag (final int p_ff_count)
{
super(p_ff_count);
}
/**
* Create the p2p-state bag to be internally hosted.
* @param p_ff_count The count of fitness functions evaluated by this
* search.
* @return The p2p-state bag to be internally hosted.
*/
protected P2PStateBag create_p2p_state (final int p_ff_count)
{
return new P2PStateBag(p_ff_count);
}
/**
* This method is used internally to create a search state instance that
* can be hosted by this bag.
* @param p_ff_count The count of fitness functions evaluated by this
* search.
* @return The new search state.
*/
@Override
protected SearchState<Genotype> create_state (final int p_ff_count)
{
this.m_p2p_state = this.create_p2p_state(p_ff_count);
return new P2PGeneticState<Genotype>(p_ff_count, this);
}
}