model_enumerators.h
Go to the documentation of this file.
00001 // 
00002 // Copyright (c) 2006-2011, Benjamin Kaufmann
00003 // 
00004 // This file is part of Clasp. See http://www.cs.uni-potsdam.de/clasp/ 
00005 // 
00006 // Clasp is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // Clasp is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with Clasp; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 #ifndef CLASP_MODEL_ENUMERATORS_H
00021 #define CLASP_MODEL_ENUMERATORS_H
00022 
00023 #ifdef _MSC_VER
00024 #pragma once
00025 #endif
00026 
00027 #include <clasp/enumerator.h>
00028 #include <clasp/clause.h>
00029 
00030 namespace Clasp { 
00031 
00033 
00059 class ModelEnumerator : public Enumerator {
00060 public:
00062         enum Strategy {
00063                 strategy_auto      = 0, 
00064                 strategy_backtrack = 1, 
00065                 strategy_record    = 2  
00066         };
00068         enum ProjectOptions {
00069                 project_enable_simple = 1, 
00070                 project_use_heuristic = 2, 
00071                 project_save_progress = 4, 
00072                 project_enable_full   = 6, 
00073         };
00077         explicit ModelEnumerator(Strategy st = strategy_auto);
00078         ~ModelEnumerator();
00079         
00081 
00085         void     setStrategy(Strategy st = strategy_auto, uint32 projection = 0);
00086         bool     projectionEnabled()const { return project_ != 0; }
00087         Strategy strategy()         const { return static_cast<Strategy>(options_ & 3u); }
00088 protected:
00089         bool   supportsRestarts() const { return optimize() || strategy() == strategy_record; }
00090         bool   supportsParallel() const { return !projectionEnabled() || strategy() != strategy_backtrack; }
00091         ConPtr doInit(SharedContext& ctx, MinimizeConstraint* m, int numModels);
00092 private:
00093         enum { detect_strategy_flag = 4u, trivial_flag = 8u, strategy_opts_mask = 15u };
00094         class ModelFinder;
00095         class BacktrackFinder;
00096         class RecordFinder;
00097         class SolutionQueue;
00098         typedef SolutionQueue* QPtr;
00099         void    initProjection(SharedContext& ctx);
00100         void    addProjectVar(SharedContext& ctx, Var v, bool mark);
00101         uint32  numProjectionVars() const { return (uint32)project_->size(); }
00102         Var     projectVar(uint32 i)const { return (*project_)[i]; }
00103         uint32  projectOpts()       const { return options_ >> 4; }
00104         bool    detectStrategy()    const { return (options_ & detect_strategy_flag) == detect_strategy_flag; }
00105         bool    trivial()           const { return (options_ & trivial_flag) == trivial_flag; }
00106         QPtr    queue_;
00107         VarVec* project_;
00108         uint32  options_;
00109 };
00110 
00111 }
00112 #endif


clasp
Author(s): Benjamin Kaufmann
autogenerated on Thu Aug 27 2015 12:41:39