From 51b8ff441097778ec95db24596b99db4cf9f1ba4 Mon Sep 17 00:00:00 2001 From: rofu Date: Sun, 20 Dec 2009 05:13:18 +0000 Subject: [PATCH] Fix the bug of calculation of upper bound in the be_shrunk() by 1. add a new parameter for the instance index 2. change C[yi] to C[prob->y[i]] --- linear.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linear.cpp b/linear.cpp index 344616c..c06ad3e 100644 --- a/linear.cpp +++ b/linear.cpp @@ -399,7 +399,7 @@ class Solver_MCSVM_CS void Solve(double *w); private: void solve_sub_problem(double A_i, int yi, double C_yi, int active_i, double *alpha_new); - bool be_shrunk(int m, int yi, double alpha_i, double minG); + bool be_shrunk(int i, int m, int yi, double alpha_i, double minG); double *B, *C, *G; int w_size, l; int nr_class; @@ -461,11 +461,11 @@ void Solver_MCSVM_CS::solve_sub_problem(double A_i, int yi, double C_yi, int act delete[] D; } -bool Solver_MCSVM_CS::be_shrunk(int m, int yi, double alpha_i, double minG) +bool Solver_MCSVM_CS::be_shrunk(int i, int m, int yi, double alpha_i, double minG) { double bound = 0; if(m == yi) - bound = C[yi]; + bound = C[prob->y[i]]; if(alpha_i == bound && G[m] < minG) return true; return false; @@ -554,12 +554,12 @@ void Solver_MCSVM_CS::Solve(double *w) for(m=0;mm) { - if(!be_shrunk(active_size_i[i], y_index[i], + if(!be_shrunk(i, active_size_i[i], y_index[i], alpha_i[alpha_index_i[active_size_i[i]]], minG)) { swap(alpha_index_i[m], alpha_index_i[active_size_i[i]]); -- 2.50.1