v2.3: unsat门随机翻转前面

This commit is contained in:
YuhangQ 2023-08-24 06:59:12 +00:00
parent fa63cbb8be
commit a924f08764
2 changed files with 59 additions and 19 deletions

View File

@ -38,7 +38,16 @@ LUT* LUTCircuit::ls_pick() {
if(unsat.size() == 0) return nullptr;
return unsat[rand() % unsat.size()];
pick = unsat[rand() % unsat.size()];
if(pick->fanins.size() == 0) {
return pick;
}
if(rand() % 10000 < 5000) {
return pick->fanins[rand() % pick->fanins.size()];
}
return pick;
}
void LUTCircuit::ls_flip(LUT *lut) {
@ -68,11 +77,41 @@ void LUTCircuit::ls_flip(LUT *lut) {
void LUTCircuit::ls_update(std::vector<LUT*> &unsat) {
// printf("?????????????????ls_update\n");
if(rand() % 10000 <= OPT(sp) * 10000) {
// if(rand() % 10000 <= OPT(sp)) {
// } else {
for(LUT* lut : luts) {
if(lut->vsat) {
if(lut->vunat_cost - OPT(vsat_inc) >= 1) {
lut->vunat_cost -= OPT(vsat_inc);
}
}
if(!lut->vsat) {
unsat.push_back(lut);
}
if(!lut->uptag) {
if(lut->up_cost - OPT(up_inc) >= 1) {
lut->up_cost -= OPT(up_inc);
}
}
for(int i=lut->fanins.size(); i<lut->fanins.size()+lut->inner_gates.size(); i++) {
Gate* g = lut->inner_gates[i-lut->fanins.size()];
LUT::FaultInfo &fi = lut->fault_table[i][lut->input_var];
if(fi.fd[0] && g->fault_detected_weight[0] - OPT(fw_inc) >= 1) {
g->fault_detected_weight[0] -= OPT(fw_inc);
}
if(fi.fd[1] && g->fault_detected_weight[1] - OPT(fw_inc) >= 1) {
g->fault_detected_weight[1] -= OPT(fw_inc);
}
if(fi.fd[0] && g->fault_propagated_weight[0] - OPT(fw_inc) >= 1) {
g->fault_propagated_weight[0] -= OPT(fw_inc);
}
if(fi.fd[1] && g->fault_propagated_weight[1] + OPT(fw_inc) >= 1) {
g->fault_propagated_weight[1] -= OPT(fw_inc);
}
}
}
} else {
for(LUT* lut : luts) {
if(!lut->vsat) {
@ -119,7 +158,7 @@ void LUTCircuit::ls_update(std::vector<LUT*> &unsat) {
}
}
}
// }
}
}
void LUTCircuit::ls_main() {
@ -360,13 +399,13 @@ void LUTCircuit::ls_gen_sol(const TMP_FAULT &target) {
best_sol.push_back(lut->value);
}
for(int step=0; ; step++) {
for(int step=0; step<OPT(max_step_coeff)*luts.size(); step++) {
// printf("step: %d\n", step);
LUT* pick = ls_pick();
if(pick == nullptr) {
break;
pick = luts[rand() % luts.size()];
}
// pick->cal_score();

View File

@ -7,17 +7,18 @@
// name, type, short-name,must-need, default ,low, high, comments
#define PARAS \
PARA( seed , int , '\0' , false , 17 , 0 , 100000000 , "max input numbers of LUT") \
PARA( lut , int , '\0' , false , 8 , 0 , 30 , "max input numbers of LUT") \
PARA( sp , double , '\0' , false , 0.01 , 0 , 1 , "max input numbers of LUT") \
PARA( brk_sp , double , '\0' , false , 0.05 , 0 , 1 , "max input numbers of LUT") \
PARA( t , int , '\0' , false , 30 , 0 , 1000 , "max input numbers of LUT") \
PARA( vsat_inc , int , '\0' , false , 1 , 0 , 100000 , "max input numbers of LUT") \
PARA( vsat_max , int , '\0' , false , 10000 , 0 , 100000 , "max input numbers of LUT") \
PARA( fw_inc , int , '\0' , false , 1 , 0 , 1000 , "max input numbers of LUT") \
PARA( fw_max , int , '\0' , false , 500 , 0 , 1000 , "max input numbers of LUT") \
PARA( up_inc , int , '\0' , false , 1 , 0 , 1000 , "max input numbers of LUT") \
PARA( up_max , int , '\0' , false , 1000 , 0 , 1000 , "max input numbers of LUT")
PARA( seed , int , '\0' , false , 17 , 0 , 100000000 , "max input numbers of LUT") \
PARA( lut , int , '\0' , false , 8 , 0 , 30 , "max input numbers of LUT") \
PARA( sp , double , '\0' , false , 0.01 , 0 , 1 , "max input numbers of LUT") \
PARA( brk_sp , double , '\0' , false , 0.05 , 0 , 1 , "max input numbers of LUT") \
PARA( t , int , '\0' , false , 30 , 0 , 1000 , "max input numbers of LUT") \
PARA( vsat_inc , int , '\0' , false , 1 , 0 , 100000 , "max input numbers of LUT") \
PARA( vsat_max , int , '\0' , false , 10000 , 0 , 100000 , "max input numbers of LUT") \
PARA( fw_inc , int , '\0' , false , 1 , 0 , 1000 , "max input numbers of LUT") \
PARA( fw_max , int , '\0' , false , 500 , 0 , 1000 , "max input numbers of LUT") \
PARA( up_inc , int , '\0' , false , 1 , 0 , 1000 , "max input numbers of LUT") \
PARA( up_max , int , '\0' , false , 1000 , 0 , 1000 , "max input numbers of LUT") \
PARA( max_step_coeff , double , '\0' , false , 10.0 , 1 , 1000 , "max input numbers of LUT")
// name, short-name, must-need, default, comments
#define STR_PARAS \
STR_PARA( instance , 'i' , true , "" , ".bench format instance")