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
: Thexc
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
: Thendim
property represents the number of dimensions of the ellipsoid search space.helper
: Thehelper
property is an instance of theEllCalc
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 elltsq
: Thetsq
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
impl Ell
Sourcepub fn new_with_matrix(kappa: f64, mq: Array2<f64>, xc: Array1<f64>) -> Ell
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
: Thekappa
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
: Themq
parameter is of typeArray2<f64>
, which represents a 2-dimensional array off64
(floating-point) values. It is used to store the matrixmq
in theEll
object.xc
: The parameterxc
represents the center of the ellipsoid in n-dimensional space. It is an array of lengthndim
, where each element represents the coordinate of the center along a specific dimension.
Returns:
an instance of the Ell
struct.
Sourcepub fn new(val: Array1<f64>, xc: Array1<f64>) -> Ell
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 anArray1<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]);
Sourcepub fn new_with_scalar(val: f64, xc: Array1<f64>) -> Ell
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
: Theval
parameter is a scalar value of typef64
. It represents the value of the scalar component of theEll
object.xc
: The parameterxc
is an array of typeArray1<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 SearchSpace for Ell
The impl SearchSpace for Ell
block is implementing the SearchSpace
trait for the Ell
struct.
impl SearchSpace for Ell
The impl SearchSpace for Ell
block is implementing the SearchSpace
trait for the Ell
struct.
Source§fn tsq(&self) -> f64
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)) -> CutStatuswhere
T: UpdateByCutChoice<Self, ArrayType = Self::ArrayType>,
fn update_bias_cut<T>(&mut self, cut: &(Self::ArrayType, T)) -> CutStatuswhere
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)) -> CutStatuswhere
T: UpdateByCutChoice<Self, ArrayType = Self::ArrayType>,
fn update_central_cut<T>(&mut self, cut: &(Self::ArrayType, T)) -> CutStatuswhere
T: UpdateByCutChoice<Self, ArrayType = Self::ArrayType>,
The update_central_cut
function updates the cut choices using the gradient and beta values.
Arguments:
cut
: Thecut
parameter is a tuple containing two elements. The first element is of typeSelf::ArrayType
, and the second element is of typeT
.
Returns:
The function update_central_cut
returns a value of type CutStatus
.
type ArrayType = ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
fn set_xc(&mut self, x: Self::ArrayType)
Source§impl SearchSpaceQ for Ell
impl SearchSpaceQ for Ell
Source§fn tsq(&self) -> f64
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)) -> CutStatuswhere
T: UpdateByCutChoice<Self, ArrayType = Self::ArrayType>,
fn update_q<T>(&mut self, cut: &(Self::ArrayType, T)) -> CutStatuswhere
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
.