Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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