pub trait ReconstructionAlgorithm {
type IterationMetrics: AlgorithmIterationMetrics;
// Required methods
fn step<M: MeasurementRead>(
&mut self,
problem: &ReconstructionProblem<M>,
state: &mut ReconstructionState,
batch: &Batch,
iteration: usize,
) -> Result<StepOutput<Self::IterationMetrics>>;
fn iterations(&self) -> usize;
// Provided methods
fn validate(&self) -> Result<()> { ... }
fn validate_problem<M: MeasurementRead>(
&self,
_problem: &ReconstructionProblem<M>,
) -> Result<()> { ... }
fn initialize<M: MeasurementRead>(
&self,
problem: &ReconstructionProblem<M>,
) -> Result<ReconstructionState> { ... }
fn initialize_with_backend<M: MeasurementRead>(
&self,
problem: &ReconstructionProblem<M>,
backend: Arc<dyn Backend>,
) -> Result<ReconstructionState> { ... }
fn canonicalize_state<M: MeasurementRead>(
&self,
_problem: &ReconstructionProblem<M>,
_state: &mut ReconstructionState,
) -> Result<()> { ... }
fn supports_joint_reconstruction(&self) -> bool { ... }
fn batch_size(&self) -> usize { ... }
fn run<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
) -> Result<ReconstructionResult>
where Self: Sized { ... }
fn run_with_callbacks<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
callbacks: Vec<Box<dyn Callback>>,
) -> Result<ReconstructionResult>
where Self: Sized { ... }
fn run_from_checkpoint<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
checkpoint: ReconstructionCheckpoint,
) -> Result<ReconstructionResult>
where Self: Sized { ... }
}Expand description
Contract implemented by iterative image-plane reconstruction solvers.
Implementors validate their configuration, initialize a ReconstructionState,
and update one scheduled Batch at a time. The trait’s convenience methods own
the algorithm, borrow the problem for the duration of the run, and return an owned
ReconstructionResult.
Required Associated Types§
Sourcetype IterationMetrics: AlgorithmIterationMetrics
type IterationMetrics: AlgorithmIterationMetrics
Algorithm-specific metrics emitted by each step and appended to the trace.
Required Methods§
Sourcefn step<M: MeasurementRead>(
&mut self,
problem: &ReconstructionProblem<M>,
state: &mut ReconstructionState,
batch: &Batch,
iteration: usize,
) -> Result<StepOutput<Self::IterationMetrics>>
fn step<M: MeasurementRead>( &mut self, problem: &ReconstructionProblem<M>, state: &mut ReconstructionState, batch: &Batch, iteration: usize, ) -> Result<StepOutput<Self::IterationMetrics>>
Updates state for one scheduled batch in zero-based iteration.
Sourcefn iterations(&self) -> usize
fn iterations(&self) -> usize
Returns the requested number of complete schedule passes.
Provided Methods§
Sourcefn validate(&self) -> Result<()>
fn validate(&self) -> Result<()>
Validates solver parameters independently of a reconstruction problem.
Sourcefn validate_problem<M: MeasurementRead>(
&self,
_problem: &ReconstructionProblem<M>,
) -> Result<()>
fn validate_problem<M: MeasurementRead>( &self, _problem: &ReconstructionProblem<M>, ) -> Result<()>
Validates solver requirements that depend on problem.
Sourcefn initialize<M: MeasurementRead>(
&self,
problem: &ReconstructionProblem<M>,
) -> Result<ReconstructionState>
fn initialize<M: MeasurementRead>( &self, problem: &ReconstructionProblem<M>, ) -> Result<ReconstructionState>
Creates the default CPU-backed state for problem.
Sourcefn initialize_with_backend<M: MeasurementRead>(
&self,
problem: &ReconstructionProblem<M>,
backend: Arc<dyn Backend>,
) -> Result<ReconstructionState>
fn initialize_with_backend<M: MeasurementRead>( &self, problem: &ReconstructionProblem<M>, backend: Arc<dyn Backend>, ) -> Result<ReconstructionState>
Creates reconstruction state using the supplied execution backend.
Sourcefn canonicalize_state<M: MeasurementRead>(
&self,
_problem: &ReconstructionProblem<M>,
_state: &mut ReconstructionState,
) -> Result<()>
fn canonicalize_state<M: MeasurementRead>( &self, _problem: &ReconstructionProblem<M>, _state: &mut ReconstructionState, ) -> Result<()>
Projects algorithm-owned ambiguities into a stable reported convention.
Runner calls this after initialization or checkpoint restoration and
after every completed iteration, before iteration diagnostics and
callbacks, checkpoints, and final result construction. The default
implementation leaves state unchanged. Algorithms that jointly recover
coupled fields can override it without requiring external implementations
to add a lifecycle method. Implementations must preserve the represented
forward prediction and make repeated projection numerically idempotent.
Sourcefn supports_joint_reconstruction(&self) -> bool
fn supports_joint_reconstruction(&self) -> bool
Reports whether the algorithm may run inside physical joint calibration.
The default permits wrapping. Stateful methods whose internal variables
would become invalid when the calibrated forward model is recompiled can
return false; JointReconstruction then rejects them during
validation.
Sourcefn batch_size(&self) -> usize
fn batch_size(&self) -> usize
Returns the number of measured frames combined into one step.
Sourcefn run<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
) -> Result<ReconstructionResult>where
Self: Sized,
fn run<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
) -> Result<ReconstructionResult>where
Self: Sized,
Runs the algorithm with default sequential scheduling and no callbacks.
Sourcefn run_with_callbacks<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
callbacks: Vec<Box<dyn Callback>>,
) -> Result<ReconstructionResult>where
Self: Sized,
fn run_with_callbacks<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
callbacks: Vec<Box<dyn Callback>>,
) -> Result<ReconstructionResult>where
Self: Sized,
Runs the algorithm and invokes callbacks at their declared hooks.
Sourcefn run_from_checkpoint<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
checkpoint: ReconstructionCheckpoint,
) -> Result<ReconstructionResult>where
Self: Sized,
fn run_from_checkpoint<M: MeasurementRead>(
self,
problem: &ReconstructionProblem<M>,
checkpoint: ReconstructionCheckpoint,
) -> Result<ReconstructionResult>where
Self: Sized,
Resumes a run from a checkpoint after validating it against problem.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.