Commit b0da060e by chengshuyao

rebuild oneway correct

parent e97178bf
......@@ -184,8 +184,8 @@ int main(int argc,char* argv[]){
//search_partition(parameter_input_bit_width,start_order);
};
int search_partition(int start_order_depth, int* start_order){
random_device rd;
mt19937 gen(rd());
random_device rddd;
mt19937 gen(rddd());
int max_partition_parts = min(10,int(parameter_output_bit_width)+1);
int best_partition_parts = 1;
int best_area = 999999;
......
......@@ -741,14 +741,27 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
all_zero_right_list[j] = 0;
all_one_right_list[j] = 0;
double early_stop_accuracy_node = 1 - (1-parameter_early_stop_accuracy)/double(1);
if(double(how_many_zeros_left)/double(BSD_samples) > parameter_early_stop_accuracy)
all_zero_left_list[j] = 1;
else if(double(how_many_ones_left)/double(BSD_samples) > parameter_early_stop_accuracy)
all_one_left_list[j] = 1;
if(double(how_many_zeros_right)/double(BSD_samples) > parameter_early_stop_accuracy)
all_zero_right_list[j] = 1;
else if(double(how_many_ones_right)/double(BSD_samples) > parameter_early_stop_accuracy)
all_one_right_list[j] = 1;
if(parameter_early_stop_oneway){
if(how_many_zeros_left == BSD_samples)
all_zero_left_list[j] = 1;
else if(double(how_many_ones_left)/double(BSD_samples) > parameter_early_stop_accuracy)
all_one_left_list[j] = 1;
if(how_many_zeros_right == BSD_samples)
all_zero_right_list[j] = 1;
else if(double(how_many_ones_right)/double(BSD_samples) > parameter_early_stop_accuracy)
all_one_right_list[j] = 1;
}
else{
if(double(how_many_zeros_left)/double(BSD_samples) > parameter_early_stop_accuracy)
all_zero_left_list[j] = 1;
else if(double(how_many_ones_left)/double(BSD_samples) > parameter_early_stop_accuracy)
all_one_left_list[j] = 1;
if(double(how_many_zeros_right)/double(BSD_samples) > parameter_early_stop_accuracy)
all_zero_right_list[j] = 1;
else if(double(how_many_ones_right)/double(BSD_samples) > parameter_early_stop_accuracy)
all_one_right_list[j] = 1;
}
}
......
......@@ -69,24 +69,51 @@ int BDD_class::compare_simplify_list(int list_line_amount,bool* this_line,bool**
which_list_number = -1;
double early_stop_accuracy_node = 1 - (1-parameter_early_stop_accuracy)/double(4);
if(early_stop_accuracy_node < 1 - double(1)/BSD_samples){
for (int i=list_line_amount-1;i>=0;i--){
it_can_simplify_here = 0;
int same_bit = 0;
if((hash_number < double(hash_simplify_list[i]) * early_stop_accuracy_node) || (hash_number > double(hash_simplify_list[i]) / early_stop_accuracy_node)){
if(parameter_early_stop_oneway){
for (int i=list_line_amount-1;i>=0;i--){
it_can_simplify_here = 0;
}else{
for(int j=0;j<BSD_samples;j++){
if(simplify_list[i][j] == this_line[j]){
same_bit += 1;
int same_bit = 0;
bool oneway_merge =1;
if((hash_number < double(hash_simplify_list[i]) * early_stop_accuracy_node) || (hash_number > double(hash_simplify_list[i]) / early_stop_accuracy_node)){
it_can_simplify_here = 0;
}else{
for(int j=0;j<BSD_samples;j++){
if(simplify_list[i][j] == this_line[j]){
same_bit += 1;
}else if(!simplify_list[i][j] && this_line[j]){
oneway_merge = 0;
break;
}
}
if(double(same_bit)/double(BSD_samples) > early_stop_accuracy_node)
it_can_simplify_here = oneway_merge;
}
if(it_can_simplify_here){
it_can_simplify = 1;
which_list_number = i;
break;
}
if(double(same_bit)/double(BSD_samples) > early_stop_accuracy_node)
it_can_simplify_here = 1;
}
if(it_can_simplify_here){
it_can_simplify = 1;
which_list_number = i;
break;
}else{
for (int i=list_line_amount-1;i>=0;i--){
it_can_simplify_here = 0;
int same_bit = 0;
if((hash_number < double(hash_simplify_list[i]) * early_stop_accuracy_node) || (hash_number > double(hash_simplify_list[i]) / early_stop_accuracy_node)){
it_can_simplify_here = 0;
}else{
for(int j=0;j<BSD_samples;j++){
if(simplify_list[i][j] == this_line[j]){
same_bit += 1;
}
}
if(double(same_bit)/double(BSD_samples) > early_stop_accuracy_node)
it_can_simplify_here = 1;
}
if(it_can_simplify_here){
it_can_simplify = 1;
which_list_number = i;
break;
}
}
}
......
......@@ -10,8 +10,10 @@ int parameter_output_bit_width = PO_WIDTH;//最小为1,最大为PO_WIDTH
extern const int parameter_search_iterations = 10; //最大设计次数
extern const int parameter_test_ios = 1000000; //测试要求多少样本
extern const int parameter_max_samples = 64*100; //BSD每一个节点最多进行多少次采样,至少为64
extern const double parameter_early_stop_accuracy = 0.99; //允许的错误率,如果完全不允许,设为1; 没有特殊需要不要设到<1,会慢一些。
extern const double parameter_early_stop_accuracy = 1; //允许的错误率,如果完全不允许,设为1;
//没有特殊需要不要设到<1,会慢一些。
//0.5以下无意义,建议至少设到0.8吧.
extern const bool parameter_early_stop_oneway = 1; //如果设为1,只允许0->1 的错误,不允许1->0的错误
extern const int parameter_num_threads = 32; //线程数
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment