Package elki.svm.solver
Class Solver
- java.lang.Object
-
- elki.svm.solver.Solver
-
- Direct Known Subclasses:
NuSolver
public class Solver extends java.lang.ObjectSMO solver for support vector machines, derived from libSVM.An SMO algorithm in Fan et al., JMLR 6(2005), p. 1889--1918
Solves:
\[\min 0.5(\alpha^T Q \alpha) + p^T \alpha\]
\[y^T \alpha = \delta\] \[y_i = \pm 1\] \[0 ≤ alpha_i ≤ Cp \text{for} y_i = 1\] \[0 ≤ alpha_i ≤ Cn \text{for} y_i = -1\]
Given:
Q, p, y, Cp, Cn, and an initial feasible point \(\alpha\)
l is the size of vectors and matrices
eps is the stopping tolerance
solution will be put in \(\alpha\), objective value will be put in obj- Since:
- 0.8.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSolver.SolutionInfo
-
Field Summary
Fields Modifier and Type Field Description (package private) int[]active_set(package private) intactive_size(package private) double[]alpha(package private) byte[]alpha_status(package private) doubleCn(package private) doubleCp(package private) doubleeps(package private) static byteFREE(package private) double[]G(package private) double[]G_bar(package private) intlprivate static LoggingLOG(package private) static byteLOWER_BOUND(package private) double[]p(package private) QMatrixQ(package private) float[]Q_i(package private) float[]Q_j(package private) booleanunshrink(package private) static byteUPPER_BOUND(package private) byte[]y
-
Constructor Summary
Constructors Constructor Description Solver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanbe_shrunk(int i, double Gmax1, double Gmax2)(package private) Solver.SolutionInfobuildSolutionInfo(int l, double Cp, double Cn)protected doublecalculate_obj()(package private) doublecalculate_rho()(package private) voiddo_shrinking()(package private) doubleget_C(int i)protected voidinitializeActiveSet()Initialize the active set.protected voidinitializeAlpha()Initialize the alpha values.voidinitializeGradient()(package private) booleanis_free(int i)(package private) booleanis_lower_bound(int i)(package private) booleanis_upper_bound(int i)protected doublemaxViolating(int[] working_set)protected doubleminViolating(int[] working_set, double Gi)protected static doublenonzero(double d)(package private) voidreconstruct_gradient()(package private) booleanselect_working_set(int[] working_set)Solver.SolutionInfosolve(int l, QMatrix Q, double[] p_, byte[] y_, double[] alpha_, double Cp, double Cn, double eps, boolean shrinking)(package private) voidswap_index(int i, int j)(package private) voidupdate_alpha_status(int i)private voidupdate_G(int i, int j, double old_alpha_i, double old_alpha_j)private voidupdate_G_bar(double C_i, float[] Q_i)
-
-
-
Field Detail
-
LOG
private static final Logging LOG
-
active_size
int active_size
-
y
byte[] y
-
G
double[] G
-
LOWER_BOUND
static final byte LOWER_BOUND
- See Also:
- Constant Field Values
-
UPPER_BOUND
static final byte UPPER_BOUND
- See Also:
- Constant Field Values
-
FREE
static final byte FREE
- See Also:
- Constant Field Values
-
alpha_status
byte[] alpha_status
-
alpha
double[] alpha
-
Q
QMatrix Q
-
eps
double eps
-
Cp
double Cp
-
Cn
double Cn
-
p
double[] p
-
active_set
int[] active_set
-
G_bar
double[] G_bar
-
Q_i
float[] Q_i
-
Q_j
float[] Q_j
-
l
int l
-
unshrink
boolean unshrink
-
-
Method Detail
-
get_C
double get_C(int i)
-
update_alpha_status
void update_alpha_status(int i)
-
is_upper_bound
boolean is_upper_bound(int i)
-
is_lower_bound
boolean is_lower_bound(int i)
-
is_free
boolean is_free(int i)
-
swap_index
void swap_index(int i, int j)
-
reconstruct_gradient
void reconstruct_gradient()
-
solve
public Solver.SolutionInfo solve(int l, QMatrix Q, double[] p_, byte[] y_, double[] alpha_, double Cp, double Cn, double eps, boolean shrinking)
-
buildSolutionInfo
Solver.SolutionInfo buildSolutionInfo(int l, double Cp, double Cn)
-
initializeAlpha
protected void initializeAlpha()
Initialize the alpha values.
-
initializeActiveSet
protected void initializeActiveSet()
Initialize the active set.
-
update_G
private void update_G(int i, int j, double old_alpha_i, double old_alpha_j)
-
update_G_bar
private void update_G_bar(double C_i, float[] Q_i)
-
initializeGradient
public void initializeGradient()
-
calculate_obj
protected double calculate_obj()
-
nonzero
protected static double nonzero(double d)
-
select_working_set
boolean select_working_set(int[] working_set)
-
maxViolating
protected double maxViolating(int[] working_set)
-
minViolating
protected double minViolating(int[] working_set, double Gi)
-
do_shrinking
void do_shrinking()
-
be_shrunk
private boolean be_shrunk(int i, double Gmax1, double Gmax2)
-
calculate_rho
double calculate_rho()
-
-