Struct linfa_svm::solver_smo::SolverState
source · [−]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
sourceimpl<'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
sourceimpl<'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>
sourcefn clone(&self) -> SolverState<'a, F, K>
fn clone(&self) -> SolverState<'a, F, K>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a, F: PartialEq + Float, K: PartialEq + Permutable<F>> PartialEq<SolverState<'a, F, K>> for SolverState<'a, F, K>
impl<'a, F: PartialEq + Float, K: PartialEq + Permutable<F>> PartialEq<SolverState<'a, F, K>> for SolverState<'a, F, K>
sourcefn eq(&self, other: &SolverState<'a, F, K>) -> bool
fn eq(&self, other: &SolverState<'a, F, K>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SolverState<'a, F, K>) -> bool
fn ne(&self, other: &SolverState<'a, F, K>) -> bool
This method tests for !=
.
impl<'a, F: Float, K: Permutable<F>> StructuralPartialEq for SolverState<'a, F, K>
Auto Trait Implementations
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> where
K: Send + Sync,
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> where
F: UnwindSafe + RefUnwindSafe,
K: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more