固定权值

This commit is contained in:
YuhangQ 2023-02-24 08:02:14 +00:00
parent 5e6315c9df
commit 73a06ebe64
2 changed files with 24 additions and 20 deletions

View File

@ -78,7 +78,7 @@ int* flip_need_update;
std::vector<Gate*> 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;

42
ls.cpp
View File

@ -8,7 +8,7 @@
bool Circuit::local_search(std::unordered_set<Fault*> &faults) {
STEM_INC = 0;
//STEM_INC = 0;
// 初始化并重置所有 ls 数据结构
ls_init_data_structs();
@ -142,7 +142,7 @@ bool Circuit::local_search(std::unordered_set<Fault*> &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;