pub struct Limits {
pub max_evaluations: Option<u64>,
pub max_generations: Option<u64>,
pub target_cost: Option<f64>,
}Expand description
Simple limits on evaluations, generations and the target cost.
Limits::DEFAULT allows 10^6 evaluations, which keeps every run finite. Any
FnMut(&Stats) -> bool is a Budget too, for example to add a wall-clock deadline in a
std crate (annotate the argument type: |stats: &Stats| ...).
use evolutionary_planning::{Budget, Limits, Stats};
let mut limits = Limits { target_cost: Some(1e-9), ..Limits::evaluations(500) };
let stats = Stats { evaluations: 500, ..Stats::default() };
assert!(limits.exhausted(&stats));Fields§
§max_evaluations: Option<u64>Stop once this many evaluations have been performed. None is unbounded.
max_generations: Option<u64>Stop once this many generations have completed. None is unbounded.
target_cost: Option<f64>Stop once the best cost is at or below this value. None never stops on quality.
Implementations§
Source§impl Limits
impl Limits
Sourcepub const fn unlimited() -> Self
pub const fn unlimited() -> Self
No limits at all: the run ends only through an algorithm’s own convergence test.
Sourcepub const fn evaluations(max: u64) -> Self
pub const fn evaluations(max: u64) -> Self
Stops after max evaluations, with no other limit.
Sourcepub const fn generations(max: u64) -> Self
pub const fn generations(max: u64) -> Self
Stops after max generations, with no other limit.
Sourcepub const fn with_target(self, target: f64) -> Self
pub const fn with_target(self, target: f64) -> Self
Adds a target cost to these limits.
Trait Implementations§
impl Copy for Limits
impl StructuralPartialEq for Limits
Auto Trait Implementations§
impl Forget for Limits
impl Freeze for Limits
impl Move for Limits
impl RefUnwindSafe for Limits
impl Send for Limits
impl Sync for Limits
impl Unpin for Limits
impl UnsafeUnpin for Limits
impl UnwindSafe for Limits
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