pub enum Stop {
MaxTrials(u64),
MinTrials(u64),
MinErrors {
metric: String,
errors: u64,
},
Precision {
metric: String,
relative: f64,
confidence: f64,
},
MaxTime(Duration),
Any(Vec<Stop>),
All(Vec<Stop>),
}Expand description
A stopping rule.
Variants§
MaxTrials(u64)
At most this many trials: met once they have run (a cap, printed max_trials(n)).
MinTrials(u64)
Never before this many trials (use with Stop::and; met once they have run,
as Stop::MaxTrials, but printed min_trials(n)).
MinErrors
At least errors errors of the error rate metric (never met by a mean).
Precision
Relative half-width of the confidence interval of metric at most relative.
Fields
MaxTime(Duration)
At least this much wall time on the condition.
Any(Vec<Stop>)
Any of the rules.
All(Vec<Stop>)
All of the rules.
Implementations§
Source§impl Stop
impl Stop
Sourcepub fn max_trials(n: u64) -> Stop
pub fn max_trials(n: u64) -> Stop
Stop after n trials.
Sourcepub fn min_trials(n: u64) -> Stop
pub fn min_trials(n: u64) -> Stop
Never stop before n trials.
Sourcepub fn min_errors(metric: &str, errors: u64) -> Stop
pub fn min_errors(metric: &str, errors: u64) -> Stop
Stop after errors errors of the error rate metric.
Sourcepub fn precision(metric: &str, relative: f64) -> Stop
pub fn precision(metric: &str, relative: f64) -> Stop
Stop when the 95 % interval of metric is within ±relative of its value.
Sourcepub fn precision_at(metric: &str, relative: f64, confidence: f64) -> Stop
pub fn precision_at(metric: &str, relative: f64, confidence: f64) -> Stop
Stop when the interval of level confidence of metric is within ±relative of
its value (the runner refuses a level outside $(0, 1)$, see check_confidence).
§Examples
use comnum_sim::stopping::Stop;
assert_eq!(Stop::precision_at("snr_db", 0.01, 0.99).to_string(), "precision(snr_db) ≤ 0.01 at 0.99");Sourcepub fn is_bounded(&self) -> bool
pub fn is_bounded(&self) -> bool
Whether the rule can stop at all (a rule made only of lower bounds would run forever).
Sourcepub fn trial_limit(&self) -> Option<u64>
pub fn trial_limit(&self) -> Option<u64>
The number of trials at which the rule is met whatever the metrics and the
time, if there is one: n for Stop::max_trials and Stop::min_trials, the
smallest bound of an Stop::or, the largest of an Stop::and whose rules
all have one. The runner ends its last batch there.
§Examples
use comnum_sim::stopping::Stop;
assert_eq!(Stop::min_errors("ber", 100).or(Stop::max_trials(1000)).trial_limit(), Some(1000));
assert_eq!(Stop::max_trials(1000).and(Stop::min_trials(10)).trial_limit(), Some(1000));
assert_eq!(Stop::min_errors("ber", 100).and(Stop::max_trials(1000)).trial_limit(), None);Sourcepub fn check_confidences(&self) -> Result<()>
pub fn check_confidences(&self) -> Result<()>
Check the confidence levels of the precision targets of the rule
(check_confidence).
§Errors
Error::Config for a level outside $(0, 1)$.
Sourcepub fn check_metrics(&self, record: &Record) -> Result<()>
pub fn check_metrics(&self, record: &Record) -> Result<()>
Check that every target of the rule can be met by the metrics of record (the
record of a first batch of trials).
§Errors
Error::Config for a target on a metric that record does not hold (the
message names the recorded ones), or Stop::min_errors on a mean.
§Examples
use comnum_sim::stopping::Stop;
use comnum_sim::scenario::Record;
let mut rec = Record::new();
rec.errors("ber", 3, 1000);
rec.value("snr_db", 9.5);
assert!(Stop::min_errors("ber", 100).or(Stop::max_trials(10)).check_metrics(&rec).is_ok());
let e = Stop::min_errors("bler", 100).or(Stop::max_trials(10)).check_metrics(&rec).unwrap_err();
assert!(e.to_string().contains("bler") && e.to_string().contains("ber, snr_db"));
assert!(Stop::min_errors("snr_db", 100).or(Stop::max_trials(10)).check_metrics(&rec).is_err());Trait Implementations§
impl StructuralPartialEq for Stop
Auto Trait Implementations§
impl Forget for Stop
impl Freeze for Stop
impl RefUnwindSafe for Stop
impl Send for Stop
impl Sync for Stop
impl Unpin for Stop
impl UnsafeUnpin for Stop
impl UnwindSafe for Stop
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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