Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.search.algorithms.sa.adaptation.DefaultSAAdapter.java

Here you can find all the information about the file org.dgpf.search.algorithms.sa.adaptation.DefaultSAAdapter.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-06-05 13:27:42
 * Created by       : Stefan Niemczyk, Marc Kirchhoff
 * Original Filename: org.dgpf.search.algorithms.sa.adaptation.DefaultSAAdapter.java
 * Version          : 1.0.1
 * Last modification: 2006-06-22
 *                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.sa.adaptation;

import org.dgpf.search.algorithms.sa.SAParameters;
import org.dgpf.search.algorithms.sa.ta.TemperatureAdaptionStrategy;
import org.dgpf.search.api.AdaptationStrategy;
import org.dgpf.search.api.SearchParameters;
import org.dgpf.search.api.SearchState;
import org.dgpf.search.api.adaptation.DefaultSearchAdapter;
import org.sfc.utils.Typesafe;

/**
 * The default simulated annealing adaptation strategy.
 *
 * @author Stefan Niemczyk, Marc Kirchhoff
 */

public class DefaultSAAdapter extends DefaultSearchAdapter
  {
/**
 * The serial version uid.
 */

  private static final long serialVersionUID            = 1;
/**
 * The default update threshold.
 */

  public  static  final long  DEFAULT_SA_UPDATE_THRESHOLD  = 
                                      DEFAULT_UPDATE_THRESHOLD * 10;
  
/**
 * Create a new stateful adaptation strategy.
 * @param p_parameters  The search parameter set to be adapted.
 */

  public DefaultSAAdapter(final SearchParameters<?> p_parameters)
    {
    super(p_parameters);

    this.set_update_threshold(DEFAULT_SA_UPDATE_THRESHOLD);
    }

/**
 * Create a new stateful adaptation strategy by using another search
 * adaptation strategy as blueprint.
 * @param p_parameters  The search parameter set to be adapted.
 * @param p_strategy    The blueprint to copy the internal data from.
 */

  public  DefaultSAAdapter(final SearchParameters<?> p_parameters,
                           final AdaptationStrategy  p_strategy)
    {
    super(p_parameters, p_strategy);
    }
  
/**
 * This method will be called whenever the search parameters perform a
 * reset, meaning that the search level is set back to 0.
 */

  @Override
  protected void  reset ()
    {
    SAParameters<?>  l_sap;
    
    l_sap=Typesafe.cast(this.get_parameters());
    
    super.reset();
    
    l_sap.set_temperature(l_sap.get_start_temperature());
    }
  
  /**
 * This method will be called by the search engine whenever it feels like
 * it is time to adapt the current search parameters to the current search
 * state. If you override this method, you must also declare your class
 * as instance of <code>ICloneable</code>.
 * @param p_state The current state of the search.
 * @return  <code>true</code> if and only if the update level should be
 *          resetted, <code>false</code> if everything should continue
 *          normal.
 * @see SearchState#get_update_level()
 */

  @Override
  protected boolean  adapt (final SearchState<?> p_state)
    {
    SAParameters<?>             l_sap;
    TemperatureAdaptionStrategy l_tas;
    
    l_sap = Typesafe.cast(this.get_parameters());
    l_tas = l_sap.get_temperature_adaption_strategy();
    
    if(super.adapt(p_state)) return true;
    
    l_tas.adapt_temperature(l_sap);

    return false;
    }
  
/**
 * Assign the internal data of this adaptation strategy to another one.
 * This method copies the settings, but not the statistics.
 * @param p_data  The adaptation strategy to assign to.
 */

  @Override
  protected void  assign  (final AdaptationStrategy p_data)
    {
    super.assign(p_data);
    }
  }

File Information:

file name:DefaultSAAdapter.java
package:org.dgpf.search.algorithms.sa.adaptation
qualified name:org.dgpf.search.algorithms.sa.adaptation.DefaultSAAdapter.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/search/algorithms/sa/adaptation/DefaultSAAdapter.java
size:4.324 KB (4428 B)
uploaded: 2015-07-22 04:10:59 GMT+0000
last update: 2006-06-22 13:15:35 GMT+0000
last access: 2017-11-23 05:19:17 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-23 05:19:17 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo