pub struct Options {
    pub exponent_coefficient: f64,
    pub angle_coefficient: f64,
    pub num_lockon: usize,
    pub samples_per_rotation: f64,
    pub range: Range<f64>,
    pub turns: f64,
}
Available on crate feature regression only.
Expand description

Options for the spiral.

This also implements most estimator traits. These all use the manhattan distance as their fitness function. The estimators have O(n) runtime performance and O(1) size performance.

Polynomial estimator only supports degrees 1 & 2.

See module-level documentation for more info about concepts.

The Self::range limit samples on the spiral. This causes a upper limit for coefficients and a lower “precision” cutoff. You can increase Self::exponent_coefficient if you know your data will have large numbers. The algorithm will increase the size of the spiral of a line outside the spiral is found.

Use a graphing tool (e.g. Desmos) and plot r=ae^(kθ). a is Self::exponent_coefficient. k is Self::angle_coefficient.

To keep the same “size” of the spiral, you have to multiply both ends of Self::range with the factor of Self::angle_coefficient.

Performance

The methods are O(1)*O(fitness_function) where O(fitness_function) is the time complexity of your fitness_function. That’s often O(n) as you’d probably in some way sum up the points relative to the model.

The following options affect the performance as follows (roughly, no coefficients) O(num_lockon * samples_per_rotation * range.length).

Keep in mind you should probably not lower Self::angle_coefficient bellow 0.15 if you don’t increase the Self::range.

Fields§

§exponent_coefficient: f64

The initial scale of the spiral.

This gets adjusted when locking on.

§angle_coefficient: f64

The “density” of the spiral.

§num_lockon: usize

How many lockons we are allowed to do. This is a max value.

§samples_per_rotation: f64

The count of samples per each rotation in the spiral.

§range: Range<f64>

The range of angles to test.

§turns: f64

The turns of the 3d spiral when using three_variable_optimization. Frequency of turns per sphere. Is unnecessary to turn up when Self::samples_per_rotation is low.

Implementations§

source§

impl Options

source

pub fn new(level: u8) -> Self

Create a new set of options with good defaults.

level is allowed to be in the range [1..=9]. Higher values are more “precise” - they take longer but are also way (especially level>4) more likely to return good results.

Expect a 2-4x increase in runtime per increment of level.

Panics

Panics if !(1..=9).contains(level).

Trait Implementations§

source§

impl Clone for Options

source§

fn clone(&self) -> Options

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CosecantEstimator for Options

source§

fn model_cosecant( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64 ) -> CosecantCoefficients

Model the CosecantCoefficients from predictors and outcomes. Read more
source§

fn boxed_cosecant(self) -> Box<dyn CosecantEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl CosineEstimator for Options

source§

fn model_cosine( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64 ) -> CosineCoefficients

Model the CosineCoefficients from predictors and outcomes. Read more
source§

fn boxed_cosine(self) -> Box<dyn CosineEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl CotangentEstimator for Options

source§

fn model_cotangent( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64 ) -> CotangentCoefficients

Model the CotangentCoefficients from predictors and outcomes. Read more
source§

fn boxed_cotangent(self) -> Box<dyn CotangentEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl Debug for Options

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Options

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl ExponentialEstimator for Options

source§

fn model_exponential( &self, predictors: &[f64], outcomes: &[f64] ) -> ExponentialCoefficients

Model the ExponentialCoefficients from predictors and outcomes. Read more
source§

fn boxed_exponential(self) -> Box<dyn ExponentialEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl LinearEstimator for Options

source§

fn model_linear( &self, predictors: &[f64], outcomes: &[f64] ) -> LinearCoefficients

Model the LinearCoefficients from predictors and outcomes. Read more
source§

fn boxed_linear(self) -> Box<dyn LinearEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl LogisticEstimator for Options

source§

fn model_logistic( &self, predictors: &[f64], outcomes: &[f64] ) -> LogisticCoefficients

Model the LogisticCoefficients from predictors and outcomes. Read more
source§

fn boxed_logistic(self) -> Box<dyn LogisticEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl PartialEq<Options> for Options

source§

fn eq(&self, other: &Options) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PolynomialEstimator for Options

source§

fn model_polynomial( &self, predictors: &[f64], outcomes: &[f64], degree: usize ) -> PolynomialCoefficients

Model the PolynomialCoefficients from predictors and outcomes. Also takes a degree of the target polynomial. Some estimators may panic when degree is out of their range. Read more
source§

fn boxed_polynomial(self) -> Box<dyn PolynomialEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl PowerEstimator for Options

source§

fn model_power(&self, predictors: &[f64], outcomes: &[f64]) -> PowerCoefficients

Model the PowerCoefficients from predictors and outcomes. Read more
source§

fn boxed_power(self) -> Box<dyn PowerEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl SecantEstimator for Options

source§

fn model_secant( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64 ) -> SecantCoefficients

Model the SecantCoefficients from predictors and outcomes. Read more
source§

fn boxed_sesecant(self) -> Box<dyn SecantEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl SineEstimator for Options

source§

fn model_sine( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64 ) -> SineCoefficients

Model the SineCoefficients from predictors and outcomes. Read more
source§

fn boxed_sine(self) -> Box<dyn SineEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl TangentEstimator for Options

source§

fn model_tangent( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64 ) -> TangentCoefficients

Model the TangentCoefficients from predictors and outcomes. Read more
source§

fn boxed_tangent(self) -> Box<dyn TangentEstimator>where Self: Sized + 'static,

Put this estimator in a box. This is useful for conditionally choosing different estimators.
source§

impl StructuralPartialEq for Options

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dstwhere T: Cast<Dst>,

Casts the value.
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dstwhere Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

OverflowingCasts the value.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

UnwrappedCasts the value.
§

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

§

fn vzip(self) -> V

source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

WrappingCasts the value.
source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,