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: 2005-08-10 20:28:01 +0200 (Wed, 10 Aug 2005) $ by $Author: schulte $ 00010 * $Revision: 2202 $ 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 "search/dfs-copy.hh" 00023 #include "search/dfs-reco.hh" 00024 00025 namespace Gecode { namespace Search { 00026 00027 /* 00028 * Control for DFS search engine 00029 * 00030 */ 00031 00032 DFS::DFS(Space* s, unsigned int c_d, unsigned int a_d, size_t sz) { 00033 unsigned int alt; 00034 unsigned long int p = 0; 00035 Space* c = (s->status(alt,p) == SS_FAILED) ? NULL : s->clone(); 00036 if (c_d == 1) { 00037 e = new DfsCopyEngine(c,sz); 00038 } else { 00039 e = new DfsReCoEngine(c,c_d,a_d,sz); 00040 } 00041 e->propagate += p; 00042 e->current(s); 00043 e->current(NULL); 00044 e->current(c); 00045 if (c == NULL) 00046 e->fail += 1; 00047 } 00048 00049 DFS::~DFS(void) { 00050 delete e; 00051 } 00052 00053 Space* 00054 DFS::next(void) { 00055 return e->explore(); 00056 } 00057 00058 Statistics 00059 DFS::statistics(void) const { 00060 Statistics s = *e; 00061 s.memory += e->stacksize(); 00062 return s; 00063 } 00064 00065 }} 00066 00067 // STATISTICS: search-any