Sha256: 6c1ccb394ddd776861cf6b66cebfd0dbc0216a8dc3183d3819093c2d7c5867f6

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

/*
 *  Main authors:
 *     Christian Schulte <schulte@gecode.org>
 *
 *  Copyright:
 *     Christian Schulte, 2004
 *
 *  Last modified:
 *     $Date: 2006-03-31 10:27:07 +0200 (Fri, 31 Mar 2006) $ by $Author: schulte $
 *     $Revision: 3142 $
 *
 *  This file is part of Gecode, the generic constraint
 *  development environment:
 *     http://www.gecode.org
 *
 *  See the file "LICENSE" for information on usage and
 *  redistribution of this file, and for a
 *     DISCLAIMER OF ALL WARRANTIES.
 *
 */

namespace Gecode {

  /*
   * Control for restart best solution search engine
   *
   */

  template <class T>
  Restart<T>::Restart(T* s, unsigned int c_d, unsigned int a_d,
		      Search::Stop* st) :
    Gecode::DFS<T>(s,c_d,a_d,st), root(s->clone()), best(NULL) {}

  template <class T>
  forceinline
  Restart<T>::~Restart(void) {
    delete best;
    delete root;
  }

  template <class T>
  forceinline T*
  Restart<T>::next(void) {
    if (best != NULL) {
      static_cast<T*>(root)->constrain(static_cast<T*>(best));
      this->e.clone++;
      this->e.reset(root->clone(true,this->e.propagate));
    }
    Space* b = this->e.explore();
    delete best;
    best = (b != NULL) ? b->clone() : NULL;
    return static_cast<T*>(b);
  }




  /*
   * Restart convenience
   *
   */

  template <class T>
  T*
  restart(T* s, unsigned int c_d, unsigned int a_d, Search::Stop* st) {
    Restart<T> b(s,c_d,a_d,st);
    T* l = NULL;
    while (T* n = b.next()) {
      delete l; l = n;
    }
    return l;
  }

}

// STATISTICS: search-any

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gecoder-with-gecode-0.7.1 ext/gecode-1.3.1/gecode/search/restart.icc