private static void solve_epsilon_svr(svm_problem prob, svm_parameter param, double[] alpha, Solver.SolutionInfo si) { int l = prob.l; double[] alpha2 = new double[2*l]; double[] linear_term = new double[2*l]; byte[] y = new byte[2*l]; int i; for(i=0;i<l;i++) { alpha2[i] = 0; linear_term[i] = param.p - prob.y[i]; y[i] = 1; alpha2[i+l] = 0; linear_term[i+l] = param.p + prob.y[i]; y[i+l] = -1; } Solver s = new Solver(); s.Solve(2*l, new SVR_Q(prob,param), linear_term, y, alpha2, param.C, param.C, param.eps, si, param.shrinking); double sum_alpha = 0; for(i=0;i<l;i++) { alpha[i] = alpha2[i] - alpha2[i+l]; sum_alpha += Math.abs(alpha[i]); } System.out.print("nu = "+sum_alpha/(param.C*l)+"\n"); }
private static void solve_one_class(svm_problem prob, svm_parameter param, double[] alpha, Solver.SolutionInfo si) { int l = prob.l; double[] zeros = new double[l]; byte[] ones = new byte[l]; int i; int n = (int)(param.nu*prob.l); // # of alpha's at upper bound if(n>=prob.l) { System.err.print("nu must be in (0,1)\n"); System.exit(1); } for(i=0;i<n;i++) alpha[i] = 1; alpha[n] = param.nu * prob.l - n; for(i=n+1;i<l;i++) alpha[i] = 0; for(i=0;i<l;i++) { zeros[i] = 0; ones[i] = 1; } Solver s = new Solver(); s.Solve(l, new ONE_CLASS_Q(prob,param), zeros, ones, alpha, 1.0, 1.0, param.eps, si, param.shrinking); }
// // construct and solve various formulations // private static void solve_c_svc(svm_problem prob, svm_parameter param, double[] alpha, Solver.SolutionInfo si, double Cp, double Cn) { int l = prob.l; double[] minus_ones = new double[l]; byte[] y = new byte[l]; int i; for(i=0;i<l;i++) { alpha[i] = 0; minus_ones[i] = -1; if(prob.y[i] > 0) y[i] = +1; else y[i]=-1; } Solver s = new Solver(); s.Solve(l, new SVC_Q(prob,param,y), minus_ones, y, alpha, Cp, Cn, param.eps, si, param.shrinking); double sum_alpha=0; for(i=0;i<l;i++) sum_alpha += alpha[i]; System.out.print("nu = "+sum_alpha/(param.C*prob.l)+"\n"); for(i=0;i<l;i++) alpha[i] *= y[i]; }
public static void main(String[] args) { InputReader in = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); Solver solver = new Solver(in, out); solver.solve(); in.close(); out.flush(); out.close(); }
public static void main(String[] args) { try { Solver solver = new Solver(); solver.setup(args); solver.solve(); solver.writeOutput(); } catch (Exception e) { e.printStackTrace(); } }
void Solve(int l, Kernel Q, double[] b, byte[] y, double[] alpha, double Cp, double Cn, double eps, SolutionInfo si, int shrinking) { this.si = si; super.Solve(l,Q,b,y,alpha,Cp,Cn,eps,si,shrinking); }
public static void main(String[] args) { try { // Parse input and set up ProjectParams pp = ProjectParams.fromStdIn(); // System.out.println(pp.getTeams()); // System.out.println(pp); Solver solver = new Solver(pp); // System.out.println(solver + "\n"); // Solve and print solver.solve(); solver.printSolution(); } catch (IOException e) { System.err.println("Error reading data from stdin\n"); e.printStackTrace(); } }