Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

void Solver::do_shrinking (  )  [protected, virtual]

Reimplemented in Solver_NU.

Definition at line 764 of file svm.cpp.

References active_size, eps, G, is_lower_bound(), is_upper_bound(), l, reconstruct_gradient(), select_working_set(), swap_index(), unshrinked, and y.

Referenced by Solve().

00765 {
00766         int i,j,k;
00767         if(select_working_set(i,j)!=0) return;
00768         double Gm1 = -y[j]*G[j];
00769         double Gm2 = y[i]*G[i];
00770 
00771         // shrink
00772         
00773         for(k=0;k<active_size;k++)
00774         {
00775                 if(is_lower_bound(k))
00776                 {
00777                         if(y[k]==+1)
00778                         {
00779                                 if(-G[k] >= Gm1) continue;
00780                         }
00781                         else    if(-G[k] >= Gm2) continue;
00782                 }
00783                 else if(is_upper_bound(k))
00784                 {
00785                         if(y[k]==+1)
00786                         {
00787                                 if(G[k] >= Gm2) continue;
00788                         }
00789                         else    if(G[k] >= Gm1) continue;
00790                 }
00791                 else continue;
00792 
00793                 --active_size;
00794                 swap_index(k,active_size);
00795                 --k;    // look at the newcomer
00796         }
00797 
00798         // unshrink, check all variables again before final iterations
00799 
00800         if(unshrinked || -(Gm1 + Gm2) > eps*10) return;
00801         
00802         unshrinked = true;
00803         reconstruct_gradient();
00804 
00805         for(k=l-1;k>=active_size;k--)
00806         {
00807                 if(is_lower_bound(k))
00808                 {
00809                         if(y[k]==+1)
00810                         {
00811                                 if(-G[k] < Gm1) continue;
00812                         }
00813                         else    if(-G[k] < Gm2) continue;
00814                 }
00815                 else if(is_upper_bound(k))
00816                 {
00817                         if(y[k]==+1)
00818                         {
00819                                 if(G[k] < Gm2) continue;
00820                         }
00821                         else    if(G[k] < Gm1) continue;
00822                 }
00823                 else continue;
00824 
00825                 swap_index(k,active_size);
00826                 active_size++;
00827                 ++k;    // look at the newcomer
00828         }
00829 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:32:37 2010 for ImpalaSrc by  doxygen 1.5.1