Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gp.automaton.search.AutomatonContext.java

Here you can find all the information about the file org.dgpf.gp.automaton.search.AutomatonContext.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2005 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2005-12-28 11:40:44
 * Original Filename: org.dgpf.automaton.genetics.AutomatonContext.java
 * Version          : 2.2.3
 * Last modification: 2006-07-13
 *                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.gp.automaton.search;

import org.dgpf.gp.automaton.base.Automaton;
import org.sfc.events.IEventListener;

/**
 * The context type for org.dgpf.automaton.base simulators.
 *
 * @author Thomas Weise
 */

public class AutomatonContext  extends ProgramContext
  {  
/**
 * The serial version uid.
 */

  private static final long serialVersionUID = 1;
  
/**
 * The internal multi buffer.
 */

  private Automaton m_data  ;
  

/**
 * Create a new automaton context.
 * @param p_definition  The search definition to use as blueprint for the
 *                      internally stored data.
 * @param p_events      The event listener to be used to propagate
 *                      error events to, if needed.
 */

  protected AutomatonContext(final ProgramDefinition  p_definition,
                             final IEventListener     p_events) 
    {
    super(p_definition, p_events);
    }
  
  
/**
 * This method is called right before a simulation starts. It allows you
 * to perform some simulation-specific initialization.
 * The simulation-setup of the fitness functions will also be invoked here.
 * @param p_index   The index number of the current simulation. The first
 *                  simulation will have index 0, the second will have
 *                  index 1 and so on.
 * @see #end_simulation(int)
 */

  @Override
  protected final void begin_simulation  (final int p_index)
    {
    this.m_data = new Automaton(this.get_current());
    super.begin_simulation(p_index);
    }
  
/**
 * This method is called right when a simulation has finished.
 * It performs some simulation-based cleanup.
 * @param p_index   The index number of the current simulation. The first
 *                  simulation will have index 0, the second will have
 *                  index 1 and so on.
 * @see #begin_simulation(int)
 */

  @Override
  protected final void    end_simulation    (final int p_index)
    {    
    super.end_simulation(p_index);
    this.m_data = null;
    }
  
/**
 * Obtain the automaton currently being simulated.
 * @return The automaton currently being simulated.
 */

  public  final Automaton get_automaton  ()
    {
    return this.m_data;
    }
  

/**
 * Perform some simulation steps. This method is used to simulate the
 * current individual.
 * @param p_steps       The count of stepps suggested to run now in a row.
 * @return  <code>true</code> if everything went ok, <code>false</code> if
 *          something failed.
 */

  @Override
  protected boolean  simulate  (long p_steps)
    {
    final Automaton l_a;
    
    l_a = this.m_data;
    for(; p_steps > 0; p_steps--)
      {
      l_a.tick();
      }
    
    return true;
    }
  }

File Information:

file name:AutomatonContext.java
package:org.dgpf.gp.automaton.search
qualified name:org.dgpf.gp.automaton.search.AutomatonContext.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gp/automaton/search/AutomatonContext.java
size:3.826 KB (3918 B)
uploaded: 2015-07-22 04:10:55 GMT+0000
last update: 2006-07-13 04:14:58 GMT+0000
last access: 2017-11-18 06:36:36 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-18 06:36:36 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo