00001 /*****************************************************************************/ 00002 /*! 00003 * \file decision_engine.h 00004 * 00005 * Author: Clark Barrett 00006 * 00007 * Created: Fri Jul 11 13:04:25 2003 00008 * 00009 * <hr> 00010 * Copyright (C) 2003 by the Board of Trustees of Leland Stanford 00011 * Junior University and by New York University. 00012 * 00013 * License to use, copy, modify, sell and/or distribute this software 00014 * and its documentation for any purpose is hereby granted without 00015 * royalty, subject to the terms and conditions defined in the \ref 00016 * LICENSE file provided with this distribution. In particular: 00017 * 00018 * - The above copyright notice and this permission notice must appear 00019 * in all copies of the software and related documentation. 00020 * 00021 * - THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT ANY WARRANTIES, 00022 * EXPRESSED OR IMPLIED. USE IT AT YOUR OWN RISK. 00023 * 00024 * <hr> 00025 * 00026 */ 00027 /*****************************************************************************/ 00028 00029 #ifndef _cvcl__search__decision_engine_h_ 00030 #define _cvcl__search__decision_engine_h_ 00031 00032 #include "statistics.h" 00033 #include "search_fast.h" 00034 00035 namespace CVCL { 00036 00037 class DecisionEngine { 00038 00039 /***************************************************************************/ 00040 /*! 00041 *\defgroup DE Decision Engine 00042 *\brief Decision Engine, used by Search Engine 00043 *\ingroup SE 00044 *@{ 00045 */ 00046 /***************************************************************************/ 00047 00048 protected: 00049 TheoryCore* d_core; //!< Pointer to core theory 00050 SearchImplBase* d_se; //!< Pointer to search engine 00051 00052 //! List of currently active splitters 00053 CDList<Expr> d_splitters; 00054 00055 //! Total number of splitters 00056 StatCounter d_splitterCount; 00057 00058 ExprMap<Expr> d_bestByExpr; 00059 00060 //! Visited cache for findSplitterRec traversal. 00061 /*! Must be emptied in every findSplitter() call. */ 00062 ExprMap<Expr> d_visited; 00063 00064 Expr findSplitterRec(const Expr& e); 00065 virtual bool isBetter(const Expr& e1, const Expr& e2) = 0; 00066 00067 public: 00068 DecisionEngine(TheoryCore* core, SearchImplBase* se); 00069 virtual ~DecisionEngine() { } 00070 00071 /*! @brief Finds a splitter inside a non const expression. 00072 The expression passed in must not be a boolean constant, 00073 otherwise a DebugAssert will occur. \return Null Expr if passed 00074 in a Null Expr. */ 00075 virtual Expr findSplitter(const Expr& e) = 0; 00076 00077 //! Push context and record the splitter 00078 void pushDecision(Expr splitter, bool whichCase=true); 00079 //! Pop last decision (and context) 00080 void popDecision(); 00081 //! Pop to given scope 00082 void popTo(int dl); 00083 00084 //! Return the last known splitter. 00085 Expr lastSplitter(); 00086 00087 //! Search should call this when it derives 'false' 00088 virtual void goalSatisfied() = 0; 00089 00090 /*@}*/ // End of DE group 00091 00092 }; 00093 00094 } 00095 00096 #endif