Reimplemented from Solver. Definition at line 1059 of file svm.cpp. References Solver::active_size, Solver::G, INF, Solver::is_lower_bound(), Solver::is_upper_bound(), max, min, si, and Solver::y. 01060 { 01061 int nr_free1 = 0,nr_free2 = 0; 01062 double ub1 = INF, ub2 = INF; 01063 double lb1 = -INF, lb2 = -INF; 01064 double sum_free1 = 0, sum_free2 = 0; 01065 01066 for(int i=0;i<active_size;i++) 01067 { 01068 if(y[i]==+1) 01069 { 01070 if(is_lower_bound(i)) 01071 ub1 = min(ub1,G[i]); 01072 else if(is_upper_bound(i)) 01073 lb1 = std::max(lb1,G[i]); 01074 else 01075 { 01076 ++nr_free1; 01077 sum_free1 += G[i]; 01078 } 01079 } 01080 else 01081 { 01082 if(is_lower_bound(i)) 01083 ub2 = min(ub2,G[i]); 01084 else if(is_upper_bound(i)) 01085 lb2 = std::max(lb2,G[i]); 01086 else 01087 { 01088 ++nr_free2; 01089 sum_free2 += G[i]; 01090 } 01091 } 01092 } 01093 01094 double r1,r2; 01095 if(nr_free1 > 0) 01096 r1 = sum_free1/nr_free1; 01097 else 01098 r1 = (ub1+lb1)/2; 01099 01100 if(nr_free2 > 0) 01101 r2 = sum_free2/nr_free2; 01102 else 01103 r2 = (ub2+lb2)/2; 01104 01105 si->r = (r1+r2)/2; 01106 return (r1-r2)/2; 01107 }
Here is the call graph for this function:
|