pub struct SolverState<'a, F: Float, K: Permutable<F>> { /* private fields */ }
Expand description
Current state of the SMO solver
We are solving the dual problem with linear constraints min_a f(a), s.t. y^Ta = d, 0 <= a_t < C, t = 1, …, l where f(a) = a^T Q a / 2 + p^T a
Implementations§
Source§impl<'a, F: Float, K: 'a + Permutable<F>> SolverState<'a, F, K>
impl<'a, F: Float, K: 'a + Permutable<F>> SolverState<'a, F, K>
Sourcepub fn new(
alpha: Vec<F>,
p: Vec<F>,
targets: Vec<bool>,
dataset: ArrayView2<'a, F>,
kernel: K,
bounds: Vec<F>,
params: SolverParams<F>,
nu_constraint: bool,
) -> SolverState<'a, F, K>
pub fn new( alpha: Vec<F>, p: Vec<F>, targets: Vec<bool>, dataset: ArrayView2<'a, F>, kernel: K, bounds: Vec<F>, params: SolverParams<F>, nu_constraint: bool, ) -> SolverState<'a, F, K>
Initialize a solver state
This is bounded by the lifetime of the kernel matrix, because it can quite large
pub fn update(&mut self, working_set: (usize, usize))
Sourcepub fn max_violating_pair(&self) -> ((F, isize), (F, isize))
pub fn max_violating_pair(&self) -> ((F, isize), (F, isize))
Return max and min gradients of free variables
pub fn max_violating_pair_nu( &self, ) -> ((F, isize), (F, isize), (F, isize), (F, isize))
Sourcepub fn select_working_set(&self) -> (usize, usize, bool)
pub fn select_working_set(&self) -> (usize, usize, bool)
Select optimal working set
In each optimization step two variables are selected and then optimized. The indices are selected such that:
- i: maximizes -y_i * grad(f)_i, i in I_up(\alpha)
- j: minimizes the decrease of the objective value
Sourcepub fn select_working_set_nu(&self) -> (usize, usize, bool)
pub fn select_working_set_nu(&self) -> (usize, usize, bool)
Select optimal working set
In each optimization step two variables are selected and then optimized. The indices are selected such that:
- i: maximizes -y_i * grad(f)_i, i in I_up(\alpha)
- j: minimizes the decrease of the objective value
pub fn should_shrunk(&self, i: usize, gmax1: F, gmax2: F) -> bool
pub fn should_shrunk_nu( &self, i: usize, gmax1: F, gmax2: F, gmax3: F, gmax4: F, ) -> bool
pub fn do_shrinking(&mut self)
pub fn do_shrinking_nu(&mut self)
pub fn calculate_rho(&mut self) -> F
pub fn calculate_rho_nu(&mut self) -> F
pub fn solve(self) -> Svm<F, F>
Trait Implementations§
Source§impl<'a, F: Clone + Float, K: Clone + Permutable<F>> Clone for SolverState<'a, F, K>
impl<'a, F: Clone + Float, K: Clone + Permutable<F>> Clone for SolverState<'a, F, K>
Source§fn clone(&self) -> SolverState<'a, F, K>
fn clone(&self) -> SolverState<'a, F, K>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a, F: PartialEq + Float, K: PartialEq + Permutable<F>> PartialEq for SolverState<'a, F, K>
impl<'a, F: PartialEq + Float, K: PartialEq + Permutable<F>> PartialEq for SolverState<'a, F, K>
impl<'a, F: Float, K: Permutable<F>> StructuralPartialEq for SolverState<'a, F, K>
Auto Trait Implementations§
impl<'a, F, K> Freeze for SolverState<'a, F, K>
impl<'a, F, K> RefUnwindSafe for SolverState<'a, F, K>where
F: RefUnwindSafe,
K: RefUnwindSafe,
impl<'a, F, K> Send for SolverState<'a, F, K>
impl<'a, F, K> Sync for SolverState<'a, F, K>where
K: Sync,
impl<'a, F, K> Unpin for SolverState<'a, F, K>where
K: Unpin,
impl<'a, F, K> UnwindSafe for SolverState<'a, F, K>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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