Skip to main content

pmcore/results/
fit_result.rs

1use pharmsol::Equation;
2
3use crate::estimation::nonparametric::NonParametricResult;
4use crate::results::{FitSummary, IndividualSummary, PopulationSummary};
5
6/// A shared trait for the output of any estimation algorithm.
7pub trait FitResult {
8    fn objf(&self) -> f64;
9    fn converged(&self) -> bool;
10    fn summary(&self) -> FitSummary;
11    fn population_summary(&self) -> PopulationSummary;
12    fn individual_summaries(&self) -> Vec<IndividualSummary>;
13}
14
15// TODO: Implement ParametricResult once parametric fitting is available.
16#[derive(Debug)]
17#[allow(unused)]
18pub struct ParametricResult<E: Equation> {
19    _phantom: std::marker::PhantomData<E>,
20}
21
22impl<E: Equation> FitResult for ParametricResult<E> {
23    fn objf(&self) -> f64 {
24        unimplemented!("Parametric result not yet implemented")
25    }
26    fn converged(&self) -> bool {
27        unimplemented!()
28    }
29    fn summary(&self) -> FitSummary {
30        unimplemented!()
31    }
32    fn population_summary(&self) -> PopulationSummary {
33        unimplemented!()
34    }
35    fn individual_summaries(&self) -> Vec<IndividualSummary> {
36        unimplemented!()
37    }
38}
39
40use crate::estimation::nonparametric;
41
42impl<E: Equation> FitResult for NonParametricResult<E> {
43    fn objf(&self) -> f64 {
44        self.objf() // Assuming the struct has this native method
45    }
46
47    fn converged(&self) -> bool {
48        self.converged() // Assuming the struct has this native method
49    }
50
51    fn summary(&self) -> FitSummary {
52        nonparametric::fit_summary(self)
53    }
54
55    fn population_summary(&self) -> PopulationSummary {
56        nonparametric::population_summary(self)
57    }
58
59    fn individual_summaries(&self) -> Vec<IndividualSummary> {
60        nonparametric::individual_summaries(self)
61    }
62}