Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BSD
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chengshuyao
BSD
Commits
c76031ea
Commit
c76031ea
authored
Jul 17, 2025
by
chengshuyao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set parameters for early stop
parent
f9289063
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
18 deletions
+21
-18
src/BSD.cpp
+5
-2
src/BSD.h
+9
-9
src/next_layer_bit.h
+2
-2
src/top.h
+5
-5
No files found.
src/BSD.cpp
View file @
c76031ea
...
...
@@ -134,7 +134,7 @@ int BSD_execute(int variable_order_number,int** variable_order, int partition_de
BDD_class
BDD_class_main
;
BDD_class_main
.
which_demo_function
=
GLOBAL_which_demo_function
;
for
(
int
j
=
0
;
j
<
parameter_max_orders
;
j
++
){
cout
<<
"j"
<<
j
<<
endl
;
//
cout<<"j"<<j<<endl;
BDD_class_main
.
BSD_variable_order
[
j
]
=
new
int
[
parameter_input_bit_width
];
}
cout
<<
"This variable order: "
<<
variable_order_number
<<
endl
;
...
...
@@ -477,7 +477,10 @@ void search_order(int search_iterations, bool allow_partition){
best_order_num
=
zi
;
}
if
(
i
>=
parameter_max_orders
)
parameter_early_stop_split_nodes
=
int
(
best_reward_max
*
1.5
);
if
(
best_reward_max
<
500
)
parameter_early_stop_split_nodes
=
1000
;
else
parameter_early_stop_split_nodes
=
int
(
best_reward_max
*
2
);
cout
<<
endl
;
cout
<<
"Best Iteration: "
<<
best_iteration
<<
endl
;
cout
<<
"This Iteration: "
<<
i
<<
endl
;
...
...
src/BSD.h
View file @
c76031ea
...
...
@@ -246,10 +246,10 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
feature_area
=
0
;
cout
<<
"Train BDD "
<<
endl
;
//
cout<<"Train BDD "<<endl;
for
(
i
=
0
;
i
<
start_depth
+
1
;
i
++
)
BDD
[
i
]
=
new
BDD_node
[
how_many_start_nodes
];
c
out
<<
"New nodes "
<<
endl
;
//
out<<"New nodes "<<endl;
for
(
i
=
0
;
i
<
how_many_start_nodes
;
i
++
){
BDD
[
start_depth
][
i
].
which_bit_output
=
start_nodes
[
i
].
which_bit_output
;
BDD
[
start_depth
][
i
].
which_root_node
=
start_nodes
[
i
].
which_root_node
;
...
...
@@ -262,7 +262,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
BDD_mask_this
[
i
].
mask
[
zi
]
=
start_nodes
[
i
].
mask
[
zi
];
}
}
cout
<<
"Initial nodes "
<<
endl
;
//
cout<<"Initial nodes "<<endl;
total_finish_weight
=
0
;
BDD_width_each_layer
[
start_depth
]
=
how_many_start_nodes
;
...
...
@@ -289,7 +289,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
total_split_nodes_recursive
=
total_split_nodes
;
feature_area
+=
total_nodes_amount
;
bool
this_layer_need_partition
=
(
i
==
partition_depth
);
cout
<<
"Start partition check "
;
//
cout<<"Start partition check ";
if
(
this_layer_need_partition
){
cout
<<
"go for partition"
<<
endl
;
partition_into_how_many_parts
=
min
(
2
,
int
(
partition_parts
));
...
...
@@ -409,7 +409,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
}
cout
<<
"Finish partition check "
<<
endl
;
//
cout<<"Finish partition check "<<endl;
BSD_samples_train
=
BSD_samples_train_each_layer
();
BSD_samples_sort
=
BSD_samples_sort_each_layer
();
...
...
@@ -422,10 +422,10 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
total_nodes_amount
+=
BDD_width_each_layer
[
i
];
cout
<<
"New BSD nodes start "
<<
BDD_width_each_layer
[
i
]
<<
endl
;
//
cout<<"New BSD nodes start "<<BDD_width_each_layer[i]<<endl;
BDD
[
i
+
1
]
=
new
BDD_node
[
BDD_width_each_layer
[
i
]
*
2
];
cout
<<
"New BSD nodes finish "
<<
endl
;
//
cout<<"New BSD nodes finish "<<endl;
for
(
zi
=
0
;
zi
<
BDD_width_each_layer
[
i
]
*
2
;
zi
++
){
BDD
[
i
+
1
][
zi
].
has_equal_father
=
0
;
BDD
[
i
+
1
][
zi
].
non_equal_number
=
0
;
...
...
@@ -510,7 +510,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
break
;
}
}
if
((
i
==
(
parameter_early_stop_depth
-
1
))
&&
(
which_BDD
==
0
)
||
((
i
==
(
parameter_early_stop_depth
-
1
))
&&
(
which_BDD
==
1
))
||
((
total_split_nodes_recursive
)
>
parameter_early_stop_split_nodes
*
1
.
4
)){
if
((
i
==
(
parameter_early_stop_depth
-
1
))
&&
(
which_BDD
==
0
)
||
((
i
==
(
parameter_early_stop_depth
-
1
))
&&
(
which_BDD
==
1
))
||
((
total_split_nodes_recursive
+
)
>
parameter_early_stop_split_nodes
-
BDD_width_each_layer
[
i
]
)){
if
(
left_mask_output_data_sum
>
(
BSD_samples
/
2
)){
all_one_left
=
1
;
all_zero_left
=
0
;
...
...
@@ -911,7 +911,7 @@ int BDD_class::BDD_FULL_PROCESS(){
train_BDD
(
BDD
,
most_influence
,
start_depth
,
how_many_start_nodes
,
start_nodes
);
int
best_total_split_nodes_recursive
=
total_split_nodes_recursive
;
cout
<<
"Finish Train"
<<
endl
;
for
(
int
k
=
0
;
k
<
1
;
k
++
){
for
(
int
k
=
0
;
k
<
2
;
k
++
){
for
(
int
i
=
1
;
i
<
total_BDD_depth
-
2
;
i
++
){
//cout<<"Switch BDD: "<<i<<" ";
BSD_switch_layer
(
i
);
...
...
src/next_layer_bit.h
View file @
c76031ea
...
...
@@ -116,10 +116,10 @@ int BDD_class::next_bit_layer_single(int depth,int which_node_this_layer){
int
BDD_class
::
next_bit_layer
(
int
depth
,
int
order_num
){
cout
<<
"Depth: "
<<
depth
<<
" Order num: "
<<
BSD_variable_order_number
<<
endl
;
//
cout<<"Depth: "<<depth<<" Order num: "<<BSD_variable_order_number<<endl;
if
((
depth
<
BSD_variable_order_number
)
){
most_influence
[
depth
]
=
BSD_variable_order
[
order_num
][
depth
];
cout
<<
"Most influence depth"
<<
most_influence
[
depth
]
<<
endl
;
//
cout<<"Most influence depth"<<most_influence[depth]<<endl;
has_been_unfold
[
most_influence
[
depth
]]
=
1
;
cout
<<
most_influence
[
depth
]
<<
endl
;
return
BSD_variable_order
[
order_num
][
depth
];
...
...
src/top.h
View file @
c76031ea
extern
const
int
parameter_input_bit_width
=
64
+
5
;
//输入bit有几位,写在+6前面。+6是为了防止一些bug的冗余设计。
extern
const
int
parameter_output_bit_width
=
32
;
//输出bit有几位
extern
const
int
parameter_input_bit_width
=
33
+
5
;
//输入bit有几位,写在+6前面。+6是为了防止一些bug的冗余设计。
extern
const
int
parameter_output_bit_width
=
25
;
//输出bit有几位
#include"io_generator/c1908.h"
#include"io_generator_function.h"
int
parameter_search_iterations
=
1000
;
//最大设计次数
int
parameter_test_ios
=
100
;
//测试要求多少样本
extern
const
int
parameter_max_samples
=
int
(
parameter_test_ios
*
4
0
);
//BSD每一个节点最多进行多少次采样
extern
const
int
parameter_max_samples
=
int
(
parameter_test_ios
*
2
0
);
//BSD每一个节点最多进行多少次采样
bool
*
io_generator_function
(
bool
input_data
[
parameter_input_bit_width
],
int
which_demo_function
,
bool
*
output_data
)
{
...
...
@@ -13,8 +13,8 @@ bool* io_generator_function(bool input_data[parameter_input_bit_width],int which
int
i
,
j
;
bool
*
output_data_temp
=
new
bool
[
100
];
//
io_generator_outer(input_data,output_data_temp);
io_generator_single_function_1
(
input_data
,
output_data_temp
);
io_generator_outer
(
input_data
,
output_data_temp
);
//
io_generator_single_function_1(input_data,output_data_temp);
for
(
i
=
0
;
i
<
parameter_output_bit_width
;
i
++
){
output_data
[
i
]
=
output_data_temp
[
i
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment