Struct EllCalc

Source
pub struct EllCalc {
    pub helper: EllCalcCore,
    pub use_parallel_cut: bool,
    /* private fields */
}
Expand description

The EllCalc struct represents an ellipsoid search space in Rust.

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

Properties:

  • n_f: The n_f property is a floating-point number that represents the dimensionality of the search space. It indicates the number of variables or dimensions in the ellipsoid search space.
  • helper: The helper property is of type EllCalcCore and is used to perform calculations related to the ellipsoid search space. It is a separate struct that contains the necessary methods and data for these calculations.
  • use_parallel_cut: A boolean flag indicating whether to use parallel cut or not.

Fields§

§helper: EllCalcCore§use_parallel_cut: bool

Implementations§

Source§

impl EllCalc

Source

pub fn new(n: usize) -> EllCalc

The new function constructs a new EllCalc object with a given value for n_f and sets the use_parallel_cut flag to true.

Arguments:

  • n_f: The parameter n_f is a floating-point number that is used to initialize the EllCalc struct.

Returns:

The new function is returning an instance of the EllCalc struct.

§Examples:
use ellalgo_rs::ell_calc::EllCalc;
let ell_calc = EllCalc::new(4);
assert!(ell_calc.use_parallel_cut);
Source

pub fn calc_single_or_parallel_bias_cut( &self, beta: &(f64, Option<f64>), tsq: f64, ) -> (CutStatus, (f64, f64, f64))

The function calculates the updating of an ellipsoid with a single or parallel-cut.

Arguments:

  • beta: The beta parameter is a tuple containing two values: beta0 and beta1_opt. beta0 is of type f64 and beta1_opt is an optional value of type Option<f64>.
  • tsq: The tsq parameter is a reference to a f64 value.
Source

pub fn calc_single_or_parallel_central_cut( &self, beta: &(f64, Option<f64>), tsq: f64, ) -> (CutStatus, (f64, f64, f64))

The function calculates the updating of an ellipsoid with a single or parallel-cut (one of them is central-cut).

Arguments:

  • beta: The beta parameter is a tuple containing two values: f64 and Option<f64>. The first value, denoted as _b0, is of type f64. The second value, beta1_opt, is of type Option<f64>.
  • tsq: The tsq parameter is a reference to a f64 value.
Source

pub fn calc_single_or_parallel_q( &self, beta: &(f64, Option<f64>), tsq: f64, ) -> (CutStatus, (f64, f64, f64))

The function calculates the updating of an ellipsoid with a single or parallel-cut (discrete version).

Arguments:

  • beta: The beta parameter is a tuple containing two values: beta0 and beta1_opt. beta0 is of type f64 and beta1_opt is an optional value of type Option<f64>.
  • tsq: The tsq parameter is a reference to a f64 value.
Source

pub fn calc_parallel_bias_cut( &self, beta0: f64, beta1: f64, tsq: f64, ) -> (CutStatus, (f64, f64, f64))

Parallel Deep Cut

§Examples:
use approx_eq::assert_approx_eq;
use ellalgo_rs::ell_calc::EllCalc;
use ellalgo_rs::cutting_plane::CutStatus;

let ell_calc = EllCalc::new(4);
let (status, _result) = ell_calc.calc_parallel_bias_cut(0.07, 0.03, 0.01);
assert_eq!(status, CutStatus::NoSoln);

let (status, (rho, sigma, delta)) = ell_calc.calc_parallel_bias_cut(0.0, 0.05, 0.01);
assert_eq!(status, CutStatus::Success);
assert_approx_eq!(sigma, 0.8);
assert_approx_eq!(rho, 0.02);
assert_approx_eq!(delta, 1.2);

let (status, (rho, sigma, delta)) = ell_calc.calc_parallel_bias_cut(0.05, 0.11, 0.01);
assert_eq!(status, CutStatus::Success);
assert_approx_eq!(sigma, 0.8);
assert_approx_eq!(rho, 0.06);
assert_approx_eq!(delta, 0.8);

let (status, (rho, sigma, delta)) = ell_calc.calc_parallel_bias_cut(0.01, 0.04, 0.01);
assert_eq!(status, CutStatus::Success);
assert_approx_eq!(sigma, 0.928);
assert_approx_eq!(rho, 0.0232);
assert_approx_eq!(delta, 1.232);
Source

