同步代码

This commit is contained in:
YuhangQ 2023-03-21 08:36:53 +00:00
parent f02012ea75
commit 359c2e8cd1
5 changed files with 526 additions and 7224 deletions

BIN
atpg

Binary file not shown.

14
ls.cpp
View File

@ -37,6 +37,8 @@ bool Circuit::local_search() {
break; break;
} }
//assert(is_valid_circuit()); //assert(is_valid_circuit());
auto end = std::chrono::system_clock::now(); auto end = std::chrono::system_clock::now();
@ -160,8 +162,10 @@ int Circuit::ls_pick() {
return var; return var;
// int ccanr_var = CCAnr::module_pick_var(); int ccanr_var = CCAnr::module_pick_var();
// int ccanr_score = ls_pick_score(ccanr_var); int ccanr_score = ls_pick_score(ccanr_var);
return ccanr_var;
// if(var_score > 0 && rand() % 100 <= 10) { // if(var_score > 0 && rand() % 100 <= 10) {
// return var; // return var;
@ -233,7 +237,7 @@ void Circuit::ls_init_stems() {
} }
void Circuit::ls_flip_var(int var) { void Circuit::ls_flip_var(int var) {
//CCAnr::module_flip_var(var); CCAnr::module_flip_var(var);
ClauseLS::flip(var); ClauseLS::flip(var);
if(id2gate.count(var) && id2gate[var]->stem) { if(id2gate.count(var) && id2gate[var]->stem) {
@ -278,7 +282,7 @@ void Circuit::ls_random_circuit() {
// random init clauseLS // random init clauseLS
for(int i=1; i<=ClauseLS::num_vars; i++) { for(int i=1; i<=ClauseLS::num_vars; i++) {
int new_v = rand() % 2; int new_v = CCAnr::module_cur_soln()[i];
if(new_v != ClauseLS::lit_value[i]) { if(new_v != ClauseLS::lit_value[i]) {
//ls_flip_var(i); //ls_flip_var(i);
ClauseLS::flip(i); ClauseLS::flip(i);
@ -357,8 +361,6 @@ void Circuit::ls_reset_data() {
void Circuit::ls_flip_stem(Gate* stem) { void Circuit::ls_flip_stem(Gate* stem) {
printf("flip-stem: %s\n", stem->name.c_str());
stem->value = !stem->value; stem->value = !stem->value;
// update CC // update CC

View File

@ -31,6 +31,8 @@ int main(int args, char* argv[]) {
circuit->global_fault_undetected_count = circuit->gates.size() * 2; circuit->global_fault_undetected_count = circuit->gates.size() * 2;
CCAnr::module_init();
// init clause local search // init clause local search
ClauseLS::init_data_structs(circuit); ClauseLS::init_data_structs(circuit);

View File

@ -1,5 +1,5 @@
# 定义源文件列表 # 定义源文件列表
SOURCES := $(wildcard *.c) $(wildcard *.cpp) SOURCES := $(wildcard *.c) $(wildcard *.cpp) $(wildcard CCAnr/*.cpp)
# 将源文件列表转换为目标文件列表 # 将源文件列表转换为目标文件列表
OBJECTS := $(addprefix build/,$(SOURCES:%=%.o)) OBJECTS := $(addprefix build/,$(SOURCES:%=%.o))

7732
test.cnf

File diff suppressed because it is too large Load Diff