for(i=0;i<active_size;i++) if(!is_upper_bound(i)) if(!is_lower_bound(i)) reconstruct_gradient(); active_size = l; if (be_shrunk(i, Gmax1, Gmax2, Gmax3, Gmax4)) if (!be_shrunk(active_size, Gmax1, Gmax2, Gmax3, Gmax4)) swap_index(i,active_size); break;
private boolean be_shrunk(int i, double Gmax1, double Gmax2, double Gmax3, double Gmax4) { if(is_upper_bound(i)) { if(y[i]==+1) return(-G[i] > Gmax1); else return(-G[i] > Gmax4); } else if(is_lower_bound(i)) { if(y[i]==+1) return(G[i] > Gmax2); else return(G[i] > Gmax3); } else return(false); }
private static void solve_nu_svr(svm_problem prob, svm_parameter param, double[] alpha, Solver.SolutionInfo si) { int l = prob.l; double C = param.C; double[] alpha2 = new double[2*l]; double[] linear_term = new double[2*l]; byte[] y = new byte[2*l]; int i; double sum = C * param.nu * l / 2; for(i=0;i<l;i++) { alpha2[i] = alpha2[i+l] = Math.min(sum,C); sum -= alpha2[i]; linear_term[i] = - prob.y[i]; y[i] = 1; linear_term[i+l] = prob.y[i]; y[i+l] = -1; } Solver_NU s = new Solver_NU(); s.Solve(2*l, new SVR_Q(prob,param), linear_term, y, alpha2, C, C, param.eps, si, param.shrinking); svm.info("epsilon = "+(-si.r)+"\n"); for(i=0;i<l;i++) alpha[i] = alpha2[i] - alpha2[i+l]; }
private boolean be_shrunk(int i, double Gmax1, double Gmax2, double Gmax3, double Gmax4) { if(is_upper_bound(i)) { if(y[i]==+1) return(-G[i] > Gmax1); else return(-G[i] > Gmax4); } else if(is_lower_bound(i)) { if(y[i]==+1) return(G[i] > Gmax2); else return(G[i] > Gmax3); } else return(false); }
private static void solve_nu_svr(svm_problem prob, svm_parameter param, double[] alpha, Solver.SolutionInfo si) { int l = prob.l; double C = param.C; double[] alpha2 = new double[2*l]; double[] linear_term = new double[2*l]; byte[] y = new byte[2*l]; int i; double sum = C * param.nu * l / 2; for(i=0;i<l;i++) { alpha2[i] = alpha2[i+l] = Math.min(sum,C); sum -= alpha2[i]; linear_term[i] = - prob.y[i]; y[i] = 1; linear_term[i+l] = prob.y[i]; y[i+l] = -1; } Solver_NU s = new Solver_NU(); s.Solve(2*l, new SVR_Q(prob,param), linear_term, y, alpha2, C, C, param.eps, si, param.shrinking); svm.info("epsilon = "+(-si.r)+"\n"); for(i=0;i<l;i++) alpha[i] = alpha2[i] - alpha2[i+l]; }
for(i=0;i<active_size;i++) if(!is_upper_bound(i)) if(!is_lower_bound(i)) reconstruct_gradient(); active_size = l; if (be_shrunk(i, Gmax1, Gmax2, Gmax3, Gmax4)) if (!be_shrunk(active_size, Gmax1, Gmax2, Gmax3, Gmax4)) swap_index(i,active_size); break;
private boolean be_shrunk(int i, double Gmax1, double Gmax2, double Gmax3, double Gmax4) { if(is_upper_bound(i)) { if(y[i]==+1) return(-G[i] > Gmax1); else return(-G[i] > Gmax4); } else if(is_lower_bound(i)) { if(y[i]==+1) return(G[i] > Gmax2); else return(G[i] > Gmax3); } else return(false); }
private static void solve_nu_svr(svm_problem prob, svm_parameter param, double[] alpha, Solver.SolutionInfo si) { int l = prob.l; double C = param.C; double[] alpha2 = new double[2*l]; double[] linear_term = new double[2*l]; byte[] y = new byte[2*l]; int i; double sum = C * param.nu * l / 2; for(i=0;i<l;i++) { alpha2[i] = alpha2[i+l] = Math.min(sum,C); sum -= alpha2[i]; linear_term[i] = - prob.y[i]; y[i] = 1; linear_term[i+l] = prob.y[i]; y[i+l] = -1; } Solver_NU s = new Solver_NU(); s.Solve(2*l, new SVR_Q(prob,param), linear_term, y, alpha2, C, C, param.eps, si, param.shrinking); svm.info("epsilon = "+(-si.r)+"\n"); for(i=0;i<l;i++) alpha[i] = alpha2[i] - alpha2[i+l]; }
for(i=0;i<active_size;i++) if(!is_upper_bound(i)) if(!is_lower_bound(i)) reconstruct_gradient(); active_size = l; if (be_shrunk(i, Gmax1, Gmax2, Gmax3, Gmax4)) if (!be_shrunk(active_size, Gmax1, Gmax2, Gmax3, Gmax4)) swap_index(i,active_size); break;
if(is_lower_bound(i)) ub1 = Math.min(ub1,G[i]); else if(is_upper_bound(i)) lb1 = Math.max(lb1,G[i]); else if(is_lower_bound(i)) ub2 = Math.min(ub2,G[i]); else if(is_upper_bound(i)) lb2 = Math.max(lb2,G[i]); else
if(is_lower_bound(i)) ub1 = Math.min(ub1,G[i]); else if(is_upper_bound(i)) lb1 = Math.max(lb1,G[i]); else if(is_lower_bound(i)) ub2 = Math.min(ub2,G[i]); else if(is_upper_bound(i)) lb2 = Math.max(lb2,G[i]); else
if(is_lower_bound(i)) ub1 = Math.min(ub1,G[i]); else if(is_upper_bound(i)) lb1 = Math.max(lb1,G[i]); else if(is_lower_bound(i)) ub2 = Math.min(ub2,G[i]); else if(is_upper_bound(i)) lb2 = Math.max(lb2,G[i]); else
if(y[t]==+1) if(!is_upper_bound(t)) if(-G[t] >= Gmaxp) if(!is_lower_bound(t)) if(G[t] >= Gmaxn) if (!is_lower_bound(j)) if (!is_upper_bound(j))
if(y[t]==+1) if(!is_upper_bound(t)) if(-G[t] >= Gmaxp) if(!is_lower_bound(t)) if(G[t] >= Gmaxn) if (!is_lower_bound(j)) if (!is_upper_bound(j))
if(y[t]==+1) if(!is_upper_bound(t)) if(-G[t] >= Gmaxp) if(!is_lower_bound(t)) if(G[t] >= Gmaxn) if (!is_lower_bound(j)) if (!is_upper_bound(j))