lbf::samplers::ls_sampler

Struct LSSampler

Source
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

Source

pub fn new( item: &Item, ref_transform: &DTransformation, sd_transl_range: (fsize, fsize), sd_rot_range: (fsize, fsize), ) -> Self

Source

pub fn from_defaults( item: &Item, ref_transform: &DTransformation, bbox: &AARectangle, ) -> Self

Creates a new sampler with default standard deviation ranges: SD_TRANSL and SD_ROT.

Source

pub fn shift_mean(&mut self, ref_transform: &DTransformation)

Shifts the mean of the normal distributions to the given reference transformation.

Source

pub fn set_stddev(&mut self, stddev_transl: fsize, stddev_rot: fsize)

Sets the standard deviation of the normal distributions.

Source

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;

Source

pub fn sample(&mut self, rng: &mut impl Rng) -> DTransformation

Samples a transformation from the distribution.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V