Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.search.api.FitnessData.java

Here you can find all the information about the file org.dgpf.search.api.FitnessData.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-03-30 15:04:09
 * Original Filename: org.dgpf.search.api.FitnessData.java
 * Version          : 2.0.0
 * Last modification: 2006-05-08
 *                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.api;

import java.io.Serializable;

/**
 * <p>
 * This is an internal state container for the fitness functions.
 * It holds their intermedia results. Each fitness function might provide
 * an own derived descendant of this class, regarding what type of
 * information it needs to store.  
 * </p>
 * <p>
 * After each simulation, a fitness function <strong>must</strong> store
 * the fitness value it has calculated into a fitness data instance. For
 * each simulation there will be an distinct fitness data instance
 * available per fitness function.
 * </p>
 * 
 * @param <Genotype>    The sort of genotype used to represent individuals.
 *                      This must be a serializable type.
 *                    
 * @see FitnessFunction
 * @see #set_fitness(double)
 * @author Thomas Weise
 */

public class FitnessData<Genotype extends     Serializable> 
                                  implements  Comparable<FitnessData>
  {
/**
 * The internal fitness value.
 * @see #get_fitness()
 */

  private double  m_fitness  ;
  
  
/**
 * Obtain the fitness value stored in this fitness data instance.
 * @return The fitness value stored in this fitness data instance.
 */

  public  final double  get_fitness ()
    {
    return this.m_fitness;
    }
  

  
/**
 * Compare two fitness data instances.
 * @param p_data  The fitness data instance to compare with.
 * @return  An integer denoting the comparison result: 0 for equal,
 *          <0 for smaller and >0 for bigger.
 */

  public  final int compareTo (final FitnessData p_data)
    {
    return Double.compare(this.m_fitness, p_data.m_fitness);
    }
  
/**
 * Tells the fitness data that a new simulation is about to begin.
 * @param p_context       The context driving the simulation.
 */

  protected void begin_simulation(final SearchContext<Genotype> p_context)
    {
    this.m_fitness = 0.0d;
    }
  
/**
 * Tells the fitness data that a simulation has been terminated.
 * @param p_context       The context driving the simulation.
 */

  protected void end_simulation (final SearchContext<Genotype> p_context)
    {
    // does nothing
    }
  
/**
 * Set the fitness value stored in this record.
 * @param p_fitness The fitness value to be stored.
 */

  public final void  set_fitness (final double p_fitness)
    {
    this.m_fitness = SearchUtils.format_positive(p_fitness);
    }
  }

File Information:

file name:FitnessData.java
package:org.dgpf.search.api
qualified name:org.dgpf.search.api.FitnessData.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/search/api/FitnessData.java
size:3.499 KB (3583 B)
uploaded: 2015-07-22 04:11:00 GMT+0000
last update: 2006-05-11 07:44:43 GMT+0000
last access: 2017-11-19 04:47:18 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-19 04:47:18 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo