Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.search.algorithms.ga.p2p.P2PGeneticState.java

Here you can find all the information about the file org.dgpf.search.algorithms.ga.p2p.P2PGeneticState.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 *
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-04-10 06:38:47
 * Original Filename: org.dgpf.search.algorithms.ga.p2p.P2PGeneticState.java
 * Version          : 2.0.2
 * Last modification: 2006-07-21
 *                by: Thomas Weise
 *
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */


package org.dgpf.search.algorithms.ga.p2p;

import java.io.Serializable;

import org.dgpf.search.algorithms.ga.GeneticState;
import org.dgpf.search.api.Assigner;
import org.dgpf.search.api.p2p.P2PSearchUtils;
import org.dgpf.search.api.p2p.P2PState;
import org.sfc.meta.MetaInformation;
import org.sfc.utils.Typesafe;

/**
 * <p>
 * This class encapsulates the dynamic state of a genetic evolution
 * extended by peer-to-peer information.
 * This state will change every generation and includes statistical
 * information.
 * </p><p>
 * <h2>SERIALIZATION WARNING</h2>
 * Serializing instances of this class more than once into the same
 * <code>ObjectOutputStream</code> will lead to corruption.
 * <code>ObjectOutputStream</code>s serialize the same object only once,
 * thus serializing an instance of this class twice will lead to only
 * one real copy, and reading it will return the same instance with the
 * same values twice. So if you keep a <code>Geneticstate</code>, wait
 * until its values change and than storing it again will lead to the
 * changed data getting lost.
 * </p>
 *
 * @param <Genotype>    The sort of genotype used to represent individuals.
 *                      This must be a serializable type.
 *
 * @see P2PGeneticStateBag
 *
 * @author Thomas Weise
 */

public class P2PGeneticState<Genotype extends Serializable>
                                      extends GeneticState<Genotype>
  {
/**
 * The serial version uid.
 */

  private static final long serialVersionUID = 1;

/**
 * The meta information of the p2p genetic state.
 */

  public  static  final MetaInformation P2P_GENETIC_STATE_METAINFO  ;
  
  static
    {
    P2PSearchUtils.P2P_STATE.add_port(
            P2PGeneticState.class, true, false, null);    
    P2P_GENETIC_STATE_METAINFO = new MetaInformation();
    }
  
/**
 * The peer-to-peer state extension.
 */

  private          P2PState               m_p2p_state ;

/**
 * Create a new p2p genetic state.
 * @param p_ff_count  The count of fitness functions evaluated by this
 *                    search.
 * @param p_bag       The genetic state bag that owns this search state
 *                    instance.
 */

  protected P2PGeneticState(      int                          p_ff_count,
                            final P2PGeneticStateBag<Genotype> p_bag)
    {
    super(p_ff_count, p_bag);

    this.m_p2p_state = p_bag.m_p2p_state.unpack();    
    }


/**
 * Assign the internal data of this search data to the data of
 * another one.
 * @param p_data  The simulation data  to assign to.
 */

  @Override
  protected void  assign  (final Object p_data)
    {
    P2PGeneticState<Genotype>      l_gs;
    P2PGeneticParameters<Genotype> l_gp;

    super.assign(p_data);

    if(p_data instanceof P2PGeneticState)
      {
      l_gs = Typesafe.cast(p_data);

      Assigner.assign(this.m_p2p_state, l_gs.m_p2p_state);
      }

    if(p_data instanceof P2PGeneticParameters)
      {
      l_gp = Typesafe.cast(p_data);
      Assigner.assign(this.m_p2p_state, l_gp.get_p2p_parameters());
      }
    }

/**
 * Obtain the p2p state which holds the control and statical data of the
 * peer-to-peer node.
 * @return The p2p state which holds the control and statical data of the
 *         peer-to-peer node.
 */

  public  final P2PState  get_p2p_state()
    {
    return this.m_p2p_state;
    }

  
/**
 * Creates and returns a copy of this object.  The precise meaning 
 * of "copy" may depend on the class of the object. 
 *
 * @return     A clone of this instance.
 * 
 * @see java.lang.Cloneable
 */

  @Override
  public  Object  clone ()
    {
    final P2PGeneticState<Genotype>  l_ss;
    
    l_ss = Typesafe.cast(super.clone());      
    l_ss.m_p2p_state = ((P2PState)(l_ss.m_p2p_state.clone()));      
    return l_ss;     
    }
  }

File Information:

file name:P2PGeneticState.java
package:org.dgpf.search.algorithms.ga.p2p
qualified name:org.dgpf.search.algorithms.ga.p2p.P2PGeneticState.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/search/algorithms/ga/p2p/P2PGeneticState.java
size:4.922 KB (5041 B)
uploaded: 2015-07-22 04:10:59 GMT+0000
last update: 2006-07-21 13:11:55 GMT+0000
last access: 2017-11-17 19:20:29 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-17 19:20:29 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo