diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2fd5bc6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,42 @@ +{ + "files.associations": { + "array": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "functional": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "type_traits": "cpp", + "tuple": "cpp", + "typeinfo": "cpp", + "utility": "cpp" + } +} \ No newline at end of file diff --git a/atpg b/atpg index b838526..e4d0301 100755 Binary files a/atpg and b/atpg differ diff --git a/ls.cpp b/ls.cpp index 4757042..46ab20b 100644 --- a/ls.cpp +++ b/ls.cpp @@ -8,7 +8,6 @@ #include - bool Circuit::local_search(std::unordered_set &faults) { // 初始化并重置所有 ls 数据结构 @@ -29,30 +28,29 @@ bool Circuit::local_search(std::unordered_set &faults) { Gate* stem = nullptr; ll max_score = 0; - std::vector stems_random; - std::vector candidates; + // std::vector stems_random; + // std::vector candidates; - for(int i=0; iid]) { - stems_random.push_back(stems[i]); - } - } - for(int i=0; iid]) { + // stems_random.push_back(stems[i]); + // } + // } + // for(int i=0; iid]) continue; + ll t_score = ls_pick_score(t_stem); if(t_score > max_score) { max_score = t_score; stem = t_stem; } - if(t_score > 0) t++; - if(i >= T) break; } if(max_score > 0) { @@ -78,17 +76,18 @@ bool Circuit::local_search(std::unordered_set &faults) { } else { ls_update_weight(); - while(!flip_update_queue.empty()) { - Gate* g = flip_update_queue.back(); - flip_update_queue.pop_back(); - if(!flip_need_update[g->id]) continue; - flip_need_update[g->id] = false; - flip_total_weight -= flip_weight[g->id]; - flip_total_cnt -= 1; - ls_update(g); - } + - if(stem_total_cnt == stems.size() && flip_total_cnt == 0) { + if(stem_total_cnt == stems.size()) { + while(!flip_update_queue.empty()) { + Gate* g = flip_update_queue.back(); + flip_update_queue.pop_back(); + if(!flip_need_update[g->id]) continue; + flip_need_update[g->id] = false; + flip_total_weight -= flip_weight[g->id]; + flip_total_cnt -= 1; + ls_update(g); + } //printf("FIND SOLUTION!\n"); printf("[SOL] flip: %lld, stem: %lld, fault:%lld. flip_cnt: %d, stem_cnt: %d, fault_cnt:%d\n", flip_total_weight, stem_total_weight, fault_total_weight, flip_total_cnt, stem_total_cnt, fault_total_cnt); break; @@ -237,7 +236,7 @@ ll Circuit::ls_pick_score(Gate* stem) { ll Circuit::ls_score() { //ll score = - flip_total_weight - stem_total_weight + fault_total_weight + fault_propagate_tatal_len; - ll score = - flip_total_weight - stem_total_weight + fault_propagate_score; + ll score = - flip_total_weight - stem_total_weight + fault_propagate_score + fault_total_weight; return score; }