pub struct LSSampler { /* private fields */ }
Expand description
Creates Transformation
samples for a given item.
The samples are drawn from normal distributions with decaying standard deviations.
Each time an improvement is found, the mean of the distributions is shifted to the new best transformation.
Implementations§
Source§impl LSSampler
impl LSSampler
pub fn new( item: &Item, ref_transform: &DTransformation, sd_transl_range: (fsize, fsize), sd_rot_range: (fsize, fsize), ) -> Self
Sourcepub fn from_defaults(
item: &Item,
ref_transform: &DTransformation,
bbox: &AARectangle,
) -> Self
pub fn from_defaults( item: &Item, ref_transform: &DTransformation, bbox: &AARectangle, ) -> Self
Sourcepub fn shift_mean(&mut self, ref_transform: &DTransformation)
pub fn shift_mean(&mut self, ref_transform: &DTransformation)
Shifts the mean of the normal distributions to the given reference transformation.
Sourcepub fn set_stddev(&mut self, stddev_transl: fsize, stddev_rot: fsize)
pub fn set_stddev(&mut self, stddev_transl: fsize, stddev_rot: fsize)
Sets the standard deviation of the normal distributions.
Sourcepub fn decay_stddev(&mut self, progress_pct: fsize)
pub fn decay_stddev(&mut self, progress_pct: fsize)
Adjusts the standard deviation according to the fraction of samples that have passed,
following an exponential decay curve.
progress_pct
is a value in [0, 1].
f(0) = init; f(1) = end; f(x) = init * (end/init)^x;
Sourcepub fn sample(&mut self, rng: &mut impl Rng) -> DTransformation
pub fn sample(&mut self, rng: &mut impl Rng) -> DTransformation
Samples a transformation from the distribution.
Auto Trait Implementations§
impl Freeze for LSSampler
impl RefUnwindSafe for LSSampler
impl Send for LSSampler
impl Sync for LSSampler
impl Unpin for LSSampler
impl UnwindSafe for LSSampler
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> 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