Wed, 07 Oct 2026 08:01:12 -0500
Bump version
| 0 | 1 | /*! |
| 2 | This module provides [`RunnableExperiment`] for running chosen algorithms on a chosen experiment. | |
| 3 | */ | |
| 4 | ||
| 89 | 5 | use crate::domain::{AdmissibleDomain, FullSpace}; |
| 6 | use crate::fb::{pointsource_fb_dom, pointsource_fista_reg, FBConfig, InsertionConfig}; | |
| 35 | 7 | use crate::forward_model::sensor_grid::{ |
| 8 | //SensorGridBTFN, | |
| 9 | Sensor, | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
10 | SensorGrid, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
11 | SensorGridBT, |
| 35 | 12 | Spread, |
| 13 | }; | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
14 | use crate::forward_model::*; |
| 89 | 15 | use crate::forward_pdps::{ |
| 16 | pointsource_fb_pair_dom, pointsource_forward_pdps_pair_dom, ForwardPDPSConfig, | |
| 17 | }; | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
18 | use crate::frank_wolfe::{pointsource_fw_reg, FWConfig, FWVariant, RegTermFW}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
19 | use crate::kernels::*; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
20 | use crate::measures::merging::{SpikeMerging, SpikeMergingMethod}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
21 | use crate::measures::*; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
22 | use crate::pdps::{pointsource_pdps_reg, PDPSConfig}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
23 | use crate::plot::*; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
24 | use crate::prox_penalty::{ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
25 | ProxPenalty, ProxTerm, RadonSquared, StepLengthBound, StepLengthBoundPD, StepLengthBoundPair, |
| 32 | 26 | }; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
27 | use crate::regularisation::{NonnegRadonRegTerm, RadonRegTerm, Regularisation, SlidingRegTerm}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
28 | use crate::seminorms::*; |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
29 | use crate::sliding_fb::{ |
| 89 | 30 | pointsource_sliding_fb, SlidingFBConfig, TransportConfig, TransportProxPenalty, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
31 | }; |
| 35 | 32 | use crate::sliding_pdps::{ |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
33 | pointsource_sliding_fb_pair_dom, pointsource_sliding_pdps_pair_dom, SlidingPDPSConfig, |
| 35 | 34 | }; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
35 | use crate::subproblem::{InnerMethod, InnerSettings}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
36 | use crate::tolerance::Tolerance; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
37 | use crate::types::*; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
38 | use crate::{AlgorithmOverrides, CommandLineArgs}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
39 | use alg_tools::bisection_tree::*; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
40 | use alg_tools::bounds::{Bounded, MinMaxMapping}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
41 | use alg_tools::convex::{Conjugable, Norm222, Prox, Zero}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
42 | use alg_tools::direct_product::Pair; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
43 | use alg_tools::discrete_gradient::{ForwardNeumann, Grad}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
44 | use alg_tools::error::{DynError, DynResult}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
45 | use alg_tools::euclidean::{ClosedEuclidean, Euclidean}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
46 | use alg_tools::iterate::{ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
47 | AlgIteratorFactory, AlgIteratorOptions, BasicAlgIteratorFactory, LoggingIteratorFactory, Timed, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
48 | TimingIteratorFactory, ValueIteratorFactory, Verbose, |
| 0 | 49 | }; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
50 | use alg_tools::lingrid::lingrid; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
51 | use alg_tools::linops::{IdOp, RowOp, AXPY}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
52 | use alg_tools::logger::Logger; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
53 | use alg_tools::mapping::{ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
54 | DataTerm, DifferentiableMapping, DifferentiableRealMapping, Instance, RealMapping, |
| 32 | 55 | }; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
56 | use alg_tools::maputil::map3; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
57 | use alg_tools::nalgebra_support::ToNalgebraRealField; |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
58 | use alg_tools::norms::{Dist, Norm, NormExponent, L1, L2}; |
| 35 | 59 | use alg_tools::operator_arithmetic::Weighted; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
60 | use alg_tools::sets::Cube; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
61 | use alg_tools::sets::SetOrd; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
62 | use alg_tools::tabledump::TableDump; |
| 35 | 63 | use anyhow::anyhow; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
64 | use chrono::{DateTime, Utc}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
65 | use clap::ValueEnum; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
66 | use colored::Colorize; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
67 | use cpu_time::ProcessTime; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
68 | use nalgebra::base::DVector; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
69 | use numeric_literals::replace_float_literals; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
70 | use rand::prelude::{SeedableRng, StdRng}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
71 | use rand_distr::Distribution; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
72 | use serde::{Deserialize, Serialize}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
73 | use serde_json; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
74 | use std::collections::HashMap; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
75 | use std::hash::Hash; |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
76 | //use std::ops::Mul; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
77 | use std::time::Instant; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
78 | use thiserror::Error; |
| 0 | 79 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
80 | //#[cfg(feature = "pyo3")] |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
81 | //use pyo3::pyclass; |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
82 | |
| 0 | 83 | /// Available algorithms and their configurations |
| 84 | #[derive(Copy, Clone, Debug, Serialize, Deserialize)] | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
85 | pub enum AlgorithmConfig<F: Float> { |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
86 | FB(FBConfig<F>, ProxTerm), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
87 | FISTA(FBConfig<F>, ProxTerm), |
| 0 | 88 | FW(FWConfig<F>), |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
89 | PDPS(PDPSConfig<F>, ProxTerm), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
90 | SlidingFB(SlidingFBConfig<F>, ProxTerm), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
91 | ForwardPDPS(ForwardPDPSConfig<F>, ProxTerm), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
92 | SlidingPDPS(SlidingPDPSConfig<F>, ProxTerm), |
| 0 | 93 | } |
| 94 | ||
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
95 | fn unpack_tolerance<F: Float>(v: &Vec<F>) -> Tolerance<F> { |
|
20
90f77ad9a98d
Added command line option for (power) tolerance
Tuomo Valkonen <tuomov@iki.fi>
parents:
9
diff
changeset
|
96 | assert!(v.len() == 3); |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
97 | Tolerance::Power { initial: v[0], factor: v[1], exponent: v[2] } |
|
20
90f77ad9a98d
Added command line option for (power) tolerance
Tuomo Valkonen <tuomov@iki.fi>
parents:
9
diff
changeset
|
98 | } |
|
90f77ad9a98d
Added command line option for (power) tolerance
Tuomo Valkonen <tuomov@iki.fi>
parents:
9
diff
changeset
|
99 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
100 | impl<F: ClapFloat> AlgorithmConfig<F> { |
| 0 | 101 | /// Override supported parameters based on the command line. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
102 | pub fn cli_override(self, cli: &AlgorithmOverrides<F>) -> Self { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
103 | let override_merging = |g: SpikeMergingMethod<F>| SpikeMergingMethod { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
104 | enabled: cli.merge.unwrap_or(g.enabled), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
105 | radius: cli.merge_radius.unwrap_or(g.radius), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
106 | interp: cli.merge_interp.unwrap_or(g.interp), |
| 73 | 107 | scaling: cli.scaling_heuristic.or(g.scaling), |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
108 | }; |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
109 | let override_inner = |g: InnerSettings<F>| InnerSettings { |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
110 | method: cli.inner_method.unwrap_or(g.method), |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
111 | fb_τ0: cli.inner_τ0.unwrap_or(g.fb_τ0), |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
112 | pdps_τσ0: cli |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
113 | .inner_pdps_τσ0 |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
114 | .as_ref() |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
115 | .map_or(g.pdps_τσ0, |τσ0| (τσ0[0], τσ0[1])), |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
116 | pp_τ: cli.inner_pp_τ.as_ref().map_or(g.pp_τ, |τ| (τ[0], τ[1])), |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
117 | tolerance_mult: cli.inner_tol.unwrap_or(g.tolerance_mult), |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
118 | ..g |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
119 | }; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
120 | let override_fb_generic = |g: InsertionConfig<F>| InsertionConfig { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
121 | bootstrap_insertions: cli |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
122 | .bootstrap_insertions |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
123 | .as_ref() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
124 | .map_or(g.bootstrap_insertions, |n| Some((n[0], n[1]))), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
125 | merge_every: cli.merge_every.unwrap_or(g.merge_every), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
126 | merging: override_merging(g.merging), |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
77
diff
changeset
|
127 | max_scaling_iter: cli.max_scaling_iter.unwrap_or(g.max_scaling_iter), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
128 | final_merging: cli.final_merging.unwrap_or(g.final_merging), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
129 | fitness_merging: cli.fitness_merging.unwrap_or(g.fitness_merging), |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
130 | inner: override_inner(g.inner), |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
73
diff
changeset
|
131 | extra_weight_optimisation_steps: cli |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
73
diff
changeset
|
132 | .extra_weight_optimisation_steps |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
73
diff
changeset
|
133 | .unwrap_or(g.extra_weight_optimisation_steps), |
| 89 | 134 | random_insertions: cli.random_insertions.unwrap_or(g.random_insertions), |
|
90
b471a13e3136
Added greedy insertion option, but does and actually really should not too much
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
135 | greedy: cli.greedy.unwrap_or(g.greedy), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
136 | tolerance: cli |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
137 | .tolerance |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
138 | .as_ref() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
139 | .map(unpack_tolerance) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
140 | .unwrap_or(g.tolerance), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
141 | ..g |
| 0 | 142 | }; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
143 | let override_transport = |g: TransportConfig<F>| TransportConfig { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
144 | θ0: cli.theta0.unwrap_or(g.θ0), |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
145 | τθ: cli.tautheta.or(g.τθ), |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
146 | tolerance_mult: cli.transport_tolerance.unwrap_or(g.tolerance_mult), |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
147 | ℓ_gradv_mult: cli.gradv_lipest_mult.unwrap_or(g.ℓ_gradv_mult), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
148 | adaptation: cli.transport_adaptation.unwrap_or(g.adaptation), |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
149 | allow_partial_transport: cli |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
150 | .allow_partial_transport |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
151 | .unwrap_or(g.allow_partial_transport), |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
152 | alt_remainder_control: cli.alt_remainder_control.unwrap_or(g.alt_remainder_control), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
153 | ..g |
| 35 | 154 | }; |
| 0 | 155 | |
| 156 | use AlgorithmConfig::*; | |
| 157 | match self { | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
158 | FB(fb, prox) => FB( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
159 | FBConfig { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
160 | τ0: cli.tau0.unwrap_or(fb.τ0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
161 | σp0: cli.sigmap0.unwrap_or(fb.σp0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
162 | insertion: override_fb_generic(fb.insertion), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
163 | ..fb |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
164 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
165 | prox, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
166 | ), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
167 | FISTA(fb, prox) => FISTA( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
168 | FBConfig { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
169 | τ0: cli.tau0.unwrap_or(fb.τ0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
170 | σp0: cli.sigmap0.unwrap_or(fb.σp0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
171 | insertion: override_fb_generic(fb.insertion), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
172 | ..fb |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
173 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
174 | prox, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
175 | ), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
176 | PDPS(pdps, prox) => PDPS( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
177 | PDPSConfig { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
178 | τ0: cli.tau0.unwrap_or(pdps.τ0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
179 | σ0: cli.sigma0.unwrap_or(pdps.σ0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
180 | acceleration: cli.acceleration.unwrap_or(pdps.acceleration), |
|
77
be105c046777
PDPSConfig.generic -> insertion in consistency with others
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
181 | insertion: override_fb_generic(pdps.insertion), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
182 | ..pdps |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
183 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
184 | prox, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
185 | ), |
| 0 | 186 | FW(fw) => FW(FWConfig { |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
187 | merging: override_merging(fw.merging), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
188 | tolerance: cli |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
189 | .tolerance |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
190 | .as_ref() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
191 | .map(unpack_tolerance) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
192 | .unwrap_or(fw.tolerance), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
193 | ..fw |
| 32 | 194 | }), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
195 | SlidingFB(sfb, prox) => SlidingFB( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
196 | SlidingFBConfig { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
197 | τ0: cli.tau0.unwrap_or(sfb.τ0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
198 | σp0: cli.sigmap0.unwrap_or(sfb.σp0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
199 | transport: override_transport(sfb.transport), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
200 | insertion: override_fb_generic(sfb.insertion), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
201 | ..sfb |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
202 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
203 | prox, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
204 | ), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
205 | SlidingPDPS(spdps, prox) => SlidingPDPS( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
206 | SlidingPDPSConfig { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
207 | τ0: cli.tau0.unwrap_or(spdps.τ0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
208 | σp0: cli.sigmap0.unwrap_or(spdps.σp0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
209 | σd0: cli.sigma0.unwrap_or(spdps.σd0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
210 | //acceleration : cli.acceleration.unwrap_or(pdps.acceleration), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
211 | transport: override_transport(spdps.transport), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
212 | insertion: override_fb_generic(spdps.insertion), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
213 | ..spdps |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
214 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
215 | prox, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
216 | ), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
217 | ForwardPDPS(fpdps, prox) => ForwardPDPS( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
218 | ForwardPDPSConfig { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
219 | τ0: cli.tau0.unwrap_or(fpdps.τ0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
220 | σp0: cli.sigmap0.unwrap_or(fpdps.σp0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
221 | σd0: cli.sigma0.unwrap_or(fpdps.σd0), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
222 | //acceleration : cli.acceleration.unwrap_or(pdps.acceleration), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
223 | insertion: override_fb_generic(fpdps.insertion), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
224 | ..fpdps |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
225 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
226 | prox, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
227 | ), |
| 0 | 228 | } |
| 229 | } | |
| 230 | } | |
| 231 | ||
| 35 | 232 | /// Helper struct for tagging and [`AlgorithmConfig`] or [`ExperimentV2`] with a name. |
| 0 | 233 | #[derive(Clone, Debug, Serialize, Deserialize)] |
| 234 | pub struct Named<Data> { | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
235 | pub name: String, |
| 0 | 236 | #[serde(flatten)] |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
237 | pub data: Data, |
| 0 | 238 | } |
| 239 | ||
| 240 | /// Shorthand algorithm configurations, to be used with the command line parser | |
|
9
21b0e537ac0e
Command line parameter passing simplifications and make `-o` required.
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
241 | #[derive(ValueEnum, Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
242 | //#[cfg_attr(feature = "pyo3", pyclass(module = "pointsource_algs"))] |
| 0 | 243 | pub enum DefaultAlgorithm { |
| 244 | /// The μFB forward-backward method | |
| 245 | #[clap(name = "fb")] | |
| 246 | FB, | |
| 247 | /// The μFISTA inertial forward-backward method | |
| 248 | #[clap(name = "fista")] | |
| 249 | FISTA, | |
| 250 | /// The “fully corrective” conditional gradient method | |
| 251 | #[clap(name = "fw")] | |
| 252 | FW, | |
| 253 | /// The “relaxed conditional gradient method | |
| 254 | #[clap(name = "fwrelax")] | |
| 255 | FWRelax, | |
| 256 | /// The μPDPS primal-dual proximal splitting method | |
| 257 | #[clap(name = "pdps")] | |
| 258 | PDPS, | |
| 35 | 259 | /// The sliding FB method |
| 32 | 260 | #[clap(name = "sliding_fb", alias = "sfb")] |
| 261 | SlidingFB, | |
| 35 | 262 | /// The sliding PDPS method |
| 263 | #[clap(name = "sliding_pdps", alias = "spdps")] | |
| 264 | SlidingPDPS, | |
| 265 | /// The PDPS method with a forward step for the smooth function | |
| 266 | #[clap(name = "forward_pdps", alias = "fpdps")] | |
| 267 | ForwardPDPS, | |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
268 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
269 | // Radon variants |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
270 | /// The μFB forward-backward method with radon-norm squared proximal term |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
271 | #[clap(name = "radon_fb")] |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
272 | RadonFB, |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
273 | /// The μFISTA inertial forward-backward method with radon-norm squared proximal term |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
274 | #[clap(name = "radon_fista")] |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
275 | RadonFISTA, |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
276 | /// The μPDPS primal-dual proximal splitting method with radon-norm squared proximal term |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
277 | #[clap(name = "radon_pdps")] |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
278 | RadonPDPS, |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
279 | /// The sliding FB method with radon-norm squared proximal term |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
280 | #[clap(name = "radon_sliding_fb", alias = "radon_sfb")] |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
281 | RadonSlidingFB, |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
282 | /// The sliding PDPS method with radon-norm squared proximal term |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
283 | #[clap(name = "radon_sliding_pdps", alias = "radon_spdps")] |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
284 | RadonSlidingPDPS, |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
285 | /// The PDPS method with a forward step for the smooth function with radon-norm squared proximal term |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
286 | #[clap(name = "radon_forward_pdps", alias = "radon_fpdps")] |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
287 | RadonForwardPDPS, |
| 0 | 288 | } |
| 289 | ||
| 290 | impl DefaultAlgorithm { | |
| 291 | /// Returns the algorithm configuration corresponding to the algorithm shorthand | |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
292 | pub fn default_config<F: Float>( |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
293 | &self, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
294 | regularisation_hint: Option<&Regularisation<F>>, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
295 | ) -> AlgorithmConfig<F> { |
| 0 | 296 | use DefaultAlgorithm::*; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
297 | let radon_insertion = InsertionConfig { |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
298 | merging: SpikeMergingMethod { enabled: true, interp: false, ..Default::default() }, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
299 | fitness_merging: true, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
300 | inner: InnerSettings { |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
301 | method: if let Some(Regularisation::NonnegRadon(_)) = regularisation_hint { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
302 | InnerMethod::Exact |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
303 | } else { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
304 | InnerMethod::PDPS // SSN not implemented |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
305 | }, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
306 | ..Default::default() |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
307 | }, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
308 | ..Default::default() |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
309 | }; |
| 0 | 310 | match *self { |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
311 | FB => AlgorithmConfig::FB(Default::default(), ProxTerm::Wave), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
312 | FISTA => AlgorithmConfig::FISTA(Default::default(), ProxTerm::Wave), |
| 0 | 313 | FW => AlgorithmConfig::FW(Default::default()), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
314 | FWRelax => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
315 | AlgorithmConfig::FW(FWConfig { variant: FWVariant::Relaxed, ..Default::default() }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
316 | } |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
317 | PDPS => AlgorithmConfig::PDPS(Default::default(), ProxTerm::Wave), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
318 | SlidingFB => AlgorithmConfig::SlidingFB(Default::default(), ProxTerm::Wave), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
319 | SlidingPDPS => AlgorithmConfig::SlidingPDPS(Default::default(), ProxTerm::Wave), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
320 | ForwardPDPS => AlgorithmConfig::ForwardPDPS(Default::default(), ProxTerm::Wave), |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
321 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
322 | // Radon variants |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
323 | RadonFB => AlgorithmConfig::FB( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
324 | FBConfig { insertion: radon_insertion, ..Default::default() }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
325 | ProxTerm::RadonSquared, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
326 | ), |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
327 | RadonFISTA => AlgorithmConfig::FISTA( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
328 | FBConfig { insertion: radon_insertion, ..Default::default() }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
329 | ProxTerm::RadonSquared, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
330 | ), |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
331 | RadonPDPS => AlgorithmConfig::PDPS( |
|
77
be105c046777
PDPSConfig.generic -> insertion in consistency with others
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
332 | PDPSConfig { insertion: radon_insertion, ..Default::default() }, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
333 | ProxTerm::RadonSquared, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
334 | ), |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
335 | RadonSlidingFB => AlgorithmConfig::SlidingFB( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
336 | SlidingFBConfig { insertion: radon_insertion, ..Default::default() }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
337 | ProxTerm::RadonSquared, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
338 | ), |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
339 | RadonSlidingPDPS => AlgorithmConfig::SlidingPDPS( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
340 | SlidingPDPSConfig { insertion: radon_insertion, ..Default::default() }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
341 | ProxTerm::RadonSquared, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
342 | ), |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
343 | RadonForwardPDPS => AlgorithmConfig::ForwardPDPS( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
344 | ForwardPDPSConfig { insertion: radon_insertion, ..Default::default() }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
345 | ProxTerm::RadonSquared, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
346 | ), |
| 0 | 347 | } |
| 348 | } | |
| 349 | ||
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
350 | pub fn to_named<F: Float>(self, alg: AlgorithmConfig<F>) -> Named<AlgorithmConfig<F>> { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
351 | Named { name: self.name(), data: alg } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
352 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
353 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
354 | pub fn name(self) -> String { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
355 | self.to_possible_value().unwrap().get_name().to_string() |
| 0 | 356 | } |
| 357 | } | |
| 358 | ||
| 359 | // // Floats cannot be hashed directly, so just hash the debug formatting | |
| 360 | // // for use as file identifier. | |
| 361 | // impl<F : Float> Hash for AlgorithmConfig<F> { | |
| 362 | // fn hash<H: Hasher>(&self, state: &mut H) { | |
| 363 | // format!("{:?}", self).hash(state); | |
| 364 | // } | |
| 365 | // } | |
| 366 | ||
| 367 | /// Plotting level configuration | |
| 368 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, ValueEnum, Debug)] | |
| 369 | pub enum PlotLevel { | |
| 370 | /// Plot nothing | |
| 371 | #[clap(name = "none")] | |
| 372 | None, | |
| 373 | /// Plot problem data | |
| 374 | #[clap(name = "data")] | |
| 375 | Data, | |
| 376 | /// Plot iterationwise state | |
| 377 | #[clap(name = "iter")] | |
| 378 | Iter, | |
| 379 | } | |
| 380 | ||
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
381 | impl Default for PlotLevel { |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
382 | fn default() -> Self { |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
383 | Self::Data |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
384 | } |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
385 | } |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
386 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
387 | type DefaultBT<F, const N: usize> = BT<DynamicDepth, F, usize, Bounds<F>, N>; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
388 | type DefaultSeminormOp<F, K, const N: usize> = ConvolutionOp<F, K, DefaultBT<F, N>, N>; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
389 | type DefaultSG<F, Sensor, Spread, const N: usize> = |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
390 | SensorGrid<F, Sensor, Spread, DefaultBT<F, N>, N>; |
| 0 | 391 | |
| 392 | /// This is a dirty workaround to rust-csv not supporting struct flattening etc. | |
| 393 | #[derive(Serialize)] | |
| 394 | struct CSVLog<F> { | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
395 | iter: usize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
396 | cpu_time: f64, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
397 | value: F, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
398 | relative_value: F, |
| 35 | 399 | //post_value : F, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
400 | n_spikes: usize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
401 | inner_iters: usize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
402 | merged: usize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
403 | pruned: usize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
404 | this_iters: usize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
405 | epsilon: F, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
406 | discrepancy: F, |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
407 | aux_discrepancy: F, |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
408 | joint_discrepancy: F, |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
409 | radon_norm: F, |
| 0 | 410 | } |
| 411 | ||
| 412 | /// Collected experiment statistics | |
| 413 | #[derive(Clone, Debug, Serialize)] | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
414 | struct ExperimentStats<F: Float> { |
| 0 | 415 | /// Signal-to-noise ratio in decibels |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
416 | ssnr: F, |
| 0 | 417 | /// Proportion of noise in the signal as a number in $[0, 1]$. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
418 | noise_ratio: F, |
| 0 | 419 | /// When the experiment was run (UTC) |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
420 | when: DateTime<Utc>, |
| 0 | 421 | } |
| 422 | ||
| 423 | #[replace_float_literals(F::cast_from(literal))] | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
424 | impl<F: Float> ExperimentStats<F> { |
| 0 | 425 | /// Calculate [`ExperimentStats`] based on a noisy `signal` and the separated `noise` signal. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
426 | fn new<E: Euclidean<F>>(signal: &E, noise: &E) -> Self { |
| 0 | 427 | let s = signal.norm2_squared(); |
| 428 | let n = noise.norm2_squared(); | |
| 429 | let noise_ratio = (n / s).sqrt(); | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
430 | let ssnr = 10.0 * (s / n).log10(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
431 | ExperimentStats { ssnr, noise_ratio, when: Utc::now() } |
| 0 | 432 | } |
| 433 | } | |
| 434 | /// Collected algorithm statistics | |
| 435 | #[derive(Clone, Debug, Serialize)] | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
436 | struct AlgorithmStats<F: Float> { |
| 0 | 437 | /// Overall CPU time spent |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
438 | cpu_time: F, |
| 0 | 439 | /// Real time spent |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
440 | elapsed: F, |
| 0 | 441 | } |
| 442 | ||
| 443 | /// A wrapper for [`serde_json::to_writer_pretty`] that takes a filename as input | |
| 444 | /// and outputs a [`DynError`]. | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
445 | fn write_json<T: Serialize>(filename: String, data: &T) -> DynError { |
| 0 | 446 | serde_json::to_writer_pretty(std::fs::File::create(filename)?, data)?; |
| 447 | Ok(()) | |
| 448 | } | |
| 449 | ||
| 450 | /// Struct for experiment configurations | |
| 451 | #[derive(Debug, Clone, Serialize)] | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
452 | pub struct ExperimentV2<F, NoiseDistr, S, K, P, const N: usize> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
453 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
454 | F: Float + ClapFloat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
455 | [usize; N]: Serialize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
456 | NoiseDistr: Distribution<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
457 | S: Sensor<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
458 | P: Spread<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
459 | K: SimpleConvolutionKernel<N, F>, |
| 0 | 460 | { |
| 461 | /// Domain $Ω$. | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
462 | pub domain: Cube<N, F>, |
| 0 | 463 | /// Number of sensors along each dimension |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
464 | pub sensor_count: [usize; N], |
| 0 | 465 | /// Noise distribution |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
466 | pub noise_distr: NoiseDistr, |
| 0 | 467 | /// Seed for random noise generation (for repeatable experiments) |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
468 | pub noise_seed: u64, |
| 0 | 469 | /// Sensor $θ$; $θ * ψ$ forms the forward operator $𝒜$. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
470 | pub sensor: S, |
| 0 | 471 | /// Spread $ψ$; $θ * ψ$ forms the forward operator $𝒜$. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
472 | pub spread: P, |
| 0 | 473 | /// Kernel $ρ$ of $𝒟$. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
474 | pub kernel: K, |
| 0 | 475 | /// True point sources |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
476 | pub μ_hat: RNDM<N, F>, |
|
24
d29d1fcf5423
Support arbitrary regularisation terms; implement non-positivity-constrained regularisation.
Tuomo Valkonen <tuomov@iki.fi>
parents:
23
diff
changeset
|
477 | /// Regularisation term and parameter |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
478 | pub regularisation: Regularisation<F>, |
| 0 | 479 | /// For plotting : how wide should the kernels be plotted |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
480 | pub kernel_plot_width: F, |
| 0 | 481 | /// Data term |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
482 | pub dataterm: DataTermType, |
| 0 | 483 | /// A map of default configurations for algorithms |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
484 | pub algorithm_overrides: HashMap<DefaultAlgorithm, AlgorithmOverrides<F>>, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
485 | /// Default merge radius |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
486 | pub default_merge_radius: F, |
| 0 | 487 | } |
| 488 | ||
| 35 | 489 | #[derive(Debug, Clone, Serialize)] |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
490 | pub struct ExperimentBiased<F, NoiseDistr, S, K, P, B, const N: usize> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
491 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
492 | F: Float + ClapFloat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
493 | [usize; N]: Serialize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
494 | NoiseDistr: Distribution<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
495 | S: Sensor<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
496 | P: Spread<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
497 | K: SimpleConvolutionKernel<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
498 | B: Mapping<Loc<N, F>, Codomain = F> + Serialize + std::fmt::Debug, |
| 35 | 499 | { |
| 500 | /// Basic setup | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
501 | pub base: ExperimentV2<F, NoiseDistr, S, K, P, N>, |
| 35 | 502 | /// Weight of TV term |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
503 | pub λ: F, |
| 35 | 504 | /// Bias function |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
505 | pub bias: B, |
| 35 | 506 | } |
| 507 | ||
| 0 | 508 | /// Trait for runnable experiments |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
509 | pub trait RunnableExperiment<F: ClapFloat> { |
|
9
21b0e537ac0e
Command line parameter passing simplifications and make `-o` required.
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
510 | /// Run all algorithms provided, or default algorithms if none provided, on the experiment. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
511 | fn runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
512 | &self, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
513 | cli: &CommandLineArgs, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
514 | cli_algorithm_overrides: &AlgorithmOverrides<F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
515 | ) -> DynError; |
| 0 | 516 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
517 | /// Experiment name |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
518 | fn name(&self) -> &str; |
| 35 | 519 | } |
| 520 | ||
| 521 | /// Error codes for running an algorithm on an experiment. | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
522 | #[derive(Error, Debug)] |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
523 | pub enum RunError { |
| 35 | 524 | /// Algorithm not implemented for this experiment |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
525 | #[error("Algorithm not implemented for this experiment")] |
| 35 | 526 | NotImplemented, |
| 0 | 527 | } |
| 528 | ||
| 35 | 529 | use RunError::*; |
| 530 | ||
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
531 | type DoRunAllIt<'a, F, const N: usize> = LoggingIteratorFactory< |
| 35 | 532 | 'a, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
533 | Timed<IterInfo<F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
534 | TimingIteratorFactory<BasicAlgIteratorFactory<IterInfo<F>>>, |
| 35 | 535 | >; |
| 536 | ||
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
537 | /// Trait for things used by many a [`RunnableExperiment`], but that are not dyn-compatible. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
538 | pub trait RunnableExperimentExtras<F: ClapFloat>: |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
539 | RunnableExperiment<F> + Serialize + Sized |
| 35 | 540 | { |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
541 | /// Helper function to print experiment start message and save setup. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
542 | /// Returns saving prefix. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
543 | fn start(&self, cli: &CommandLineArgs) -> DynResult<String> { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
544 | let experiment_name = self.name(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
545 | let ser = serde_json::to_string(self); |
| 35 | 546 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
547 | println!( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
548 | "{}\n{}", |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
549 | format!("Performing experiment {}…", experiment_name).cyan(), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
550 | format!( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
551 | "Experiment settings: {}", |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
552 | if let Ok(ref s) = ser { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
553 | s |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
554 | } else { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
555 | "<serialisation failure>" |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
556 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
557 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
558 | .bright_black(), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
559 | ); |
| 35 | 560 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
561 | // Set up output directory |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
562 | let prefix = format!("{}/{}/", cli.outdir, experiment_name); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
563 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
564 | // Save experiment configuration and statistics |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
565 | std::fs::create_dir_all(&prefix)?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
566 | write_json(format!("{prefix}experiment.json"), self)?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
567 | write_json(format!("{prefix}config.json"), cli)?; |
| 35 | 568 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
569 | Ok(prefix) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
570 | } |
| 35 | 571 | |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
572 | /// Collect algorithms to run based on command line args. |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
573 | fn collect_algs( |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
574 | &self, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
575 | cli: &CommandLineArgs, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
576 | algorithm_overrides: &AlgorithmOverrides<F>, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
577 | algorithm_overrides_fn: impl Fn(DefaultAlgorithm) -> Option<AlgorithmOverrides<F>>, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
578 | regularisation_hint: Option<&Regularisation<F>>, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
579 | dflt: &[DefaultAlgorithm], |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
580 | ) -> DynResult<Vec<Named<AlgorithmConfig<F>>>> |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
581 | where |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
582 | F: for<'a> Deserialize<'a>, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
583 | { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
584 | let proc_alg = |alg: &DefaultAlgorithm| { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
585 | let default_cfg = alg.default_config(regularisation_hint); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
586 | let cfg = if let Some(over) = &algorithm_overrides_fn(*alg) { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
587 | default_cfg.cli_override(over) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
588 | } else { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
589 | default_cfg |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
590 | } |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
591 | .cli_override(algorithm_overrides); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
592 | alg.to_named(cfg) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
593 | }; |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
594 | |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
595 | let mut algs: Vec<Named<AlgorithmConfig<F>>> = cli.algorithm.iter().map(proc_alg).collect(); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
596 | for filename in cli.saved_algorithm.iter() { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
597 | let f = std::fs::File::open(filename)?; |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
598 | let alg = serde_json::from_reader(f)?; |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
599 | algs.push(alg); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
600 | } |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
601 | if algs.is_empty() { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
602 | Ok(dflt.iter().map(proc_alg).collect()) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
603 | } else { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
604 | Ok(algs) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
605 | } |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
606 | } |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
607 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
608 | /// Helper function to run all algorithms on an experiment. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
609 | fn do_runall<P, Z, Plot, const N: usize>( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
610 | &self, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
611 | prefix: &String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
612 | cli: &CommandLineArgs, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
613 | algorithms: Vec<Named<AlgorithmConfig<F>>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
614 | mut make_plotter: impl FnMut(String) -> Plot, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
615 | mut save_extra: impl FnMut(String, Z) -> DynError, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
616 | init: P, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
617 | mut do_alg: impl FnMut( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
618 | (&AlgorithmConfig<F>, DoRunAllIt<F, N>, Plot, P, String), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
619 | ) -> DynResult<(RNDM<N, F>, Z)>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
620 | ) -> DynError |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
621 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
622 | F: for<'b> Deserialize<'b>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
623 | PlotLookup: Plotting<N>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
624 | P: Clone, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
625 | { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
626 | let experiment_name = self.name(); |
| 35 | 627 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
628 | let mut logs = Vec::new(); |
| 35 | 629 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
630 | let iterator_options = AlgIteratorOptions { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
631 | max_iter: cli.max_iter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
632 | verbose_iter: cli |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
633 | .verbose_iter |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
634 | .map_or(Verbose::LogarithmicCap { base: 10, cap: 2 }, |n| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
635 | Verbose::Every(n) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
636 | }), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
637 | quiet: cli.quiet, |
| 35 | 638 | }; |
| 639 | ||
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
640 | // Run the algorithm(s) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
641 | for named @ Named { name: alg_name, data: alg } in algorithms.iter() { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
642 | let this_prefix = format!("{}{}/", prefix, alg_name); |
| 35 | 643 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
644 | // Create Logger and IteratorFactory |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
645 | let mut logger = Logger::new(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
646 | let iterator = iterator_options.instantiate().timed().into_log(&mut logger); |
| 35 | 647 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
648 | let running = if !cli.quiet { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
649 | format!( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
650 | "{}\n{}\n{}\n", |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
651 | format!("Running {} on experiment {}…", alg_name, experiment_name).cyan(), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
652 | format!( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
653 | "Iteration settings: {}", |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
654 | serde_json::to_string(&iterator_options)? |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
655 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
656 | .bright_black(), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
657 | format!("Algorithm settings: {}", serde_json::to_string(&alg)?).bright_black() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
658 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
659 | } else { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
660 | "".to_string() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
661 | }; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
662 | // |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
663 | // The following is for postprocessing, which has been disabled anyway. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
664 | // |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
665 | // let reg : Box<dyn WeightOptim<_, _, _, N>> = match regularisation { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
666 | // Regularisation::Radon(α) => Box::new(RadonRegTerm(α)), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
667 | // Regularisation::NonnegRadon(α) => Box::new(NonnegRadonRegTerm(α)), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
668 | // }; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
669 | //let findim_data = reg.prepare_optimise_weights(&opA, &b); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
670 | //let inner_config : InnerSettings<F> = Default::default(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
671 | //let inner_it = inner_config.iterator_options; |
| 35 | 672 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
673 | // Create plotter and directory if needed. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
674 | let plotter = make_plotter(this_prefix); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
675 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
676 | let start = Instant::now(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
677 | let start_cpu = ProcessTime::now(); |
| 35 | 678 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
679 | let (μ, z) = match do_alg((alg, iterator, plotter, init.clone(), running)) { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
680 | Ok(μ) => μ, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
681 | Err(e) => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
682 | let msg = format!( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
683 | "Skipping algorithm “{alg_name}” for {experiment_name} due to error: {e}" |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
684 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
685 | .red(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
686 | eprintln!("{}", msg); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
687 | continue; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
688 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
689 | }; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
690 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
691 | let elapsed = start.elapsed().as_secs_f64(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
692 | let cpu_time = start_cpu.elapsed().as_secs_f64(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
693 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
694 | println!( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
695 | "{}", |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
696 | format!("Elapsed {elapsed}s (CPU time {cpu_time}s)… ").yellow() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
697 | ); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
698 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
699 | // Save results |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
700 | println!("{}", "Saving results …".green()); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
701 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
702 | let mkname = |t| format!("{prefix}{alg_name}_{t}"); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
703 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
704 | write_json(mkname("config.json"), &named)?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
705 | write_json(mkname("stats.json"), &AlgorithmStats { cpu_time, elapsed })?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
706 | μ.write_csv(mkname("reco.txt"))?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
707 | save_extra(mkname(""), z)?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
708 | //logger.write_csv(mkname("log.txt"))?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
709 | logs.push((mkname("log.txt"), logger)); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
710 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
711 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
712 | save_logs( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
713 | logs, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
714 | format!("{prefix}valuerange.json"), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
715 | cli.load_valuerange, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
716 | ) |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
717 | } |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
718 | } |
| 35 | 719 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
720 | impl<F, E> RunnableExperimentExtras<F> for E |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
721 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
722 | F: ClapFloat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
723 | Self: RunnableExperiment<F> + Serialize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
724 | { |
| 35 | 725 | } |
| 726 | ||
| 727 | #[replace_float_literals(F::cast_from(literal))] | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
728 | impl<F, NoiseDistr, S, K, P, /*PreadjointCodomain, */ const N: usize> RunnableExperiment<F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
729 | for Named<ExperimentV2<F, NoiseDistr, S, K, P, N>> |
| 35 | 730 | where |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
731 | F: ClapFloat |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
732 | + nalgebra::RealField |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
733 | + ToNalgebraRealField<MixedType = F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
734 | + Default |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
735 | + for<'b> Deserialize<'b>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
736 | [usize; N]: Serialize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
737 | S: Sensor<N, F> + Copy + Serialize + std::fmt::Debug, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
738 | P: Spread<N, F> + Copy + Serialize + std::fmt::Debug, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
739 | Convolution<S, P>: Spread<N, F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
740 | + Bounded<F> |
| 35 | 741 | + LocalAnalysis<F, Bounds<F>, N> |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
742 | + Copy |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
743 | // TODO: shold not have differentiability as a requirement, but |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
744 | // decide availability of sliding based on it. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
745 | //+ for<'b> Differentiable<&'b Loc<N, F>, Output = Loc<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
746 | // TODO: very weird that rust only compiles with Differentiable |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
747 | // instead of the above one on references, which is required by |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
748 | // poitsource_sliding_fb_reg. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
749 | + DifferentiableRealMapping<N, F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
750 | + Lipschitz<L2, FloatType = F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
751 | for<'b> <Convolution<S, P> as DifferentiableMapping<Loc<N, F>>>::Differential<'b>: |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
752 | Lipschitz<L2, FloatType = F>, // TODO: should not be required generally, only for sliding_fb. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
753 | AutoConvolution<P>: BoundedBy<F, K>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
754 | K: SimpleConvolutionKernel<N, F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
755 | + LocalAnalysis<F, Bounds<F>, N> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
756 | + Copy |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
757 | + Serialize |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
758 | + std::fmt::Debug, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
759 | Cube<N, F>: P2Minimise<Loc<N, F>, F> + SetOrd, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
760 | PlotLookup: Plotting<N>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
761 | DefaultBT<F, N>: SensorGridBT<F, S, P, N, Depth = DynamicDepth> + BTSearch<N, F>, |
| 35 | 762 | BTNodeLookup: BTNode<F, usize, Bounds<F>, N>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
763 | RNDM<N, F>: SpikeMerging<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
764 | NoiseDistr: Distribution<F> + Serialize + std::fmt::Debug, |
| 35 | 765 | { |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
766 | fn name(&self) -> &str { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
767 | self.name.as_ref() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
768 | } |
| 0 | 769 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
770 | fn runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
771 | &self, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
772 | cli: &CommandLineArgs, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
773 | cli_algorithm_overrides: &AlgorithmOverrides<F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
774 | ) -> DynError { |
|
9
21b0e537ac0e
Command line parameter passing simplifications and make `-o` required.
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
775 | // Get experiment configuration |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
776 | let &ExperimentV2 { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
777 | domain, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
778 | sensor_count, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
779 | ref noise_distr, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
780 | sensor, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
781 | spread, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
782 | kernel, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
783 | ref μ_hat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
784 | regularisation, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
785 | kernel_plot_width, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
786 | dataterm, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
787 | noise_seed, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
788 | .. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
789 | } = &self.data; |
|
9
21b0e537ac0e
Command line parameter passing simplifications and make `-o` required.
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
790 | |
|
21b0e537ac0e
Command line parameter passing simplifications and make `-o` required.
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
791 | // Set up algorithms |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
792 | let algorithms = self.collect_algs( |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
793 | cli, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
794 | cli_algorithm_overrides, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
795 | |alg| { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
796 | Some(AlgorithmOverrides { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
797 | merge_radius: Some(self.data.default_merge_radius), |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
798 | ..self |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
799 | .data |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
800 | .algorithm_overrides |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
801 | .get(&alg) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
802 | .cloned() |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
803 | .unwrap_or_else(Default::default) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
804 | }) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
805 | }, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
806 | Some(®ularisation), |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
807 | match dataterm { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
808 | DataTermType::L222 => &[ |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
809 | DefaultAlgorithm::FB, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
810 | DefaultAlgorithm::RadonFB, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
811 | DefaultAlgorithm::SlidingFB, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
812 | DefaultAlgorithm::RadonSlidingFB, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
813 | DefaultAlgorithm::FW, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
814 | DefaultAlgorithm::PDPS, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
815 | ], |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
816 | DataTermType::L1 => &[DefaultAlgorithm::PDPS], |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
817 | }, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
818 | )?; |
| 0 | 819 | |
| 820 | // Set up operators | |
|
9
21b0e537ac0e
Command line parameter passing simplifications and make `-o` required.
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
821 | let depth = DynamicDepth(8); |
| 0 | 822 | let opA = DefaultSG::new(domain, sensor_count, sensor, spread, depth); |
| 823 | let op𝒟 = DefaultSeminormOp::new(depth, domain, kernel); | |
| 824 | ||
| 825 | // Set up random number generator. | |
| 826 | let mut rng = StdRng::seed_from_u64(noise_seed); | |
| 827 | ||
| 828 | // Generate the data and calculate SSNR statistic | |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
829 | let b_hat = opA.apply(μ_hat); |
| 0 | 830 | let noise = DVector::from_distribution(b_hat.len(), &noise_distr, &mut rng); |
| 831 | let b = &b_hat + &noise; | |
| 832 | // Need to wrap calc_ssnr into a function to hide ultra-lame nalgebra::RealField | |
| 833 | // overloading log10 and conflicting with standard NumTraits one. | |
| 834 | let stats = ExperimentStats::new(&b, &noise); | |
| 835 | ||
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
836 | let prefix = self.start(cli)?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
837 | write_json(format!("{prefix}stats.json"), &stats)?; |
| 0 | 838 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
839 | plotall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
840 | cli, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
841 | &prefix, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
842 | &domain, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
843 | &sensor, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
844 | &kernel, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
845 | &spread, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
846 | &μ_hat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
847 | &op𝒟, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
848 | &opA, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
849 | &b_hat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
850 | &b, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
851 | kernel_plot_width, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
852 | )?; |
| 0 | 853 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
854 | let plotgrid = lingrid(&domain, &[if N == 1 { 1000 } else { 100 }; N]); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
855 | let make_plotter = |this_prefix| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
856 | let plot_count = if cli.plot >= PlotLevel::Iter { 2000 } else { 0 }; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
857 | SeqPlotter::new(this_prefix, plot_count, plotgrid.clone()) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
858 | }; |
| 35 | 859 | |
| 860 | let save_extra = |_, ()| Ok(()); | |
| 0 | 861 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
862 | let μ0 = None; // Zero init |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
863 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
864 | match (dataterm, regularisation) { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
865 | (DataTermType::L1, Regularisation::Radon(α)) => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
866 | let f = DataTerm::new(opA, b, L1.as_mapping()); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
867 | let reg = RadonRegTerm(α); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
868 | self.do_runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
869 | &prefix, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
870 | cli, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
871 | algorithms, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
872 | make_plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
873 | save_extra, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
874 | μ0, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
875 | |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
876 | run_pdps(&f, ®, &RadonSquared, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
877 | run_pdps(&f, ®, &op𝒟, p, |_| Err(NotImplemented.into())) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
878 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
879 | .map(|μ| (μ, ())) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
880 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
881 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
882 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
883 | (DataTermType::L1, Regularisation::NonnegRadon(α)) => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
884 | let f = DataTerm::new(opA, b, L1.as_mapping()); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
885 | let reg = NonnegRadonRegTerm(α); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
886 | self.do_runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
887 | &prefix, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
888 | cli, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
889 | algorithms, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
890 | make_plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
891 | save_extra, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
892 | μ0, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
893 | |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
894 | run_pdps(&f, ®, &RadonSquared, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
895 | run_pdps(&f, ®, &op𝒟, p, |_| Err(NotImplemented.into())) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
896 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
897 | .map(|μ| (μ, ())) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
898 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
899 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
900 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
901 | (DataTermType::L222, Regularisation::Radon(α)) => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
902 | let f = DataTerm::new(opA, b, Norm222::new()); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
903 | let reg = RadonRegTerm(α); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
904 | self.do_runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
905 | &prefix, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
906 | cli, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
907 | algorithms, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
908 | make_plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
909 | save_extra, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
910 | μ0, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
911 | |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
912 | run_fb(&f, ®, &RadonSquared, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
913 | run_pdps(&f, ®, &RadonSquared, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
914 | run_fb(&f, ®, &op𝒟, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
915 | run_pdps(&f, ®, &op𝒟, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
916 | run_fw(&f, ®, p, |_| Err(NotImplemented.into())) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
917 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
918 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
919 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
920 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
921 | .map(|μ| (μ, ())) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
922 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
923 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
924 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
925 | (DataTermType::L222, Regularisation::NonnegRadon(α)) => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
926 | let f = DataTerm::new(opA, b, Norm222::new()); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
927 | let reg = NonnegRadonRegTerm(α); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
928 | self.do_runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
929 | &prefix, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
930 | cli, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
931 | algorithms, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
932 | make_plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
933 | save_extra, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
934 | μ0, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
935 | |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
936 | run_fb(&f, ®, &RadonSquared, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
937 | run_pdps(&f, ®, &RadonSquared, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
938 | run_fb(&f, ®, &op𝒟, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
939 | run_pdps(&f, ®, &op𝒟, p, |p| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
940 | run_fw(&f, ®, p, |_| Err(NotImplemented.into())) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
941 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
942 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
943 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
944 | }) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
945 | .map(|μ| (μ, ())) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
946 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
947 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
948 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
949 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
950 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
951 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
952 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
953 | /// Runs PDPS if `alg` so requests and `prox_penalty` matches. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
954 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
955 | /// Due to the structure of the PDPS, the data term `f` has to have a specific form. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
956 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
957 | /// `cont` gives a continuation attempt to find the algorithm matching the description `alg`. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
958 | pub fn run_pdps<'a, F, A, Phi, Reg, P, I, Plot, const N: usize>( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
959 | f: &'a DataTerm<F, RNDM<N, F>, A, Phi>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
960 | reg: &Reg, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
961 | prox_penalty: &P, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
962 | (alg, iterator, plotter, μ0, running): ( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
963 | &AlgorithmConfig<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
964 | I, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
965 | Plot, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
966 | Option<RNDM<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
967 | String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
968 | ), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
969 | cont: impl FnOnce( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
970 | (&AlgorithmConfig<F>, I, Plot, Option<RNDM<N, F>>, String), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
971 | ) -> DynResult<RNDM<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
972 | ) -> DynResult<RNDM<N, F>> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
973 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
974 | F: Float + ToNalgebraRealField, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
975 | A: ForwardModel<RNDM<N, F>, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
976 | Phi: Conjugable<A::Observable, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
977 | for<'b> Phi::Conjugate<'b>: Prox<A::Observable>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
978 | for<'b> &'b A::Observable: Instance<A::Observable>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
979 | A::Observable: AXPY, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
980 | Reg: SlidingRegTerm<Loc<N, F>, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
981 | P: ProxPenalty<Loc<N, F>, A::PreadjointCodomain, Reg, F> + StepLengthBoundPD<F, A, RNDM<N, F>>, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
982 | RNDM<N, F>: SpikeMerging<F> + Norm<Radon, F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
983 | I: AlgIteratorFactory<IterInfo<F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
984 | Plot: Plotter<P::ReturnMapping, A::PreadjointCodomain, RNDM<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
985 | { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
986 | match alg { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
987 | &AlgorithmConfig::PDPS(ref algconfig, prox_type) if prox_type == P::prox_type() => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
988 | print!("{running}"); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
989 | pointsource_pdps_reg(f, reg, prox_penalty, algconfig, iterator, plotter, μ0) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
990 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
991 | _ => cont((alg, iterator, plotter, μ0, running)), |
| 0 | 992 | } |
| 993 | } | |
| 35 | 994 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
995 | /// Runs FB-style algorithms if `alg` so requests and `prox_penalty` matches. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
996 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
997 | /// `cont` gives a continuation attempt to find the algorithm matching the description `alg`. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
998 | pub fn run_fb<F, Dat, Reg, P, I, Plot, const N: usize>( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
999 | f: &Dat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1000 | reg: &Reg, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1001 | prox_penalty: &P, |
| 89 | 1002 | init: (&AlgorithmConfig<F>, I, Plot, Option<RNDM<N, F>>, String), |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1003 | cont: impl FnOnce( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1004 | (&AlgorithmConfig<F>, I, Plot, Option<RNDM<N, F>>, String), |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1005 | ) -> DynResult<RNDM<N, F>>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1006 | ) -> DynResult<RNDM<N, F>> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1007 | where |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1008 | F: Float + ToNalgebraRealField, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1009 | I: AlgIteratorFactory<IterInfo<F>>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1010 | Dat: DifferentiableMapping<RNDM<N, F>, Codomain = F> + BoundedCurvature<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1011 | Dat::DerivativeDomain: |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1012 | DifferentiableRealMapping<N, F> + ClosedMul<F> + MinMaxMapping<Loc<N, F>, F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1013 | RNDM<N, F>: SpikeMerging<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1014 | Reg: SlidingRegTerm<Loc<N, F>, F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1015 | P: TransportProxPenalty<Loc<N, F>, Dat::DerivativeDomain, Reg, F> + StepLengthBound<F, Dat>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1016 | Plot: Plotter<P::ReturnMapping, Dat::DerivativeDomain, RNDM<N, F>>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1017 | { |
| 89 | 1018 | run_fb_dom(f, reg, prox_penalty, init, &mut FullSpace, cont) |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1019 | } |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1020 | |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1021 | /// Runs FB-style algorithms if `alg` so requests and `prox_penalty` matches. |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1022 | /// |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1023 | /// `cont` gives a continuation attempt to find the algorithm matching the description `alg`. |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1024 | pub fn run_fb_dom<F, Dat, Reg, P, I, Plot, const N: usize>( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1025 | f: &Dat, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1026 | reg: &Reg, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1027 | prox_penalty: &P, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1028 | (alg, iterator, plotter, μ0, running): ( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1029 | &AlgorithmConfig<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1030 | I, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1031 | Plot, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1032 | Option<RNDM<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1033 | String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1034 | ), |
| 89 | 1035 | domain: &mut impl AdmissibleDomain<Loc<N, F>>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1036 | cont: impl FnOnce( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1037 | (&AlgorithmConfig<F>, I, Plot, Option<RNDM<N, F>>, String), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1038 | ) -> DynResult<RNDM<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1039 | ) -> DynResult<RNDM<N, F>> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1040 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1041 | F: Float + ToNalgebraRealField, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1042 | I: AlgIteratorFactory<IterInfo<F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1043 | Dat: DifferentiableMapping<RNDM<N, F>, Codomain = F> + BoundedCurvature<F>, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1044 | Dat::DerivativeDomain: |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1045 | DifferentiableRealMapping<N, F> + ClosedMul<F> + MinMaxMapping<Loc<N, F>, F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1046 | RNDM<N, F>: SpikeMerging<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1047 | Reg: SlidingRegTerm<Loc<N, F>, F>, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1048 | P: TransportProxPenalty<Loc<N, F>, Dat::DerivativeDomain, Reg, F> + StepLengthBound<F, Dat>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1049 | Plot: Plotter<P::ReturnMapping, Dat::DerivativeDomain, RNDM<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1050 | { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1051 | let pt = P::prox_type(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1052 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1053 | match alg { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1054 | &AlgorithmConfig::FB(ref algconfig, prox_type) if prox_type == pt => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1055 | print!("{running}"); |
| 89 | 1056 | pointsource_fb_dom( |
| 1057 | f, | |
| 1058 | reg, | |
| 1059 | prox_penalty, | |
| 1060 | algconfig, | |
| 1061 | iterator, | |
| 1062 | plotter, | |
| 1063 | μ0, | |
| 1064 | domain, | |
| 1065 | ) | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1066 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1067 | &AlgorithmConfig::FISTA(ref algconfig, prox_type) if prox_type == pt => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1068 | print!("{running}"); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1069 | pointsource_fista_reg(f, reg, prox_penalty, algconfig, iterator, plotter, μ0) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1070 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1071 | &AlgorithmConfig::SlidingFB(ref algconfig, prox_type) if prox_type == pt => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1072 | print!("{running}"); |
| 89 | 1073 | pointsource_sliding_fb( |
| 1074 | f, | |
| 1075 | reg, | |
| 1076 | prox_penalty, | |
| 1077 | algconfig, | |
| 1078 | iterator, | |
| 1079 | plotter, | |
| 1080 | μ0, | |
| 1081 | domain, | |
| 1082 | ) | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1083 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1084 | _ => cont((alg, iterator, plotter, μ0, running)), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1085 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1086 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1087 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1088 | /// Runs FB-style algorithms if `alg` so requests and `prox_penalty` matches. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1089 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1090 | /// For the moment, due to restrictions of the Frank–Wolfe implementation, only the |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1091 | /// $L^2$-squared data term is enabled through the type signatures. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1092 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1093 | /// `cont` gives a continuation attempt to find the algorithm matching the description `alg`. |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1094 | pub fn run_fw<'a, F, U, A, Reg, I, Plot>( |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1095 | f: &'a DataTerm<F, DiscreteMeasure<U, F>, A, Norm222<F>>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1096 | reg: &Reg, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1097 | (alg, iterator, plotter, μ0, running): ( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1098 | &AlgorithmConfig<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1099 | I, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1100 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1101 | Option<DiscreteMeasure<U, F>>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1102 | String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1103 | ), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1104 | cont: impl FnOnce( |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1105 | ( |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1106 | &AlgorithmConfig<F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1107 | I, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1108 | Plot, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1109 | Option<DiscreteMeasure<U, F>>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1110 | String, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1111 | ), |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1112 | ) -> DynResult<DiscreteMeasure<U, F>>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1113 | ) -> DynResult<DiscreteMeasure<U, F>> |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1114 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1115 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1116 | U: Space + Clone + PartialEq, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1117 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1118 | A: ForwardModel<DiscreteMeasure<U, F>, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1119 | A::PreadjointCodomain: MinMaxMapping<U, F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1120 | for<'b> &'b A::PreadjointCodomain: Instance<A::PreadjointCodomain>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1121 | DiscreteMeasure<U, F>: SpikeMerging<F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1122 | Reg: RegTermFW<F, U, A, ValueIteratorFactory<F, AlgIteratorOptions>>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1123 | Plot: Plotter<A::PreadjointCodomain, A::PreadjointCodomain, DiscreteMeasure<U, F>>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1124 | { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1125 | match alg { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1126 | &AlgorithmConfig::FW(ref algconfig) => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1127 | print!("{running}"); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1128 | pointsource_fw_reg(f, reg, algconfig, iterator, plotter, μ0) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1129 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1130 | _ => cont((alg, iterator, plotter, μ0, running)), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1131 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1132 | } |
| 35 | 1133 | |
| 1134 | #[replace_float_literals(F::cast_from(literal))] | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1135 | impl<F, NoiseDistr, S, K, P, B, const N: usize> RunnableExperiment<F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1136 | for Named<ExperimentBiased<F, NoiseDistr, S, K, P, B, N>> |
| 35 | 1137 | where |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1138 | F: ClapFloat |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1139 | + nalgebra::RealField |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1140 | + ToNalgebraRealField<MixedType = F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1141 | + Default |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1142 | + for<'b> Deserialize<'b>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1143 | [usize; N]: Serialize, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1144 | S: Sensor<N, F> + Copy + Serialize + std::fmt::Debug, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1145 | P: Spread<N, F> + Copy + Serialize + std::fmt::Debug, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1146 | Convolution<S, P>: Spread<N, F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1147 | + Bounded<F> |
| 35 | 1148 | + LocalAnalysis<F, Bounds<F>, N> |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1149 | + Copy |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1150 | // TODO: shold not have differentiability as a requirement, but |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1151 | // decide availability of sliding based on it. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1152 | //+ for<'b> Differentiable<&'b Loc<N, F>, Output = Loc<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1153 | // TODO: very weird that rust only compiles with Differentiable |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1154 | // instead of the above one on references, which is required by |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1155 | // poitsource_sliding_fb_reg. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1156 | + DifferentiableRealMapping<N, F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1157 | + Lipschitz<L2, FloatType = F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1158 | for<'b> <Convolution<S, P> as DifferentiableMapping<Loc<N, F>>>::Differential<'b>: |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1159 | Lipschitz<L2, FloatType = F>, // TODO: should not be required generally, only for sliding_fb. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1160 | AutoConvolution<P>: BoundedBy<F, K>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1161 | K: SimpleConvolutionKernel<N, F> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1162 | + LocalAnalysis<F, Bounds<F>, N> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1163 | + Copy |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1164 | + Serialize |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1165 | + std::fmt::Debug, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1166 | Cube<N, F>: P2Minimise<Loc<N, F>, F> + SetOrd, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1167 | PlotLookup: Plotting<N>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1168 | DefaultBT<F, N>: SensorGridBT<F, S, P, N, Depth = DynamicDepth> + BTSearch<N, F>, |
| 35 | 1169 | BTNodeLookup: BTNode<F, usize, Bounds<F>, N>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1170 | RNDM<N, F>: SpikeMerging<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1171 | NoiseDistr: Distribution<F> + Serialize + std::fmt::Debug, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1172 | B: Mapping<Loc<N, F>, Codomain = F> + Serialize + std::fmt::Debug, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1173 | nalgebra::DVector<F>: ClosedMul<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1174 | // This is mainly required for the final Mul requirement to be defined |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1175 | // DefaultSG<F, S, P, N>: ForwardModel< |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1176 | // RNDM<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1177 | // F, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1178 | // PreadjointCodomain = PreadjointCodomain, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1179 | // Observable = DVector<F::MixedType>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1180 | // >, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1181 | // PreadjointCodomain: Bounded<F> + DifferentiableRealMapping<N, F> + std::ops::Mul<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1182 | // Pair<PreadjointCodomain, DVector<F>>: std::ops::Mul<F>, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
1183 | // DefaultSeminormOp<F, K, N> : ProxPenalty<F, PreadjointCodomain, RadonRegTerm<F>, N>, |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
1184 | // DefaultSeminormOp<F, K, N> : ProxPenalty<F, PreadjointCodomain, NonnegRadonRegTerm<F>, N>, |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
1185 | // RadonSquared : ProxPenalty<F, PreadjointCodomain, RadonRegTerm<F>, N>, |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
1186 | // RadonSquared : ProxPenalty<F, PreadjointCodomain, NonnegRadonRegTerm<F>, N>, |
| 35 | 1187 | { |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1188 | fn name(&self) -> &str { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1189 | self.name.as_ref() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1190 | } |
| 35 | 1191 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1192 | fn runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1193 | &self, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1194 | cli: &CommandLineArgs, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1195 | cli_algorithm_overrides: &AlgorithmOverrides<F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1196 | ) -> DynError { |
| 35 | 1197 | // Get experiment configuration |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1198 | let &ExperimentBiased { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1199 | λ, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1200 | ref bias, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1201 | base: |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1202 | ExperimentV2 { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1203 | domain, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1204 | sensor_count, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1205 | ref noise_distr, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1206 | sensor, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1207 | spread, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1208 | kernel, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1209 | ref μ_hat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1210 | regularisation, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1211 | kernel_plot_width, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1212 | dataterm, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1213 | noise_seed, |
| 35 | 1214 | .. |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1215 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1216 | } = &self.data; |
| 35 | 1217 | |
| 1218 | // Set up algorithms | |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1219 | let algorithms = self.collect_algs( |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1220 | cli, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1221 | cli_algorithm_overrides, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1222 | |alg| { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1223 | Some(AlgorithmOverrides { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1224 | merge_radius: Some(self.data.base.default_merge_radius), |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1225 | ..self |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1226 | .data |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1227 | .base |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1228 | .algorithm_overrides |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1229 | .get(&alg) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1230 | .cloned() |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1231 | .unwrap_or_else(Default::default) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1232 | }) |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1233 | }, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1234 | Some(®ularisation), |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1235 | &[ |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1236 | DefaultAlgorithm::SlidingPDPS, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1237 | DefaultAlgorithm::ForwardPDPS, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1238 | DefaultAlgorithm::RadonSlidingPDPS, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1239 | DefaultAlgorithm::RadonForwardPDPS, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1240 | ], |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1241 | )?; |
| 35 | 1242 | |
| 1243 | // Set up operators | |
| 1244 | let depth = DynamicDepth(8); | |
| 1245 | let opA = DefaultSG::new(domain, sensor_count, sensor, spread, depth); | |
| 1246 | let op𝒟 = DefaultSeminormOp::new(depth, domain, kernel); | |
| 1247 | let opAext = RowOp(opA.clone(), IdOp::new()); | |
| 1248 | let fnR = Zero::new(); | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1249 | let h = map3( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1250 | domain.span_start(), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1251 | domain.span_end(), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1252 | sensor_count, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1253 | |a, b, n| (b - a) / F::cast_from(n), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1254 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1255 | .into_iter() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1256 | .reduce(NumTraitsFloat::max) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1257 | .unwrap(); |
| 35 | 1258 | let z = DVector::zeros(sensor_count.iter().product()); |
| 1259 | let opKz = Grad::new_for(&z, h, sensor_count, ForwardNeumann).unwrap(); | |
| 1260 | let y = opKz.apply(&z); | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1261 | let fnH = Weighted { base_fn: L1.as_mapping(), weight: λ }; // TODO: L_{2,1} |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1262 | // let zero_y = y.clone(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1263 | // let zeroBTFN = opA.preadjoint().apply(&zero_y); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1264 | // let opKμ = ZeroOp::new(&zero_y, zeroBTFN); |
| 35 | 1265 | |
| 1266 | // Set up random number generator. | |
| 1267 | let mut rng = StdRng::seed_from_u64(noise_seed); | |
| 1268 | ||
| 1269 | // Generate the data and calculate SSNR statistic | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1270 | let bias_vec = DVector::from_vec( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1271 | opA.grid() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1272 | .into_iter() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1273 | .map(|v| bias.apply(v)) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1274 | .collect::<Vec<F>>(), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1275 | ); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1276 | let b_hat: DVector<_> = opA.apply(μ_hat) + &bias_vec; |
| 35 | 1277 | let noise = DVector::from_distribution(b_hat.len(), &noise_distr, &mut rng); |
| 1278 | let b = &b_hat + &noise; | |
| 1279 | // Need to wrap calc_ssnr into a function to hide ultra-lame nalgebra::RealField | |
| 1280 | // overloading log10 and conflicting with standard NumTraits one. | |
| 1281 | let stats = ExperimentStats::new(&b, &noise); | |
| 1282 | ||
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1283 | let prefix = self.start(cli)?; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1284 | write_json(format!("{prefix}stats.json"), &stats)?; |
| 35 | 1285 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1286 | plotall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1287 | cli, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1288 | &prefix, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1289 | &domain, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1290 | &sensor, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1291 | &kernel, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1292 | &spread, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1293 | &μ_hat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1294 | &op𝒟, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1295 | &opA, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1296 | &b_hat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1297 | &b, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1298 | kernel_plot_width, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1299 | )?; |
| 35 | 1300 | |
| 1301 | opA.write_observable(&bias_vec, format!("{prefix}bias"))?; | |
| 1302 | ||
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1303 | let plotgrid = lingrid(&domain, &[if N == 1 { 1000 } else { 100 }; N]); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1304 | let make_plotter = |this_prefix| { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1305 | let plot_count = if cli.plot >= PlotLevel::Iter { 2000 } else { 0 }; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1306 | SeqPlotter::new(this_prefix, plot_count, plotgrid.clone()) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1307 | }; |
| 35 | 1308 | |
| 1309 | let save_extra = |prefix, z| opA.write_observable(&z, format!("{prefix}z")); | |
|
24
d29d1fcf5423
Support arbitrary regularisation terms; implement non-positivity-constrained regularisation.
Tuomo Valkonen <tuomov@iki.fi>
parents:
23
diff
changeset
|
1310 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1311 | let μ0 = None; // Zero init |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1312 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1313 | match (dataterm, regularisation) { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1314 | (DataTermType::L222, Regularisation::Radon(α)) => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1315 | let f = DataTerm::new(opAext, b, Norm222::new()); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1316 | let reg = RadonRegTerm(α); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1317 | self.do_runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1318 | &prefix, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1319 | cli, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1320 | algorithms, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1321 | make_plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1322 | save_extra, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1323 | (μ0, z, y), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1324 | |p| { |
| 89 | 1325 | run_pdps_pair_dom( |
| 1326 | &f, | |
| 1327 | ®, | |
| 1328 | &RadonSquared, | |
| 1329 | &opKz, | |
| 1330 | &fnR, | |
| 1331 | &fnH, | |
| 1332 | p, | |
| 1333 | &mut FullSpace, | |
| 1334 | |q| { | |
| 1335 | run_pdps_pair_dom( | |
| 1336 | &f, | |
| 1337 | ®, | |
| 1338 | &op𝒟, | |
| 1339 | &opKz, | |
| 1340 | &fnR, | |
| 1341 | &fnH, | |
| 1342 | q, | |
| 1343 | &mut FullSpace, | |
| 1344 | |_| Err(NotImplemented.into()), | |
| 1345 | ) | |
| 1346 | }, | |
| 1347 | ) | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1348 | .map(|Pair(μ, z)| (μ, z)) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1349 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1350 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1351 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1352 | (DataTermType::L222, Regularisation::NonnegRadon(α)) => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1353 | let f = DataTerm::new(opAext, b, Norm222::new()); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1354 | let reg = NonnegRadonRegTerm(α); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1355 | self.do_runall( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1356 | &prefix, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1357 | cli, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1358 | algorithms, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1359 | make_plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1360 | save_extra, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1361 | (μ0, z, y), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1362 | |p| { |
| 89 | 1363 | run_pdps_pair_dom( |
| 1364 | &f, | |
| 1365 | ®, | |
| 1366 | &RadonSquared, | |
| 1367 | &opKz, | |
| 1368 | &fnR, | |
| 1369 | &fnH, | |
| 1370 | p, | |
| 1371 | &mut FullSpace, | |
| 1372 | |q| { | |
| 1373 | run_pdps_pair_dom( | |
| 1374 | &f, | |
| 1375 | ®, | |
| 1376 | &op𝒟, | |
| 1377 | &opKz, | |
| 1378 | &fnR, | |
| 1379 | &fnH, | |
| 1380 | q, | |
| 1381 | &mut FullSpace, | |
| 1382 | |_| Err(NotImplemented.into()), | |
| 1383 | ) | |
| 1384 | }, | |
| 1385 | ) | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1386 | .map(|Pair(μ, z)| (μ, z)) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1387 | }, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1388 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1389 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1390 | _ => Err(NotImplemented.into()), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1391 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1392 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1393 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1394 | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1395 | type MeasureZ<F, Z, U> = Pair<DiscreteMeasure<U, F>, Z>; |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1396 | |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1397 | #[deprecated] |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1398 | pub fn run_pdps_pair<F, S, Dat, Reg, Z, R, Y, KOpZ, H, P, I, Plot, U>( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1399 | f: &Dat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1400 | reg: &Reg, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1401 | prox_penalty: &P, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1402 | opKz: &KOpZ, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1403 | fnR: &R, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1404 | fnH: &H, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1405 | init: ( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1406 | &AlgorithmConfig<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1407 | I, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1408 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1409 | (Option<DiscreteMeasure<U, F>>, Z, Y), |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1410 | String, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1411 | ), |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1412 | cont: impl FnOnce( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1413 | ( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1414 | &AlgorithmConfig<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1415 | I, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1416 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1417 | (Option<DiscreteMeasure<U, F>>, Z, Y), |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1418 | String, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1419 | ), |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
1420 | ) -> DynResult<MeasureZ<F, Z, U>>, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
1421 | ) -> DynResult<MeasureZ<F, Z, U>> |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1422 | where |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1423 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1424 | U: Space + Clone + Dist<L2, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1425 | for<'a> &'a U: Instance<U>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1426 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1427 | Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>> |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1428 | + BoundedCurvature<F>, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1429 | S: ClosedMul<F> + MinMaxMapping<U, F>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1430 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1431 | //Pair<S, Z>: ClosedMul<F>, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1432 | DiscreteMeasure<U, F>: SpikeMerging<F> + Norm<Radon, F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1433 | Reg: SlidingRegTerm<U, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1434 | P: TransportProxPenalty<U, S, Reg, F>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1435 | KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1436 | + GEMV<F, Z> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1437 | + SimplyAdjointable<Z, Y, AdjointCodomain = Z>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1438 | KOpZ::SimpleAdjoint: GEMV<F, Y>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1439 | Y: ClosedEuclidean<F> + Clone, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1440 | for<'b> &'b Y: Instance<Y>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1441 | Z: ClosedEuclidean<F> + Clone + ClosedMul<F> + AXPY, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1442 | for<'b> &'b Z: Instance<Z>, // compiler overflow + Mul<F, Output = Z>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1443 | R: Prox<Z, Codomain = F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1444 | H: Conjugable<Y, F, Codomain = F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1445 | for<'b> H::Conjugate<'b>: Prox<Y>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1446 | Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1447 | { |
| 89 | 1448 | run_pdps_pair_dom( |
| 1449 | f, | |
| 1450 | reg, | |
| 1451 | prox_penalty, | |
| 1452 | opKz, | |
| 1453 | fnR, | |
| 1454 | fnH, | |
| 1455 | init, | |
| 1456 | &mut FullSpace, | |
| 1457 | cont, | |
| 1458 | ) | |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1459 | } |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1460 | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1461 | pub fn run_pdps_pair_dom<F, S, Dat, Reg, Z, R, Y, KOpZ, H, P, I, Plot, U>( |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1462 | f: &Dat, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1463 | reg: &Reg, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1464 | prox_penalty: &P, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1465 | opKz: &KOpZ, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1466 | fnR: &R, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1467 | fnH: &H, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1468 | (alg, iterator, plotter, μ0zy, running): ( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1469 | &AlgorithmConfig<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1470 | I, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1471 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1472 | (Option<DiscreteMeasure<U, F>>, Z, Y), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1473 | String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1474 | ), |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1475 | domain: &mut impl AdmissibleDomain<U>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1476 | cont: impl FnOnce( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1477 | ( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1478 | &AlgorithmConfig<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1479 | I, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1480 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1481 | (Option<DiscreteMeasure<U, F>>, Z, Y), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1482 | String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1483 | ), |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
1484 | ) -> DynResult<MeasureZ<F, Z, U>>, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
1485 | ) -> DynResult<MeasureZ<F, Z, U>> |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1486 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1487 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1488 | U: Space + Clone + Dist<L2, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1489 | for<'a> &'a U: Instance<U>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1490 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1491 | Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>> |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1492 | + BoundedCurvature<F>, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1493 | S: ClosedMul<F> + MinMaxMapping<U, F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1494 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1495 | //Pair<S, Z>: ClosedMul<F>, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1496 | DiscreteMeasure<U, F>: SpikeMerging<F> + Norm<Radon, F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1497 | Reg: SlidingRegTerm<U, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1498 | P: TransportProxPenalty<U, S, Reg, F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1499 | KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1500 | + GEMV<F, Z> |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1501 | + SimplyAdjointable<Z, Y, AdjointCodomain = Z>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1502 | KOpZ::SimpleAdjoint: GEMV<F, Y>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1503 | Y: ClosedEuclidean<F> + Clone, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1504 | for<'b> &'b Y: Instance<Y>, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
1505 | Z: ClosedEuclidean<F> + Clone + ClosedMul<F> + AXPY, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1506 | for<'b> &'b Z: Instance<Z>, // compiler overflow + Mul<F, Output = Z>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1507 | R: Prox<Z, Codomain = F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1508 | H: Conjugable<Y, F, Codomain = F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1509 | for<'b> H::Conjugate<'b>: Prox<Y>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1510 | Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1511 | { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1512 | let pt = P::prox_type(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1513 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1514 | match alg { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1515 | &AlgorithmConfig::ForwardPDPS(ref algconfig, prox_type) if prox_type == pt => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1516 | print!("{running}"); |
| 89 | 1517 | pointsource_forward_pdps_pair_dom( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1518 | f, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1519 | reg, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1520 | prox_penalty, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1521 | algconfig, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1522 | iterator, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1523 | plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1524 | μ0zy, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1525 | opKz, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1526 | fnR, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1527 | fnH, |
| 89 | 1528 | domain, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1529 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1530 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1531 | &AlgorithmConfig::SlidingPDPS(ref algconfig, prox_type) if prox_type == pt => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1532 | print!("{running}"); |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1533 | pointsource_sliding_pdps_pair_dom( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1534 | f, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1535 | reg, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1536 | prox_penalty, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1537 | algconfig, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1538 | iterator, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1539 | plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1540 | μ0zy, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1541 | opKz, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1542 | fnR, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1543 | fnH, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1544 | domain, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1545 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1546 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1547 | _ => cont((alg, iterator, plotter, μ0zy, running)), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1548 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1549 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1550 | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1551 | pub fn run_fb_pair<F, S, Dat, Reg, Z, R, P, I, Plot, U>( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1552 | f: &Dat, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1553 | reg: &Reg, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1554 | prox_penalty: &P, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1555 | fnR: &R, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1556 | init: ( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1557 | &AlgorithmConfig<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1558 | I, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1559 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1560 | (Option<DiscreteMeasure<U, F>>, Z), |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1561 | String, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1562 | ), |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1563 | cont: impl FnOnce( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1564 | ( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1565 | &AlgorithmConfig<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1566 | I, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1567 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1568 | (Option<DiscreteMeasure<U, F>>, Z), |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1569 | String, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1570 | ), |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
1571 | ) -> DynResult<MeasureZ<F, Z, U>>, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
1572 | ) -> DynResult<MeasureZ<F, Z, U>> |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1573 | where |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1574 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1575 | U: Space + Clone + Dist<L2, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1576 | for<'a> &'a U: Instance<U>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1577 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1578 | Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>> |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1579 | + BoundedCurvature<F>, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1580 | S: ClosedMul<F> + MinMaxMapping<U, F>, |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1581 | DiscreteMeasure<U, F>: SpikeMerging<F> + Norm<Radon, F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1582 | Reg: SlidingRegTerm<U, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1583 | P: TransportProxPenalty<U, S, Reg, F>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1584 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1585 | Z: ClosedEuclidean<F> + AXPY + Clone, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1586 | for<'b> &'b Z: Instance<Z>, // compiler overflow + Mul<F, Output = Z>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1587 | R: Prox<Z, Codomain = F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1588 | Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1589 | { |
| 89 | 1590 | run_fb_pair_dom(f, reg, prox_penalty, fnR, init, &mut FullSpace, cont) |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1591 | } |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1592 | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1593 | pub fn run_fb_pair_dom<F, S, Dat, Reg, Z, R, P, I, Plot, U>( |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1594 | f: &Dat, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1595 | reg: &Reg, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1596 | prox_penalty: &P, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1597 | fnR: &R, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1598 | (alg, iterator, plotter, μ0z, running): ( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1599 | &AlgorithmConfig<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1600 | I, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1601 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1602 | (Option<DiscreteMeasure<U, F>>, Z), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1603 | String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1604 | ), |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1605 | domain: &mut impl AdmissibleDomain<U>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1606 | cont: impl FnOnce( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1607 | ( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1608 | &AlgorithmConfig<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1609 | I, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1610 | Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1611 | (Option<DiscreteMeasure<U, F>>, Z), |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1612 | String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1613 | ), |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
1614 | ) -> DynResult<MeasureZ<F, Z, U>>, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
1615 | ) -> DynResult<MeasureZ<F, Z, U>> |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1616 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1617 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1618 | U: Space + Clone + Dist<L2, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1619 | for<'a> &'a U: Instance<U>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1620 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1621 | Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>> |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1622 | + BoundedCurvature<F>, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1623 | S: ClosedMul<F> + MinMaxMapping<U, F>, |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1624 | DiscreteMeasure<U, F>: SpikeMerging<F> + Norm<Radon, F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1625 | Reg: SlidingRegTerm<U, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1626 | P: TransportProxPenalty<U, S, Reg, F>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1627 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1628 | Z: ClosedEuclidean<F> + AXPY + Clone, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1629 | for<'b> &'b Z: Instance<Z>, // compiler overflow + Mul<F, Output = Z>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1630 | R: Prox<Z, Codomain = F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
1631 | Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1632 | { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1633 | let pt = P::prox_type(); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1634 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1635 | match alg { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1636 | &AlgorithmConfig::FB(ref algconfig, prox_type) if prox_type == pt => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1637 | print!("{running}"); |
| 89 | 1638 | pointsource_fb_pair_dom( |
| 1639 | f, | |
| 1640 | reg, | |
| 1641 | prox_penalty, | |
| 1642 | algconfig, | |
| 1643 | iterator, | |
| 1644 | plotter, | |
| 1645 | μ0z, | |
| 1646 | fnR, | |
| 1647 | domain, | |
| 1648 | ) | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1649 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1650 | &AlgorithmConfig::SlidingFB(ref algconfig, prox_type) if prox_type == pt => { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1651 | print!("{running}"); |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
1652 | pointsource_sliding_fb_pair_dom( |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1653 | f, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1654 | reg, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1655 | prox_penalty, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1656 | algconfig, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1657 | iterator, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1658 | plotter, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1659 | μ0z, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1660 | fnR, |
| 89 | 1661 | domain, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1662 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1663 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1664 | _ => cont((alg, iterator, plotter, μ0z, running)), |
| 35 | 1665 | } |
| 1666 | } | |
| 1667 | ||
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1668 | #[derive(Copy, Clone, Debug, Serialize, Deserialize)] |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1669 | struct ValueRange<F: Float> { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1670 | ini: F, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1671 | min: F, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1672 | } |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1673 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1674 | impl<F: Float> ValueRange<F> { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1675 | fn expand_with(self, other: Self) -> Self { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1676 | ValueRange { ini: self.ini.max(other.ini), min: self.min.min(other.min) } |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1677 | } |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1678 | } |
| 35 | 1679 | |
| 1680 | /// Calculative minimum and maximum values of all the `logs`, and save them into | |
| 1681 | /// corresponding file names given as the first elements of the tuples in the vectors. | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1682 | fn save_logs<F: Float + for<'b> Deserialize<'b>>( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1683 | logs: Vec<(String, Logger<Timed<IterInfo<F>>>)>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1684 | valuerange_file: String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1685 | load_valuerange: bool, |
| 35 | 1686 | ) -> DynError { |
| 1687 | // Process logs for relative values | |
| 1688 | println!("{}", "Processing logs…"); | |
| 1689 | ||
| 1690 | // Find minimum value and initial value within a single log | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1691 | let proc_single_log = |log: &Logger<Timed<IterInfo<F>>>| { |
| 35 | 1692 | let d = log.data(); |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1693 | let mi = d.iter().map(|i| i.data.value).reduce(NumTraitsFloat::min); |
| 35 | 1694 | d.first() |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1695 | .map(|i| i.data.value) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1696 | .zip(mi) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1697 | .map(|(ini, min)| ValueRange { ini, min }) |
| 35 | 1698 | }; |
| 1699 | ||
| 1700 | // Find minimum and maximum value over all logs | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1701 | let mut v = logs |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1702 | .iter() |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1703 | .filter_map(|&(_, ref log)| proc_single_log(log)) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1704 | .reduce(|v1, v2| v1.expand_with(v2)) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1705 | .ok_or(anyhow!("No algorithms found"))?; |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1706 | |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1707 | // Load existing range |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1708 | if load_valuerange && std::fs::metadata(&valuerange_file).is_ok() { |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1709 | let data = std::fs::read_to_string(&valuerange_file)?; |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1710 | v = v.expand_with(serde_json::from_str(&data)?); |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1711 | } |
| 35 | 1712 | |
| 1713 | let logmap = |Timed { cpu_time, iter, data }| { | |
| 1714 | let IterInfo { | |
| 1715 | value, | |
| 1716 | n_spikes, | |
| 1717 | inner_iters, | |
| 1718 | merged, | |
| 1719 | pruned, | |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1720 | discrepancy, |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1721 | aux_discrepancy, |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1722 | joint_discrepancy, |
| 35 | 1723 | //postprocessing, |
| 1724 | this_iters, | |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1725 | μ_norm, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1726 | ε, |
| 35 | 1727 | .. |
| 1728 | } = data; | |
| 1729 | // let post_value = match (postprocessing, dataterm) { | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1730 | // (Some(mut μ), DataTermType::L222) => { |
| 35 | 1731 | // // Comparison postprocessing is only implemented for the case handled |
| 1732 | // // by the FW variants. | |
| 1733 | // reg.optimise_weights( | |
| 1734 | // &mut μ, &opA, &b, &findim_data, &inner_config, | |
| 1735 | // inner_it | |
| 1736 | // ); | |
| 1737 | // dataterm.value_at_residual(opA.apply(&μ) - &b) | |
| 1738 | // + regularisation.apply(&μ) | |
| 1739 | // }, | |
| 1740 | // _ => value, | |
| 1741 | // }; | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1742 | let relative_value = (value - v.min) / (v.ini - v.min); |
| 35 | 1743 | CSVLog { |
| 1744 | iter, | |
| 1745 | value, | |
| 1746 | relative_value, | |
| 1747 | //post_value, | |
| 1748 | n_spikes, | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1749 | cpu_time: cpu_time.as_secs_f64(), |
| 35 | 1750 | inner_iters, |
| 1751 | merged, | |
| 1752 | pruned, | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1753 | this_iters, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1754 | radon_norm: μ_norm, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1755 | epsilon: ε, |
|
98
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1756 | discrepancy: discrepancy.unwrap_or(F::NEG_INFINITY), |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1757 | aux_discrepancy: aux_discrepancy.unwrap_or(F::NEG_INFINITY), |
|
b9818eb24b47
Store subdifferential discrepancy in log
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
1758 | joint_discrepancy: joint_discrepancy.unwrap_or(F::NEG_INFINITY), |
| 35 | 1759 | } |
| 1760 | }; | |
| 1761 | ||
| 1762 | println!("{}", "Saving logs …".green()); | |
| 1763 | ||
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1764 | serde_json::to_writer_pretty(std::fs::File::create(&valuerange_file)?, &v)?; |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
1765 | |
| 35 | 1766 | for (name, logger) in logs { |
| 1767 | logger.map(logmap).write_csv(name)?; | |
| 1768 | } | |
| 1769 | ||
| 1770 | Ok(()) | |
| 1771 | } | |
| 1772 | ||
| 0 | 1773 | /// Plot experiment setup |
| 1774 | #[replace_float_literals(F::cast_from(literal))] | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1775 | fn plotall<F, Sensor, Kernel, Spread, 𝒟, A, const N: usize>( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1776 | cli: &CommandLineArgs, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1777 | prefix: &String, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1778 | domain: &Cube<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1779 | sensor: &Sensor, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1780 | kernel: &Kernel, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1781 | spread: &Spread, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1782 | μ_hat: &RNDM<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1783 | op𝒟: &𝒟, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1784 | opA: &A, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1785 | b_hat: &A::Observable, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1786 | b: &A::Observable, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1787 | kernel_plot_width: F, |
| 0 | 1788 | ) -> DynError |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1789 | where |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1790 | F: Float + ToNalgebraRealField, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1791 | Sensor: RealMapping<N, F> + Support<N, F> + Clone, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1792 | Spread: RealMapping<N, F> + Support<N, F> + Clone, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1793 | Kernel: RealMapping<N, F> + Support<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1794 | Convolution<Sensor, Spread>: DifferentiableRealMapping<N, F> + Support<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1795 | 𝒟: DiscreteMeasureOp<Loc<N, F>, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1796 | 𝒟::Codomain: RealMapping<N, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1797 | A: ForwardModel<RNDM<N, F>, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1798 | for<'a> &'a A::Observable: Instance<A::Observable>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1799 | A::PreadjointCodomain: DifferentiableRealMapping<N, F> + Bounded<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1800 | PlotLookup: Plotting<N>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1801 | Cube<N, F>: SetOrd, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1802 | { |
|
9
21b0e537ac0e
Command line parameter passing simplifications and make `-o` required.
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
1803 | if cli.plot < PlotLevel::Data { |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1804 | return Ok(()); |
| 0 | 1805 | } |
| 1806 | ||
| 1807 | let base = Convolution(sensor.clone(), spread.clone()); | |
| 1808 | ||
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1809 | let resolution = if N == 1 { 100 } else { 40 }; |
| 35 | 1810 | let pfx = |n| format!("{prefix}{n}"); |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1811 | let plotgrid = lingrid( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1812 | &[[-kernel_plot_width, kernel_plot_width]; N].into(), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1813 | &[resolution; N], |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1814 | ); |
| 0 | 1815 | |
| 35 | 1816 | PlotLookup::plot_into_file(sensor, plotgrid, pfx("sensor")); |
| 1817 | PlotLookup::plot_into_file(kernel, plotgrid, pfx("kernel")); | |
| 1818 | PlotLookup::plot_into_file(spread, plotgrid, pfx("spread")); | |
| 1819 | PlotLookup::plot_into_file(&base, plotgrid, pfx("base_sensor")); | |
| 0 | 1820 | |
| 1821 | let plotgrid2 = lingrid(&domain, &[resolution; N]); | |
| 1822 | ||
| 1823 | let ω_hat = op𝒟.apply(μ_hat); | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1824 | let noise = opA.preadjoint().apply(opA.apply(μ_hat) - b); |
| 35 | 1825 | PlotLookup::plot_into_file(&ω_hat, plotgrid2, pfx("omega_hat")); |
| 1826 | PlotLookup::plot_into_file(&noise, plotgrid2, pfx("omega_noise")); | |
| 0 | 1827 | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1828 | let preadj_b = opA.preadjoint().apply(b); |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1829 | let preadj_b_hat = opA.preadjoint().apply(b_hat); |
| 0 | 1830 | //let bounds = preadj_b.bounds().common(&preadj_b_hat.bounds()); |
| 1831 | PlotLookup::plot_into_file_spikes( | |
| 35 | 1832 | Some(&preadj_b), |
| 1833 | Some(&preadj_b_hat), | |
| 1834 | plotgrid2, | |
| 1835 | &μ_hat, | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
46
diff
changeset
|
1836 | pfx("omega_b"), |
| 0 | 1837 | ); |
| 35 | 1838 | PlotLookup::plot_into_file(&preadj_b, plotgrid2, pfx("preadj_b")); |
| 1839 | PlotLookup::plot_into_file(&preadj_b_hat, plotgrid2, pfx("preadj_b_hat")); | |
| 0 | 1840 | |
| 1841 | // Save true solution and observables | |
| 1842 | μ_hat.write_csv(pfx("orig.txt"))?; | |
| 1843 | opA.write_observable(&b_hat, pfx("b_hat"))?; | |
| 1844 | opA.write_observable(&b, pfx("b_noisy")) | |
| 1845 | } |