在Solver类型中有数据成员及其调整与使用:

数据成员

double step_size;
double step_size_dec;
double min_step_size;

step-size被使用情况
 1 // Revert to the state at given level (keeping all assignment at 'level' but not beyond).
 2 //
 3 void Solver::cancelUntil(int bLevel) {
 4     
 5     if (decisionLevel() > bLevel){
 6 #ifdef PRINT_OUT
 7         std::cout << "bt " << bLevel << "\n";
 8 #endif                
 9         add_tmp.clear();
10         for (int c = trail.size()-1; c >= trail_lim[bLevel]; c--)
11         {
12             Var      x  = var(trail[c]);
13 
14             if (level(x) <= bLevel)
15             {
16                 add_tmp.push(trail[c]);
17             }
18             else
19             {
20                  if (!VSIDS){
21                     uint32_t age = conflicts - picked[x];
22                     if (age > 0){
23                         double adjusted_reward = ((double) (conflicted[x] + almost_conflicted[x])) / ((double) age);
24                         double old_activity = activity_CHB[x];
25                         activity_CHB[x] = step_size * adjusted_reward + ((1 - step_size) * old_activity);
26                         if (order_heap_CHB.inHeap(x)){
27                             if (activity_CHB[x] > old_activity)
28                                 order_heap_CHB.decrease(x);
29                             else
30                                 order_heap_CHB.increase(x);
31                         }
32                     }
33 #ifdef ANTI_EXPLORATION
34                     canceled[x] = conflicts;
35 #endif
36                 }
37                 
38                 assigns [x] = l_Undef;
39 #ifdef PRINT_OUT
40                 std::cout << "undo " << x << "\n";
41 #endif                
42                 if (phase_saving > 1 || (phase_saving == 1) && c > trail_lim.last())
43                     polarity[x] = sign(trail[c]);
44                 insertVarOrder(x);
45             }
46         }
47         qhead = trail_lim[bLevel];
48         trail.shrink(trail.size() - trail_lim[bLevel]);
49         trail_lim.shrink(trail_lim.size() - bLevel);
50         for (int nLitId = add_tmp.size() - 1; nLitId >= 0; --nLitId)
51         {
52             trail.push_(add_tmp[nLitId]);
53         }
54         
55         add_tmp.clear();
56     } 
57 }

 

在Solver::search(int nconflict)中调整情况
1 if (VSIDS){
2    if (--timer == 0 && var_decay < 0.95) timer = 5000, var_decay += 0.01;
3 }else
4    if (step_size > min_step_size) step_size -= step_size_dec;

注1:开始阶段每冲突5000次,衰减系数增加0.01,冲突在(var_decay由0.8增至0.95)75000次冲突之后,保持var_decay为0.95不变。

注2:step_size初始值为0.40,每次冲突缩减step-size-dec = 0.000001;直至再发生340000次冲突之后min_step_size=0.06。也就是说在总的(340000+750000=1090000)次冲突之后不再做调整(时间触发的情形另说),var_decay保持0.95,step-size保持在0.06。

 

posted on 2020-10-10 12:10  海阔凭鱼跃越  阅读(231)  评论(0)    收藏  举报