Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 7

Warning: Cannot modify header information - headers already sent by (output started at /home/project-web/dgpf/htdocs/scripts/datetime.php:7) in /home/project-web/dgpf/htdocs/scripts/init.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at /home/project-web/dgpf/htdocs/scripts/datetime.php:7) in /home/project-web/dgpf/htdocs/scripts/init.php on line 29
Distributed Genetic Programming Framework
Logo
Distributed Genetic Programming Framework
print print


Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 16

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 16

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 16

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 16

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 16

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 16

File org.dgpf.search.api.adaptation.DefaultSearchAdapter.java

Here you can find all the information about the file org.dgpf.search.api.adaptation.DefaultSearchAdapter.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:13:23
 * Original Filename: org.dgpf.search.api.adaptation.DefaultSearchAdapter.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.adaptation;

import org.dgpf.search.api.AdaptationStrategy;
import org.dgpf.search.api.SearchParameters;
import org.dgpf.search.api.SearchState;
import org.dgpf.search.api.StatefulAdaptationStrategy;

/**
 * This is the default adaptation strategy for searches. Basically, it
 * resets the search if no improvement could be achieved for too long.
 *
 * @author Thomas Weise
 */

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

  private static final long serialVersionUID            = 1;
    
/**
 * The default minimum updates.
 */

  public  static  final long  DEFAULT_MIN_UPDATES       = 10;
/**
 * The default update threshold.
 */

  public  static  final long  DEFAULT_UPDATE_THRESHOLD  = 150 ;
/**
 * The default time to wait before resetting: 8h.
 */

  public  static  final long  DEFAULT_TIME_THRESHOLD    =
                                          (1000 * 60 * 60 * 8);

/**
 * The predicted time an update will take. This is computed as a slighting
 * average.
 */

  private long    m_update_time ;
/**
 * The update with the best individual.
 * @see #get_best_update()
 */

  private long    m_best_update      ;
/**
 * The update level with the best individual.
 * @see #get_rel_best_update()
 */

  private long    m_best_update_2     ;
/**
 * The time threshold after which a reset should be scheduled if no
 * improvement could be achieved.
 * @see #get_time_threshold()
 */

  private long    m_time_threshold    ;
/**
 * The update threshold after which a reset should be scheduled if no
 * improvement could be achieved.
 * @see #get_update_threshold()
 */

  private long    m_update_threshold  ;
/**
 * The minimum count of updates to run before a reset can be scheduled.
 * @see #get_min_updates()
 */

  private long    m_min_updates     ;


