pub struct Epsilon { /* private fields */ }Expand description
A rational approximation tolerance ε = num / den >= 0, used as the
factor 1 + ε.
Cost has no division or fractional scaling, only the saturating
integer product Cost::saturating_times. A rational ε lets the
searches test x <= (1 + ε) · y exactly as den · x <= (den + num) · y.
§Overflow
The products are saturating. When (den + num) · y saturates, the test
falls back to x <= y, which is the exact (ε = 0) answer. The searches
then prune or merge less but keep their guarantees. Keep den + num
small relative to the headroom of the cost type to get the full benefit.
§Examples
use multiobjective_search::Epsilon;
let ten_percent = Epsilon::new(1, 10);
assert!(ten_percent.within(110_u32, 100));
assert!(!ten_percent.within(111_u32, 100));
assert!(Epsilon::ZERO.within(100_u32, 100));
assert!(!Epsilon::ZERO.within(101_u32, 100));Implementations§
Trait Implementations§
impl Copy for Epsilon
impl Eq for Epsilon
impl StructuralPartialEq for Epsilon
Auto Trait Implementations§
impl Forget for Epsilon
impl Freeze for Epsilon
impl Move for Epsilon
impl RefUnwindSafe for Epsilon
impl Send for Epsilon
impl Sync for Epsilon
impl Unpin for Epsilon
impl UnsafeUnpin for Epsilon
impl UnwindSafe for Epsilon
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