65 use crate::plot::*; |
65 use crate::plot::*; |
66 use crate::AlgorithmOverrides; |
66 use crate::AlgorithmOverrides; |
67 |
67 |
68 /// Available algorithms and their configurations |
68 /// Available algorithms and their configurations |
69 #[derive(Copy, Clone, Debug, Serialize, Deserialize)] |
69 #[derive(Copy, Clone, Debug, Serialize, Deserialize)] |
70 pub enum AlgorithmConfig<F : Float> { |
70 pub enum AlgorithmConfig<F : ClapFloat> { |
71 FB(FBConfig<F>), |
71 FB(FBConfig<F>), |
72 FW(FWConfig<F>), |
72 FW(FWConfig<F>), |
73 PDPS(PDPSConfig<F>), |
73 PDPS(PDPSConfig<F>), |
74 } |
74 } |
75 |
75 |
139 PDPS, |
139 PDPS, |
140 } |
140 } |
141 |
141 |
142 impl DefaultAlgorithm { |
142 impl DefaultAlgorithm { |
143 /// Returns the algorithm configuration corresponding to the algorithm shorthand |
143 /// Returns the algorithm configuration corresponding to the algorithm shorthand |
144 pub fn default_config<F : Float>(&self) -> AlgorithmConfig<F> { |
144 pub fn default_config<F : ClapFloat>(&self) -> AlgorithmConfig<F> { |
145 use DefaultAlgorithm::*; |
145 use DefaultAlgorithm::*; |
146 match *self { |
146 match *self { |
147 FB => AlgorithmConfig::FB(Default::default()), |
147 FB => AlgorithmConfig::FB(Default::default()), |
148 FISTA => AlgorithmConfig::FB(FBConfig{ |
148 FISTA => AlgorithmConfig::FB(FBConfig{ |
149 meta : FBMetaAlgorithm::InertiaFISTA, |
149 meta : FBMetaAlgorithm::InertiaFISTA, |
157 PDPS => AlgorithmConfig::PDPS(Default::default()), |
157 PDPS => AlgorithmConfig::PDPS(Default::default()), |
158 } |
158 } |
159 } |
159 } |
160 |
160 |
161 /// Returns the [`Named`] algorithm corresponding to the algorithm shorthand |
161 /// Returns the [`Named`] algorithm corresponding to the algorithm shorthand |
162 pub fn get_named<F : Float>(&self) -> Named<AlgorithmConfig<F>> { |
162 pub fn get_named<F : ClapFloat>(&self) -> Named<AlgorithmConfig<F>> { |
163 self.to_named(self.default_config()) |
163 self.to_named(self.default_config()) |
164 } |
164 } |
165 |
165 |
166 pub fn to_named<F : Float>(self, alg : AlgorithmConfig<F>) -> Named<AlgorithmConfig<F>> { |
166 pub fn to_named<F : ClapFloat>(self, alg : AlgorithmConfig<F>) -> Named<AlgorithmConfig<F>> { |
167 let name = self.to_possible_value().unwrap().get_name().to_string(); |
167 let name = self.to_possible_value().unwrap().get_name().to_string(); |
168 Named{ name , data : alg } |
168 Named{ name , data : alg } |
169 } |
169 } |
170 } |
170 } |
171 |
171 |
194 |
194 |
195 /// Algorithm and iterator config for the experiments |
195 /// Algorithm and iterator config for the experiments |
196 |
196 |
197 #[derive(Clone, Debug, Serialize)] |
197 #[derive(Clone, Debug, Serialize)] |
198 #[serde(default)] |
198 #[serde(default)] |
199 pub struct Configuration<F : Float> { |
199 pub struct Configuration<F : ClapFloat> { |
200 /// Algorithms to run |
200 /// Algorithms to run |
201 pub algorithms : Vec<Named<AlgorithmConfig<F>>>, |
201 pub algorithms : Vec<Named<AlgorithmConfig<F>>>, |
202 /// Options for algorithm step iteration (verbosity, etc.) |
202 /// Options for algorithm step iteration (verbosity, etc.) |
203 pub iterator_options : AlgIteratorOptions, |
203 pub iterator_options : AlgIteratorOptions, |
204 /// Plotting level |
204 /// Plotting level |
284 |
284 |
285 |
285 |
286 /// Struct for experiment configurations |
286 /// Struct for experiment configurations |
287 #[derive(Debug, Clone, Serialize)] |
287 #[derive(Debug, Clone, Serialize)] |
288 pub struct Experiment<F, NoiseDistr, S, K, P, const N : usize> |
288 pub struct Experiment<F, NoiseDistr, S, K, P, const N : usize> |
289 where F : Float, |
289 where F : ClapFloat, |
290 [usize; N] : Serialize, |
290 [usize; N] : Serialize, |
291 NoiseDistr : Distribution<F>, |
291 NoiseDistr : Distribution<F>, |
292 S : Sensor<F, N>, |
292 S : Sensor<F, N>, |
293 P : Spread<F, N>, |
293 P : Spread<F, N>, |
294 K : SimpleConvolutionKernel<F, N>, |
294 K : SimpleConvolutionKernel<F, N>, |
546 opA : &A, |
546 opA : &A, |
547 b_hat : &A::Observable, |
547 b_hat : &A::Observable, |
548 b : &A::Observable, |
548 b : &A::Observable, |
549 kernel_plot_width : F, |
549 kernel_plot_width : F, |
550 ) -> DynError |
550 ) -> DynError |
551 where F : Float + ToNalgebraRealField, |
551 where F : ClapFloat + ToNalgebraRealField, |
552 Sensor : RealMapping<F, N> + Support<F, N> + Clone, |
552 Sensor : RealMapping<F, N> + Support<F, N> + Clone, |
553 Spread : RealMapping<F, N> + Support<F, N> + Clone, |
553 Spread : RealMapping<F, N> + Support<F, N> + Clone, |
554 Kernel : RealMapping<F, N> + Support<F, N>, |
554 Kernel : RealMapping<F, N> + Support<F, N>, |
555 Convolution<Sensor, Spread> : RealMapping<F, N> + Support<F, N>, |
555 Convolution<Sensor, Spread> : RealMapping<F, N> + Support<F, N>, |
556 𝒟 : DiscreteMeasureOp<Loc<F, N>, F>, |
556 𝒟 : DiscreteMeasureOp<Loc<F, N>, F>, |