/**
 * Create a new stateful adaptation strategy.
 * @param p_parameters  The search parameter set to be adapted.
 */

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

    this.set_min_updates(DEFAULT_MIN_UPDATES);
    this.set_time_threshold(DEFAULT_TIME_THRESHOLD);
    this.set_update_threshold(DEFAULT_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  DefaultSearchAdapter(final SearchParameters<?> p_parameters,
                               final AdaptationStrategy  p_strategy)
    {
    super(p_parameters, p_strategy);

    if(this.m_min_updates <= 0)
      {
      this.set_min_updates(DEFAULT_MIN_UPDATES);
      }

    if(this.m_time_threshold <= 0)
      {
      this.set_time_threshold(DEFAULT_TIME_THRESHOLD);
      }

    if(this.m_update_threshold <= 0)
      {
      this.set_update_threshold(DEFAULT_UPDATE_THRESHOLD);
      }
    }

/**
 * 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 ()
    {
    super.reset();
    this.m_best_update_2 = 0;


//this one is experimental and may be removed
//       this.get_parameters().set_challenge_parent(
//             !(this.get_parameters().get_challenge_parent()));
    }

/**
 * 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)
    {
    long l_u, l_l, l_t;

    l_u = p_state.get_update_count();
    l_l = p_state.get_update_level();
    l_t = p_state.get_update_time();

    if(l_u <= 0) this.m_update_time = l_t;
    else         this.m_update_time = (((7*this.m_update_time) + l_t) >>> 3);

    if(p_state.get_improvement()     > 0) this.m_best_update   = l_u;
    if(p_state.get_rel_improvement() > 0) this.m_best_update_2 = l_l;

    l_l -= this.m_best_update_2;

    if(l_l > this.m_min_updates)
      {
      l_t = this.m_update_threshold;

      if(l_l > l_t)
        {
        this.m_update_threshold = Math.max(l_t+1, (11*l_t)/10);
        return true;
        }
      }

    l_t = this.m_time_threshold;
    if((l_l * this.m_update_time) > l_t)
      {
      this.m_time_threshold = Math.max(l_t+1,((11*l_t)/10));
      return true;
      }

    return false;
    }

/**
 * <p>
 * Obtain the predicted time an update will take. This prediction is based
 * on the recent updates and is computed as a slighting average.</p>
 * <p>You should always use the update time provided by this function
 * instead of the one provided by the search state. This time here is
 * a good prediction and ensures that you don't calculate with a peak
 * value. Also, remember that the search could be restored from a file,
 * which is why you should never use absolute time stamps for anything that
 * has something to do with automatic adaptation.</p>
 * @return The predicted time an update will take.
 */

  public final long  get_update_time ()
    {
    return this.m_update_time;
    }

/**
 * Obtain the index of the update where the currently known best ever
 * individual was found.
 * @return The index of the update where the currently known best ever
 *         individual was found.
 * @see #get_best_update()
 */

  public  final long  get_best_update ()
    {
    return this.m_best_update;
    }


/**
 * Obtain the index of the update level where the currently known best ever
 * individual was found.
 * @return The index of the update level where the currently known best ever
 *         individual was found.
 * @see #get_best_update()
 */

  public  final long  get_rel_best_update ()
    {
    return this.m_best_update_2;
    }

/**
 * The update threshold after which a reset should be scheduled if no
 * improvement could be achieved.
 * @return  The update threshold after which a reset should be scheduled if
 *          no improvement could be achieved.
 */

  public  final long  get_update_threshold  ()
    {
    return this.m_update_threshold;
    }

/**
 * Set the update threshold after which a reset should be scheduled if no
 * improvement could be achieved.
 * @param p_threshold The new update threshold after which a reset should
 *                    be scheduled if no improvement could be achieved.
 */

  public  void  set_update_threshold  (final long p_threshold)
    {
    if(p_threshold > 0) this.m_update_threshold = p_threshold;
    }

/**
 * Obtain the minimum updates to perform before a reset might be scheduled.
 * @return The minimum updates to perform before a reset might be scheduled.
 */

  public  final long  get_min_updates ()
    {
    return this.m_min_updates;
    }

/**
 * Set the minimum updates to perform before a reset might be scheduled.
 * @param p_min_updates The new minimum updates to perform before a reset
 *                      might be scheduled.
 */

  public  void  set_min_updates  (final long p_min_updates)
    {
    if(p_min_updates > 0) this.m_min_updates = p_min_updates;
    }

/**
 * <p>
 * Obtain the time threshold after which a reset should be scheduled if no
 * improvement could be achieved.</p>
 * <p>Notice: Resetting will not neccessarily occure directly when this
 * timeout ellapses. It uses the predicted update time to compute a update
 * index when it will occure, and it occures only after one update's
 * completion</p>
 * @return The time threshold after which a reset should be scheduled if no
 *         improvement could be achieved.
 */

  public  final long  get_time_threshold  ()
    {
    return this.m_time_threshold;
    }

/**
 * Set the time threshold after which a reset should be scheduled if no
 * improvement could be achieved.
 * @param p_threshold <p>The time threshold after which a reset should be
 *                    scheduled if no improvement could be achieved.</p>
 *                    <p>Notice: Resetting will not neccessarily occure
 *                    directly when this timeout ellapses. It uses the
 *                    predicted update time to compute a update index when
 *                    it will occure, and it occures only after one update's
 *                    completion</p>
 */

  public  void  set_time_threshold(final long p_threshold)
    {
    if(p_threshold > 0) this.m_time_threshold = p_threshold;
    }

/**
 * 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)
    {
    DefaultSearchAdapter  l_dsa;

    super.assign(p_data);

    if(p_data instanceof DefaultSearchAdapter)
      {
      l_dsa = ((DefaultSearchAdapter)p_data);

      this.set_min_updates(l_dsa.get_min_updates());
      this.set_time_threshold(l_dsa.get_time_threshold());
      this.set_update_threshold(l_dsa.get_update_threshold());
      }
    }
  }

File Information:

file name:DefaultSearchAdapter.java
package:org.dgpf.search.api.adaptation
qualified name:org.dgpf.search.api.adaptation.DefaultSearchAdapter.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/search/api/adaptation/DefaultSearchAdapter.java
size:10.607 KB (10862 B)
uploaded: 2018-01-07 12:03:35 GMT+0000
last update: 2006-05-11 10:36:12 GMT+0000
last access: 2018-01-07 12:03:35 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
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 16

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 16
last modified at 2018-01-07 12:03:34 GMT+0000
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 19

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/dgpf/htdocs/scripts/datetime.php on line 19
served at 2018-02-21 07:20:04 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo