Var Solver::newVar(bool sign, bool dvar),默认sign为true,dvar为true

 1 Var Solver::newVar(bool sign, bool dvar) {
 2     int v = nVars();
 3     watches.init(mkLit(v, false));
 4     watches.init(mkLit(v, true));
 5     watchesBin.init(mkLit(v, false));
 6     watchesBin.init(mkLit(v, true));
 7 
 8     assigns.push(l_Undef);
 9 
10     vardata.push(mkVarData(CRef_Undef, 0));
11 
12     //activity .push(0);
13 
14     activity.push(rnd_init_act ? drand(random_seed) * 0.00001 : 0);
15 
16     seen.push(0);
17 
18     permDiff.push(0);
19 
20     polarity.push(sign);
21 
22     decision.push();
23     trail.capacity(v + 1);
24 
25     setDecisionVar(v, dvar);//确定变量是否将要进行选择
26     return v;
27 }


 

1、watches是OccLists<Lit,vec<Watcher>,WatcherDeleted>类型

1     template<class Idx, class Vec, class Deleted>
2     class OccLists {
3         vec <Vec> occs;
4         vec<char> dirty;
5         vec <Idx> dirties;
6         Deleted deleted;
1         void init(const Idx &idx) {
2             occs.growTo(toInt(idx) + 1);//设置occs长度+1
3             dirty.growTo(toInt(idx) + 1, 0);//设置dirty长度+1,并且元素初始化为0
4         }

2、watchesBin同watches

3、assign是vec<lbool>类型,初始赋值为l_Undef(uint8_t  2)

4、vardata是vec<VarData>

 struct VarData { CRef reason; int level; };
static inline VarData mkVarData(CRef cr, int l){ VarData d = {cr, l}; return d; }

初始化对reason赋值CRef_Undef(UINT32_MAX),level赋值为0

5、activity是vec<double>类型,初始赋值为 rnd_init_act ? drand(random_seed) * 0.00001 : 0。其中rnd_init_act为设置参数

6、seen是vec<char>类型,初始赋值为0

7、permDiff是vec<unsigned int>类型,初始为0

8、plarity是vec<char>类型,初始为“\001”

9、decsion是vec<char>类型,初始为“”

10、trail是vec<Lit>类型,只增大其cap


inline int      Solver::nVars         ()      const   { return vardata.size(); }
1 inline void     Solver::setDecisionVar(Var v, bool b)
2 {
3     if      ( b && !decision[v]) dec_vars++;
4     else if (!b &&  decision[v]) dec_vars--;
5 
6     decision[v] = b;
7     insertVarOrder(v);
8 }
1 inline void Solver::insertVarOrder(Var x) {
2     if (!order_heap.inHeap(x) && decision[x]) order_heap.insert(x); }

 

posted on 2020-10-13 18:09  QzZq  阅读(270)  评论(0)    收藏  举报

导航