| 1004 I: AlgIteratorFactory<IterInfo<F>>, |
1004 I: AlgIteratorFactory<IterInfo<F>>, |
| 1005 Dat: DifferentiableMapping<DiscreteMeasure<U, F>, Codomain = F> + BoundedCurvature<F>, |
1005 Dat: DifferentiableMapping<DiscreteMeasure<U, F>, Codomain = F> + BoundedCurvature<F>, |
| 1006 Dat::DerivativeDomain: |
1006 Dat::DerivativeDomain: |
| 1007 DifferentiableMapping<U, Codomain = F> + ClosedMul<F> + MinMaxMapping<U, F>, |
1007 DifferentiableMapping<U, Codomain = F> + ClosedMul<F> + MinMaxMapping<U, F>, |
| 1008 //for<'a> Dat::Differential<'a>: Lipschitz<&'a P, FloatType = F>, |
1008 //for<'a> Dat::Differential<'a>: Lipschitz<&'a P, FloatType = F>, |
| 1009 DiscreteMeasure<U, F>: SpikeMerging<F>, |
1009 DiscreteMeasure<U, F>: SpikeMerging<F> + Norm<Radon, F>, |
| 1010 Reg: SlidingRegTerm<U, F>, |
1010 Reg: SlidingRegTerm<U, F>, |
| 1011 P: TransportProxPenalty<U, Dat::DerivativeDomain, Reg, F> + StepLengthBound<F, Dat>, |
1011 P: TransportProxPenalty<U, Dat::DerivativeDomain, Reg, F> + StepLengthBound<F, Dat>, |
| 1012 Plot: Plotter<P::ReturnMapping, Dat::DerivativeDomain, DiscreteMeasure<U, F>>, |
1012 Plot: Plotter<P::ReturnMapping, Dat::DerivativeDomain, DiscreteMeasure<U, F>>, |
| 1013 { |
1013 { |
| 1014 // Check parameters |
1014 // Check parameters |
| 1036 // by τ compared to the conditional gradient approach. |
1036 // by τ compared to the conditional gradient approach. |
| 1037 let tolerance = config.insertion.tolerance * τ * reg.tolerance_scaling(); |
1037 let tolerance = config.insertion.tolerance * τ * reg.tolerance_scaling(); |
| 1038 let mut ε = tolerance.initial(); |
1038 let mut ε = tolerance.initial(); |
| 1039 |
1039 |
| 1040 // Statistics |
1040 // Statistics |
| 1041 let full_stats = |μ: &DiscreteMeasure<U, F>, ε, stats| IterInfo { |
1041 let full_stats = |
| 1042 value: f.apply(μ) + reg.apply(μ), |
1042 |μ: &DiscreteMeasure<U, F>, v: &mut Dat::DerivativeDomain, ε, stats| IterInfo { |
| 1043 n_spikes: μ.len(), |
1043 value: f.apply(μ) + reg.apply(μ), |
| 1044 ε, |
1044 n_spikes: μ.len(), |
| 1045 // postprocessing: config.insertion.postprocessing.then(|| μ.clone()), |
1045 discrepancy: Some(τ * reg.discrepancy(v, 1.0, ε / τ, μ, &config.insertion)), |
| 1046 ..stats |
1046 μ_norm: μ.norm(Radon), |
| 1047 }; |
1047 ε, |
| |
1048 // postprocessing: config.insertion.postprocessing.then(|| μ.clone()), |
| |
1049 ..stats |
| |
1050 }; |
| 1048 let mut stats = IterInfo::new(); |
1051 let mut stats = IterInfo::new(); |
| 1049 |
1052 |
| |
1053 // Construct initial smooth part of surrogate model |
| |
1054 let mut v = f.differential(&μ); |
| |
1055 |
| 1050 // Run the algorithm |
1056 // Run the algorithm |
| 1051 for state in iterator.iter_init(|| full_stats(&μ, ε, stats.clone())) { |
1057 for state in iterator.iter_init(|| full_stats(&μ, &mut v, ε, stats.clone())) { |
| 1052 let mut v = f.differential(&μ); |
|
| 1053 |
|
| 1054 // Calculate initial transport |
1058 // Calculate initial transport |
| 1055 prox_penalty.initial_transport( |
1059 prox_penalty.initial_transport( |
| 1056 &mut γ, |
1060 &mut γ, |
| 1057 &μ, |
1061 &μ, |
| 1058 ε, |
1062 ε, |
| 1162 } |
1166 } |
| 1163 |
1167 |
| 1164 let iter = state.iteration(); |
1168 let iter = state.iteration(); |
| 1165 stats.this_iters += 1; |
1169 stats.this_iters += 1; |
| 1166 |
1170 |
| |
1171 // Update smooth part of surrogate model |
| |
1172 v = f.differential(&μ); |
| |
1173 |
| 1167 // Give statistics if requested |
1174 // Give statistics if requested |
| 1168 state.if_verbose(|| { |
1175 state.if_verbose(|| { |
| 1169 plotter.plot_spikes(iter, None, Some(&τv̆), &μ); |
1176 plotter.plot_spikes(iter, None, Some(&v), &μ); |
| 1170 full_stats(&μ, ε, std::mem::replace(&mut stats, IterInfo::new())) |
1177 full_stats( |
| |
1178 &μ, |
| |
1179 &mut v, |
| |
1180 ε, |
| |
1181 std::mem::replace(&mut stats, IterInfo::new()), |
| |
1182 ) |
| 1171 }); |
1183 }); |
| 1172 |
1184 |
| 1173 // Update main tolerance for next iteration |
1185 // Update main tolerance for next iteration |
| 1174 ε = tolerance.update(ε, iter); |
1186 ε = tolerance.update(ε, iter); |
| 1175 } |
1187 } |
| 1196 I: AlgIteratorFactory<IterInfo<F>>, |
1208 I: AlgIteratorFactory<IterInfo<F>>, |
| 1197 Dat: DifferentiableMapping<DiscreteMeasure<U, F>, Codomain = F> + BoundedCurvature<F>, |
1209 Dat: DifferentiableMapping<DiscreteMeasure<U, F>, Codomain = F> + BoundedCurvature<F>, |
| 1198 Dat::DerivativeDomain: |
1210 Dat::DerivativeDomain: |
| 1199 DifferentiableMapping<U, Codomain = F> + ClosedMul<F> + MinMaxMapping<U, F>, |
1211 DifferentiableMapping<U, Codomain = F> + ClosedMul<F> + MinMaxMapping<U, F>, |
| 1200 //for<'a> Dat::Differential<'a>: Lipschitz<&'a P, FloatType = F>, |
1212 //for<'a> Dat::Differential<'a>: Lipschitz<&'a P, FloatType = F>, |
| 1201 DiscreteMeasure<U, F>: SpikeMerging<F>, |
1213 DiscreteMeasure<U, F>: SpikeMerging<F> + Norm<Radon, F>, |
| 1202 Reg: SlidingRegTerm<U, F>, |
1214 Reg: SlidingRegTerm<U, F>, |
| 1203 P: TransportProxPenalty<U, Dat::DerivativeDomain, Reg, F> + StepLengthBound<F, Dat>, |
1215 P: TransportProxPenalty<U, Dat::DerivativeDomain, Reg, F> + StepLengthBound<F, Dat>, |
| 1204 Plot: Plotter<P::ReturnMapping, Dat::DerivativeDomain, DiscreteMeasure<U, F>>, |
1216 Plot: Plotter<P::ReturnMapping, Dat::DerivativeDomain, DiscreteMeasure<U, F>>, |
| 1205 { |
1217 { |
| 1206 pointsource_sliding_fb( |
1218 pointsource_sliding_fb( |