pub fn calc_parallel_q( &self, beta0: f64, beta1: f64, tsq: f64, ) -> (CutStatus, (f64, f64, f64))

Discrete Parallel Deep Cut

§Examples:
use approx_eq::assert_approx_eq;
use ellalgo_rs::ell_calc::EllCalc;
use ellalgo_rs::cutting_plane::CutStatus;

let ell_calc = EllCalc::new(4);
let (status, _result) = ell_calc.calc_parallel_q(-0.07, 0.07, 0.01);
assert_eq!(status, CutStatus::NoEffect);

let (status, _result) = ell_calc.calc_parallel_q(-0.04, 0.0625, 0.01);
assert_eq!(status, CutStatus::NoEffect);
Source

pub fn calc_parallel_central_cut( &self, beta1: f64, tsq: f64, ) -> (CutStatus, (f64, f64, f64))

Parallel Central Cut

§Examples:
use approx_eq::assert_approx_eq;
use ellalgo_rs::ell_calc::EllCalc;
use ellalgo_rs::cutting_plane::CutStatus;

let ell_calc = EllCalc::new(4);
let (status, (rho, sigma, delta)) = ell_calc.calc_parallel_central_cut(0.11, 0.01);
assert_eq!(status, CutStatus::Success);
assert_approx_eq!(sigma, 0.4);
assert_approx_eq!(rho, 0.02);
assert_approx_eq!(delta, 16.0 / 15.0);

let (status, (rho, sigma, delta)) = ell_calc.calc_parallel_central_cut(0.05, 0.01);
assert_eq!(status, CutStatus::Success);
assert_approx_eq!(sigma, 0.8);
assert_approx_eq!(rho, 0.02);
assert_approx_eq!(delta, 1.2);
Source

pub fn calc_bias_cut(&self, beta: f64, tsq: f64) -> (CutStatus, (f64, f64, f64))

Deep Cut

§Examples:
use approx_eq::assert_approx_eq;
use ellalgo_rs::ell_calc::EllCalc;
use ellalgo_rs::cutting_plane::CutStatus;

let ell_calc = EllCalc::new(4);
let (status, _result) = ell_calc.calc_bias_cut(0.11, 0.01);
assert_eq!(status, CutStatus::NoSoln);
let (status, _result) = ell_calc.calc_bias_cut(0.0, 0.01);
assert_eq!(status, CutStatus::Success);

let (status, (rho, sigma, delta)) = ell_calc.calc_bias_cut(0.05, 0.01);
assert_eq!(status, CutStatus::Success);
assert_approx_eq!(sigma, 0.8);
assert_approx_eq!(rho, 0.06);
assert_approx_eq!(delta, 0.8);
Source

pub fn calc_bias_cut_q( &self, beta: f64, tsq: f64, ) -> (CutStatus, (f64, f64, f64))

Discrete Deep Cut

§Examples:
use approx_eq::assert_approx_eq;
use ellalgo_rs::ell_calc::EllCalc;
use ellalgo_rs::cutting_plane::CutStatus;

let ell_calc = EllCalc::new(4);
let (status, _result) = ell_calc.calc_bias_cut_q(-0.05, 0.01);
assert_eq!(status, CutStatus::NoEffect);
Source

pub fn calc_central_cut(&self, tsq: f64) -> (CutStatus, (f64, f64, f64))

Central Cut

§Examples:
use approx_eq::assert_approx_eq;
use ellalgo_rs::ell_calc::EllCalc;
use ellalgo_rs::cutting_plane::CutStatus;

let ell_calc = EllCalc::new(4);
let (status, (rho, sigma, delta)) = ell_calc.calc_central_cut(0.01);

assert_eq!(status, CutStatus::Success);
assert_approx_eq!(sigma, 0.4);
assert_approx_eq!(rho, 0.02);
assert_approx_eq!(delta, 16.0 / 15.0);

Trait Implementations§

Source§

impl Clone for EllCalc

Source§

fn clone(&self) -> EllCalc

Returns a duplicate 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 EllCalc

Source§

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

Formats the value using the given formatter. Read more

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