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§
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 copy 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 more