src/fb.rs

changeset 91
47d495348e38
parent 89
8d1c959432c8
child 93
8f1e57821d76
equal deleted inserted replaced
90:b471a13e3136 91:47d495348e38
111 fn default() -> Self { 111 fn default() -> Self {
112 FBConfig { τ0: 0.99, σp0: 0.99, insertion: Default::default() } 112 FBConfig { τ0: 0.99, σp0: 0.99, insertion: Default::default() }
113 } 113 }
114 } 114 }
115 115
116 pub(crate) fn prune_with_stats<F: Float, const N: usize>(μ: &mut RNDM<N, F>) -> usize { 116 pub(crate) fn prune_with_stats<F: Float, const N: usize>(
117 μ: &mut RNDM<N, F>,
118 until: usize,
119 ) -> usize {
117 let n_before_prune = μ.len(); 120 let n_before_prune = μ.len();
118 μ.prune(); 121 μ.prune_until(until);
119 debug_assert!(μ.len() <= n_before_prune); 122 debug_assert!(μ.len() <= n_before_prune);
120 n_before_prune - μ.len() 123 n_before_prune - μ.len()
121 } 124 }
122 125
123 #[replace_float_literals(F::cast_from(literal))] 126 #[replace_float_literals(F::cast_from(literal))]
216 ε, 219 ε,
217 ins, 220 ins,
218 &reg, 221 &reg,
219 Some(|μ̃: &RNDM<N, F>| f.apply(μ̃) + reg.apply(μ̃)), 222 Some(|μ̃: &RNDM<N, F>| f.apply(μ̃) + reg.apply(μ̃)),
220 ); 223 );
221 stats.pruned += prune_with_stats(&mut μ); 224
225 // Prune. Do not prune new insertions on first round.
226 stats.pruned += prune_with_stats(&mut μ, μ_base_len);
222 227
223 if config.random_insertions { 228 if config.random_insertions {
224 if let Some(x) = domain.random_point() { 229 if let Some(x) = domain.random_point() {
225 μ += DeltaMeasure { x, α: 0.0 }; 230 μ += DeltaMeasure { x, α: 0.0 };
226 stats.inserted += 1; 231 stats.inserted += 1;
238 } else { 243 } else {
239 None 244 None
240 }; 245 };
241 246
242 if did_merge.is_none() { 247 if did_merge.is_none() {
243 stats.pruned += prune_with_stats(&mut μ); 248 // Prune. Do not prune new insertions on first round.
249 stats.pruned += prune_with_stats(&mut μ, μ_base_len);
244 } 250 }
245 251
246 let iter = state.iteration(); 252 let iter = state.iteration();
247 stats.this_iters += 1; 253 stats.this_iters += 1;
248 254

mercurial