diff --git a/circuit.h b/circuit.h index a74276c..f99a379 100644 --- a/circuit.h +++ b/circuit.h @@ -78,7 +78,7 @@ int* flip_need_update; std::vector flip_update_queue; // incremental stem struct -int STEM_INC = 0; +const int STEM_INC = 10000; const int STEM_WEIGHT_MAX = 1e9; ll stem_total_weight; int stem_total_cnt; diff --git a/ls.cpp b/ls.cpp index 67ba230..1689d31 100644 --- a/ls.cpp +++ b/ls.cpp @@ -8,7 +8,7 @@ bool Circuit::local_search(std::unordered_set &faults) { - STEM_INC = 0; + //STEM_INC = 0; // 初始化并重置所有 ls 数据结构 ls_init_data_structs(); @@ -142,7 +142,7 @@ bool Circuit::local_search(std::unordered_set &faults) { void Circuit::ls_update_weight() { - STEM_INC++; + //STEM_INC += 5; if(rand() % 10000 <= SP * 10000) { for(Gate* g : gates) { @@ -179,25 +179,29 @@ void Circuit::ls_update_weight() { } } - // for(int i=0; i<=1; i++) { - // if(!fault_weight[g->id][i]) continue; - // for(Gate* suc : g->suc_stems) { - // int inc = 0.2 * fault_weight[g->id][i]; + for(int i=0; i<=1; i++) { + for(Gate* pre : g->suc_stems) { + // int inc = 0.2 * fault_weight[pre->id][i]; + // inc = std::max(1, inc); - // inc = std::max(inc, 1); + // if(g->type == Gate::NAND || g->type == Gate::NOR || g->type == Gate::NOT || g->type == Gate::XNOR) { + // if(fault_weight[g->id][!pre->value] + inc <= FAULT_WEIGHT_MAX) { + // fault_weight[g->id][!pre->value] += inc; + // if(g->sa[!pre->value]) fault_total_weight += inc; + // } + // } else { + // if(fault_weight[g->id][pre->value] + inc <= FAULT_WEIGHT_MAX) { + // fault_weight[g->id][pre->value] += inc; + // if(g->sa[pre->value]) fault_total_weight += inc; + // } + // } - // if(fault_weight[suc->id][0] + inc <= FAULT_WEIGHT_MAX) { - // fault_weight[suc->id][0] += inc; - // if(suc->sa[0]) fault_total_weight += inc; - // } - - // if(fault_weight[suc->id][1] + inc <= FAULT_WEIGHT_MAX) { - // fault_weight[suc->id][1] += inc; - // if(suc->sa[1]) fault_total_weight += inc; - // } - - // } - // } + // if(fault_weight[suc->id][1] + inc <= FAULT_WEIGHT_MAX) { + // fault_weight[suc->id][1] += inc; + // if(suc->sa[1]) fault_total_weight += inc; + // } + } + } if(!g->sa[0] && fault_weight[g->id][0] > 0 && (fault_weight[g->id][0] + FAULT_INC < FAULT_WEIGHT_MAX)) { fault_weight[g->id][0] += FAULT_INC;