dfs.cc
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Christian Schulte <schulte@gecode.org> 00004 * 00005 * Copyright: 00006 * Christian Schulte, 2003 00007 * 00008 * Last modified: 00009 * $Date: 2006-08-04 16:03:17 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $ 00010 * $Revision: 3511 $ 00011 * 00012 * This file is part of Gecode, the generic constraint 00013 * development environment: 00014 * http://www.gecode.org 00015 * 00016 * See the file "LICENSE" for information on usage and 00017 * redistribution of this file, and for a 00018 * DISCLAIMER OF ALL WARRANTIES. 00019 * 00020 */ 00021 00022 #include "gecode/search.hh" 00023 00024 namespace Gecode { namespace Search { 00025 00026 /* 00027 * Control for DFS 00028 * 00029 */ 00030 00031 DFS::DFS(Space* s, unsigned int c_d, unsigned int a_d, Stop* st, size_t sz) 00032 : e(c_d,a_d,st,sz) { 00033 unsigned long int p = 0; 00034 Space* c = (s->status(p) == SS_FAILED) ? NULL : s->clone(true,p); 00035 e.init(c); 00036 e.propagate += p; 00037 e.current(s); 00038 e.current(NULL); 00039 e.current(c); 00040 if (c == NULL) 00041 e.fail += 1; 00042 } 00043 00044 Space* 00045 DFS::next(void) { 00046 return e.explore(); 00047 } 00048 00049 bool 00050 DFS::stopped(void) const { 00051 return e.stopped(); 00052 } 00053 00054 Statistics 00055 DFS::statistics(void) const { 00056 Statistics s = e; 00057 s.memory += e.stacksize(); 00058 return s; 00059 } 00060 00061 }} 00062 00063 // STATISTICS: search-any