pub struct BestDoseResult { /* private fields */ }Expand description
Result from BestDose optimization
Contains the optimal doses and associated predictions from running
BestDoseProblem::optimize().
§Fields
dose: Optimal dose amount(s) in the same order as doses in target subjectobjf: Final cost function value at optimal dosesstatus: Optimization status message (e.g., “converged”, “max iterations”)preds: Concentration-time predictions using optimal dosesauc_predictions: AUC values at observation times (only for [Target::AUC])optimization_method: Which method won:"posterior"or"uniform"
§Interpretation
§Optimization Method
-
“posterior”: Patient-specific optimization won (uses posterior weights)
- Indicates patient differs from population or has sufficient history
- Doses are highly personalized
-
“uniform”: Population-based optimization won (uses uniform weights)
- Indicates patient is population-typical or has limited history
- Doses are more conservative/robust
§Cost Function (objf)
Lower is better. The cost combines variance and bias:
Cost = (1-λ) × Variance + λ × Bias²§Examples
§Extracting Results
ⓘ
let result = problem.optimize()?;
// Single dose
println!("Optimal dose: {} mg", result.dose[0]);
// Multiple doses
for (i, &dose) in result.dose.iter().enumerate() {
println!("Dose {}: {} mg", i + 1, dose);
}
// Check which method was used
match result.optimization_method.as_str() {
"posterior" => println!("Patient-specific optimization"),
"uniform" => println!("Population-based optimization"),
_ => {}
}
// Access predictions
for pred in result.preds.iter() {
println!("t={:.1}h: {:.2} mg/L", pred.time(), pred.prediction());
}
// For AUC targets
if let Some(auc_values) = result.auc_predictions {
for (time, auc) in auc_values {
println!("AUC at t={:.1}h: {:.1} mg·h/L", time, auc);
}
}Implementations§
Source§impl BestDoseResult
impl BestDoseResult
Sourcepub fn optimal_subject(&self) -> &Subject
pub fn optimal_subject(&self) -> &Subject
Get the optimized subject
Sourcepub fn doses(&self) -> Vec<f64>
pub fn doses(&self) -> Vec<f64>
Get the dose amounts of the optimized subject
This includes all doses (bolus and infusion) in the order they appear in the optimal subject, and returns their amounts as a vector of f64.
Sourcepub fn predictions(&self) -> &NPPredictions
pub fn predictions(&self) -> &NPPredictions
Get the concentration-time predictions
Sourcepub fn optimization_method(&self) -> OptimalMethod
pub fn optimization_method(&self) -> OptimalMethod
Get the optimization method used
Trait Implementations§
Source§impl Clone for BestDoseResult
impl Clone for BestDoseResult
Source§fn clone(&self) -> BestDoseResult
fn clone(&self) -> BestDoseResult
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BestDoseResult
impl Debug for BestDoseResult
Source§impl<'de> Deserialize<'de> for BestDoseResult
impl<'de> Deserialize<'de> for BestDoseResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BestDoseResult
impl RefUnwindSafe for BestDoseResult
impl Send for BestDoseResult
impl Sync for BestDoseResult
impl Unpin for BestDoseResult
impl UnwindSafe for BestDoseResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.