/* * Main authors: * Christian Schulte * * 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 Restart::Restart(T* s, unsigned int c_d, unsigned int a_d, Search::Stop* st) : Gecode::DFS(s,c_d,a_d,st), root(s->clone()), best(NULL) {} template forceinline Restart::~Restart(void) { delete best; delete root; } template forceinline T* Restart::next(void) { if (best != NULL) { static_cast(root)->constrain(static_cast(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(b); } /* * Restart convenience * */ template T* restart(T* s, unsigned int c_d, unsigned int a_d, Search::Stop* st) { Restart b(s,c_d,a_d,st); T* l = NULL; while (T* n = b.next()) { delete l; l = n; } return l; } } // STATISTICS: search-any