Struct Ell

Source
pub struct Ell {
    pub no_defer_trick: bool,
    pub mq: Array2<f64>,
    pub xc: Array1<f64>,
    pub kappa: f64,
    pub tsq: f64,
    /* private fields */
}
Expand description

The code defines a struct called “Ell” that represents an ellipsoid search space in the Ellipsoid method.

Ell = {x | (x - xc)^T mq^-1 (x - xc) \le \kappa}

Properties:

  • no_defer_trick: A boolean flag indicating whether the defer trick should be used. The defer trick is a technique used in the Ellipsoid method to improve efficiency by deferring the update of the ellipsoid until a certain condition is met.
  • mq: A matrix representing the shape of the ellipsoid. It is a 2-dimensional array of f64 values.
  • xc: The xc property represents the center of the ellipsoid search space. It is a 1-dimensional array of floating-point numbers.
  • kappa: A scalar value that determines the size of the ellipsoid. A larger value of kappa results in a larger ellipsoid.
  • ndim: The ndim property represents the number of dimensions of the ellipsoid search space.
  • helper: The helper property is an instance of the EllCalc struct, which is used to perform calculations related to the ellipsoid search space. It provides methods for calculating the distance constant (dc), the center constant (cc), and the quadratic constant (q) used in the ell
  • tsq: The tsq property represents the squared Mahalanobis distance threshold of the ellipsoid. It is used to determine whether a point is inside or outside the ellipsoid.

Fields§

§no_defer_trick: bool§mq: Array2<f64>§xc: Array1<f64>§kappa: f64§tsq: f64

Implementations§

Source§

impl Ell

Source

pub fn new_with_matrix(kappa: f64, mq: Array2<f64>, xc: Array1<f64>) -> Ell

The function new_with_matrix constructs a new Ell object with the given parameters.

Arguments:

  • kappa: The kappa parameter is a floating-point number that represents the curvature of the ellipse. It determines the shape of the ellipse, with higher values resulting in a more elongated shape and lower values resulting in a more circular shape.
  • mq: The mq parameter is of type Array2<f64>, which represents a 2-dimensional array of f64 (floating-point) values. It is used to store the matrix mq in the Ell object.
  • xc: The parameter xc represents the center of the ellipsoid in n-dimensional space. It is an array of length ndim, where each element represents the coordinate of the center along a specific dimension.

Returns:

an instance of the Ell struct.

Source

pub fn new(val: Array1<f64>, xc: Array1<f64>) -> Ell

Creates a new Ell.

The function new creates a new Ell object with the given values.

Arguments:

  • val: An array of f64 values representing the diagonal elements of a matrix.
  • xc: xc is an Array1<f64> which represents the center of the ellipse. It contains the x and y coordinates of the center point.

Returns:

The function new returns an instance of the Ell struct.

§Examples
use ellalgo_rs::ell::Ell;
use ndarray::arr1;
let val = arr1(&[1.0, 1.0]);
let xc = arr1(&[0.0, 0.0]);
let ellip = Ell::new(val, xc);
assert_eq!(ellip.kappa, 1.0);
assert_eq!(ellip.mq.shape(), &[2, 2]);
Source

pub fn new_with_scalar(val: f64, xc: Array1<f64>) -> Ell

The function new_with_scalar constructs a new Ell object with a scalar value and a vector.

Arguments:

  • val: The val parameter is a scalar value of type f64. It represents the value of the scalar component of the Ell object.
  • xc: The parameter xc is an array of type Array1<f64>. It represents the center coordinates of the ellipse.

Returns:

an instance of the Ell struct.

§Examples
use ellalgo_rs::ell::Ell;
use ndarray::arr1;
let val = 1.0;
let xc = arr1(&[0.0, 0.0]);
let ellip = Ell::new_with_scalar(val, xc);
assert_eq!(ellip.kappa, 1.0);
assert_eq!(ellip.mq.shape(), &[2, 2]);
assert_eq!(ellip.xc.shape(), &[2]);
assert_eq!(ellip.xc[0], 0.0);
assert_eq!(ellip.xc[1], 0.0);
assert_eq!(ellip.tsq, 0.0);

Trait Implementations§

Source§

impl Clone for Ell

Source§

fn clone(&self) -> Ell

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 Debug for Ell

Source§

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

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

impl SearchSpace for Ell

The impl SearchSpace for Ell block is implementing the SearchSpace trait for the Ell struct.

Source§

fn xc(&self) -> Self::ArrayType

The function xc returns a copy of the xc array.

Source§

fn tsq(&self) -> f64

The tsq function returns the value of the tsq field of the struct.

Returns:

The method tsq is returning a value of type f64.

Source§

fn update_bias_cut<T>(&mut self, cut: &(Self::ArrayType, T)) -> CutStatus
where T: UpdateByCutChoice<Self, ArrayType = Self::ArrayType>,

The update_bias_cut function updates the decision variable based on the given cut.

Arguments:

  • cut: A tuple containing two elements:

Returns:

The update_bias_cut function returns a value of type CutStatus.

Source§

fn update_central_cut<T>(&mut self, cut: &(Self::ArrayType, T)) -> CutStatus
where T: UpdateByCutChoice<Self, ArrayType = Self::ArrayType>,

The update_central_cut function updates the cut choices using the gradient and beta values.

Arguments:

  • cut: The cut parameter is a tuple containing two elements. The first element is of type Self::ArrayType, and the second element is of type T.

Returns:

The function update_central_cut returns a value of type CutStatus.

Source§

type ArrayType = ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Source§

fn set_xc(&mut self, x: Self::ArrayType)

Source§

impl SearchSpaceQ for Ell

Source§

fn xc(&self) -> Self::ArrayType

The function xc returns a copy of the xc array.

Source§

fn tsq(&self) -> f64

The tsq function returns the value of the tsq field of the struct.

Returns:

The method tsq is returning a value of type f64.

Source§

fn update_q<T>(&mut self, cut: &(Self::ArrayType, T)) -> CutStatus
where T: UpdateByCutChoice<Self, ArrayType = Self::ArrayType>,

The update_q function updates the decision variable based on the given cut.

Arguments:

  • cut: A tuple containing two elements:

Returns:

The update_bias_cut function returns a value of type CutStatus.

Source§

type ArrayType = ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Source§

impl UpdateByCutChoice<Ell> for (f64, Option<f64>)

Source§

type ArrayType = ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Source§

fn update_bias_cut_by( &self, ellip: &mut Ell, grad: &Self::ArrayType, ) -> CutStatus

Source§

fn update_central_cut_by( &self, ellip: &mut Ell, grad: &Self::ArrayType, ) -> CutStatus

Source§

fn update_q_by(&self, ellip: &mut Ell, grad: &Self::ArrayType) -> CutStatus

Source§

impl UpdateByCutChoice<Ell> for f64

Source§

type ArrayType = ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Source§

fn update_bias_cut_by( &self, ellip: &mut Ell, grad: &Self::ArrayType, ) -> CutStatus

Source§

fn update_central_cut_by( &self, ellip: &mut Ell, grad: &Self::ArrayType, ) -> CutStatus

Source§

fn update_q_by(&self, ellip: &mut Ell, grad: &Self::ArrayType) -> CutStatus

Auto Trait Implementations§

§

impl Freeze for Ell

§

impl RefUnwindSafe for Ell

§

impl Send for Ell

§

impl Sync for Ell

§

impl Unpin for Ell

§

impl UnwindSafe for Ell

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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 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.