Ejemplo n.º 1
0
  private void read_problem() throws IOException {
    BufferedReader fp = new BufferedReader(new FileReader(input_file_name));
    Vector<Double> vy = new Vector<Double>();
    Vector<svm_node[]> vx = new Vector<svm_node[]>();
    int max_index = 0;

    while (true) {
      String line = fp.readLine();
      if (line == null) break;

      StringTokenizer st = new StringTokenizer(line, " \t\n\r\f:");

      vy.addElement(atof(st.nextToken()));
      int m = st.countTokens() / 2;
      svm_node[] x = new svm_node[m];
      for (int j = 0; j < m; j++) {
        x[j] = new svm_node();
        x[j].index = atoi(st.nextToken());
        x[j].value = atof(st.nextToken());
      }
      if (m > 0) max_index = Math.max(max_index, x[m - 1].index);
      vx.addElement(x);
    }

    prob = new svm_problem();
    prob.l = vy.size();
    prob.x = new svm_node[prob.l][];
    for (int i = 0; i < prob.l; i++) prob.x[i] = vx.elementAt(i);
    prob.y = new double[prob.l];
    for (int i = 0; i < prob.l; i++) prob.y[i] = vy.elementAt(i);

    if (param.gamma == 0 && max_index > 0) param.gamma = 1.0 / max_index;

    fp.close();
  }
Ejemplo n.º 2
0
  public void eval(
      final EvolutionState state,
      final int thread,
      final GPData input,
      final ADFStack stack,
      final GPIndividual individual,
      final Problem problem) {
    RegressionData rd = ((RegressionData) (input));

    children[0].eval(state, thread, input, stack, individual, problem);
    rd.x = Math.tan(rd.x);
  }