SolverState

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

Source

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

Source

pub fn nactive(&self) -> usize

Return number of active variables

Source

pub fn ntotal(&self) -> usize

Return number of total variables

Source

pub fn target(&self, idx: usize) -> F

Return target as positive/negative indicator

Source

pub fn bound(&self, idx: usize) -> F

Return the k-th bound

Source

pub fn swap(&mut self, i: usize, j: usize)

Swap two variables

Source

pub fn update(&mut self, working_set: (usize, usize))

Source

pub fn max_violating_pair(&self) -> ((F, isize), (F, isize))

Return max and min gradients of free variables

Source

pub fn max_violating_pair_nu( &self, ) -> ((F, isize), (F, isize), (F, isize), (F, isize))

Source

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
Source

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
Source

pub fn should_shrunk(&self, i: usize, gmax1: F, gmax2: F) -> bool

Source

pub fn should_shrunk_nu( &self, i: usize, gmax1: F, gmax2: F, gmax3: F, gmax4: F, ) -> bool

Source

pub fn do_shrinking(&mut self)

Source

pub fn do_shrinking_nu(&mut self)

Source

pub fn calculate_rho(&mut self) -> F

Source

pub fn calculate_rho_nu(&mut self) -> F

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<'a, F: Debug + Float, K: Debug + Permutable<F>> Debug for SolverState<'a, F, K>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, F: PartialEq + Float, K: PartialEq + Permutable<F>> PartialEq for SolverState<'a, F, K>

Source§

fn eq(&self, other: &SolverState<'a, F, K>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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>
where F: Freeze, K: Freeze,

§

impl<'a, F, K> RefUnwindSafe for SolverState<'a, F, K>

§

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>

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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V