⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpsolver.h

📁 多核环境下运行了可满足性分析的工具软件
💻 H
字号:
/************************************************************************************[SimpSolver.h]MiniSat -- Copyright (c) 2003-2006, Niklas Een, Niklas SorenssonPermission is hereby granted, free of charge, to any person obtaining a copy of this software andassociated documentation files (the "Software"), to deal in the Software without restriction,including without limitation the rights to use, copy, modify, merge, publish, distribute,sublicense, and/or sell copies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies orsubstantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUTNOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUTOF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**************************************************************************************************/#ifndef SimpSolver_h#define SimpSolver_h#include <cstdio>#include "Queue.h"#include "Solver.h"namespace mira {  class clauseDB;}namespace minisat {  class SimpSolver : public Solver {  public:    // Constructor/Destructor:    //    SimpSolver();    ~SimpSolver();        // Problem specification:    //    Var     newVar    (bool polarity = true, bool dvar = true);    bool    addClause (vec<Lit>& ps);        // Variable mode:    //     void    setFrozen (Var v, bool b); // If a variable is frozen it will not be eliminated.        // Solving:    //    /*  bool    solve     (bool do_simp = true, bool turn_off_simp = false); */    bool    solve     (bool do_simp = true, bool turn_off_simp = false);    bool    eliminate (bool turn_off_elim = false);  // Perform variable elimination based simplification.     // Generate a (possibly simplified) DIMACS file:    //    void    toDimacs  (const char* file);    // Mode of operation:    //    int     grow;             // Allow a variable elimination step to grow by a number of clauses (default to zero).    bool    asymm_mode;       // Shrink clauses by asymmetric branching.    bool    redundancy_check; // Check if a clause is already implied. Prett costly, and subsumes subsumptions :)    // Statistics:    //    int     merges;    int     asymm_lits;    int     remembered_clauses;    // protected:  public:        // Helper structures:    //    struct ElimData {      int          order;      // 0 means not eliminated, >0 gives an index in the elimination order      vec<Clause*> eliminated;      ElimData() : order(0) {} };        struct ElimOrderLt {      const vec<ElimData>& elimtable;      ElimOrderLt(const vec<ElimData>& et) : elimtable(et) {}      bool operator()(Var x, Var y) { return elimtable[x].order > elimtable[y].order; } };    struct ElimLt {      const vec<int>& n_occ;      ElimLt(const vec<int>& no) : n_occ(no) {}      int  cost      (Var x)        const { return n_occ[toInt(Lit(x))] * n_occ[toInt(~Lit(x))]; }      bool operator()(Var x, Var y) const { return cost(x) < cost(y); } };    // Solver state:    //    int                 elimorder;    bool                use_simplification;    vec<ElimData>       elimtable;    vec<char>           touched;    vec<vec<Clause*> >  occurs;    vec<int>            n_occ;     Heap<ElimLt>        elim_heap;    Queue<Clause*>      subsumption_queue;    vec<char>           frozen;    int                 bwdsub_assigns;    // Temporaries:    //    Clause*             bwdsub_tmpunit;    // Main internal methods:    //    bool          asymm                    (Var v, Clause& c);    bool          asymmVar                 (Var v);    void          updateElimHeap           (Var v);    void          cleanOcc                 (Var v);    vec<Clause*>& getOccurs                (Var x);    void          gatherTouchedClauses     ();    bool          merge                    (const Clause& _ps, const Clause& _qs, Var v, vec<Lit>& out_clause);    bool          merge                    (const Clause& _ps, const Clause& _qs, Var v);    bool          backwardSubsumptionCheck (bool verbose = false);    bool          eliminateVar             (Var v, bool fail = false);    void          remember                 (Var v);    void          extendModel              (int* Belegung);    void          verifyModel              (int* Belegung, char* CNFFile);    void          removeClause             (Clause& c);    bool          strengthenClause         (Clause& c, Lit l);    void          cleanUpClauses           ();    bool          implied                  (const vec<Lit>& c);    void          toDimacs                 (FILE* f, Clause& c);    bool          isEliminated             (Var v) const;    void          litToint                 ();    friend bool transferClauses(mira::clauseDB * theClauseDB, minisat::SimpSolver& simp);    friend int  clausesize(minisat::SimpSolver& simp);  };  //=================================================================================================  // Implementation of inline methods:  inline void SimpSolver::updateElimHeap(Var v) {    if (elimtable[v].order == 0)      elim_heap.update(v); }   inline void SimpSolver::cleanOcc(Var v) {    assert(use_simplification);    Clause **begin = (Clause**)occurs[v];    Clause **end = begin + occurs[v].size();    Clause **i, **j;    for (i = begin, j = end; i < j; i++)      if ((*i)->mark() == 1){	*i = *(--j);	i--;      }    //occurs[v].shrink_(end - j);  // This seems slower. Why?!    occurs[v].shrink(end - j);  }   inline vec<Clause*>& SimpSolver::getOccurs(Var x) {    cleanOcc(x); return occurs[x]; }    inline bool  SimpSolver::isEliminated (Var v) const { return v < elimtable.size() && elimtable[v].order != 0; }  inline void  SimpSolver::setFrozen    (Var v, bool b) { frozen[v] = (char)b; if (b) { updateElimHeap(v); } }  //=================================================================================================  } // end namespace minisat#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -