1
+ classdef DE_base < handle
2
+ properties
3
+ channel % DE_channel
4
+ scheme % DE_scheme
5
+ precision % for threshold computation
6
+ end
7
+
8
+ properties (Access = private )
9
+ max_iterations
10
+ target_error_rate
11
+ end
12
+
13
+ methods
14
+ function obj = DE_base(p_channel , p_scheme , p_max_iterations , p_target_error_rate )
15
+ obj.channel = p_channel ;
16
+ obj.scheme = p_scheme ;
17
+ obj.max_iterations = p_max_iterations ;
18
+ obj.target_error_rate = p_target_error_rate ;
19
+ obj.precision = p_channel .default_precision ; % default precision from the channel
20
+ disp([' threshold is determined with precision: obj.precision = ' num2str(obj .precision )]);
21
+
22
+ % passing functionalities to the ensemble object
23
+ obj .scheme .set_max_iterations(obj .max_iterations );
24
+ obj .scheme .set_target_error_rate(p_target_error_rate );
25
+ obj .scheme .set_channel(p_channel );
26
+ end
27
+
28
+ function threshold = find_threshold(obj )
29
+ % Find the approximate treshold via bisection method (binary search)
30
+
31
+ % initial search range
32
+ channel_param_lb = obj .channel .channel_param_lb ;
33
+ channel_param_ub = obj .channel .channel_param_ub ;
34
+ higher_is_better = obj .channel .higher_is_better ;
35
+
36
+ if (channel_param_lb >= channel_param_ub )
37
+ error(' Lower bound has to be strictly lower than upper bound' );
38
+ end
39
+
40
+ if (higher_is_better )
41
+ % higher ChannelParameter is better (e.g., SNR)
42
+ while (1 )
43
+ channel_param_test = channel_param_lb +(channel_param_ub - channel_param_lb )/2 ;
44
+ success = obj .scheme .density_evolution(channel_param_test );
45
+
46
+ if (success )
47
+ channel_param_ub = channel_param_test ;
48
+ else
49
+ channel_param_lb = channel_param_test ;
50
+ end
51
+
52
+ if (channel_param_ub - channel_param_lb < obj .precision )
53
+ threshold = ceil(channel_param_ub / obj .precision )*obj .precision ;
54
+ if (obj .scheme .density_evolution(threshold - obj .precision ))
55
+ threshold = threshold - obj .precision ;
56
+ end
57
+ break ;
58
+ end
59
+ end % while
60
+ else
61
+ % lower ChannelParameter is better (e.g., erasure prob.)
62
+ while (1 )
63
+ channel_param_test = channel_param_lb +(channel_param_ub - channel_param_lb )/2 ;
64
+ success = obj .scheme .density_evolution(channel_param_test );
65
+
66
+ if (success )
67
+ channel_param_lb = channel_param_test ;
68
+ else
69
+ channel_param_ub = channel_param_test ;
70
+ end
71
+
72
+ if (channel_param_ub - channel_param_lb < obj .precision )
73
+ threshold = floor(channel_param_lb / obj .precision )*obj .precision ;
74
+ if (obj .scheme .density_evolution(threshold + obj .precision ))
75
+ threshold = threshold + obj .precision ;
76
+ end
77
+ break ;
78
+ end
79
+ end % while
80
+ end
81
+ end % find_threshold
82
+
83
+ function pe = get_final_error_rate(obj , channel_parameter_range )
84
+
85
+ pe = zeros(size(channel_parameter_range ));
86
+
87
+ for i = 1 : length(pe )
88
+ obj .scheme .density_evolution(channel_parameter_range(i ));
89
+ pe(i ) = obj .scheme .get_finalErrProb();
90
+ end
91
+ end
92
+
93
+ function iter = required_iterations(obj , channel_parameter_range )
94
+ % Compute the required number of iterations to achieve the target
95
+ % error rate
96
+
97
+ iter = zeros(size(channel_parameter_range ));
98
+
99
+ for i = 1 : length(iter )
100
+ % do bisection search
101
+ iter_lb = 1 ;
102
+ iter_ub = obj .max_iterations ;
103
+
104
+ while (1 )
105
+ iter_test = round(iter_lb + (iter_ub - iter_lb )/2 );
106
+
107
+ obj .scheme .set_max_iterations(iter_test );
108
+ obj .scheme .density_evolution(channel_parameter_range(i ));
109
+ pe = obj .scheme .get_finalErrProb();
110
+
111
+ if (pe > obj .target_error_rate )
112
+ iter_lb = iter_test ;
113
+ else
114
+ iter_ub = iter_test ;
115
+ end
116
+
117
+ if (iter_ub - iter_lb <= 1 )
118
+ iter(i ) = iter_ub ;
119
+ break ;
120
+ end
121
+ end
122
+ end
123
+
124
+ end
125
+ end
126
+ end
0 commit comments