Exemple #1
0
  /**
   * It reads the data from the input files (training, validation and test) and parse all the
   * parameters from the parameters array.
   *
   * @param parameters parseParameters It contains the input files, output files and parameters
   */
  public Algorithm(parseParameters parameters) {

    train = new myDataset();
    val = new myDataset();
    test = new myDataset();
    try {
      System.out.println("\nReading the training set: " + parameters.getTrainingInputFile());
      train.readRegressionSet(parameters.getTrainingInputFile(), true);
      System.out.println("\nReading the validation set: " + parameters.getValidationInputFile());
      val.readRegressionSet(parameters.getValidationInputFile(), false);
      System.out.println("\nReading the test set: " + parameters.getTestInputFile());
      test.readRegressionSet(parameters.getTestInputFile(), false);
    } catch (IOException e) {
      System.err.println("There was a problem while reading the input data-sets: " + e);
      somethingWrong = true;
    }

    // We may check if there are some numerical attributes, because our algorithm may not handle
    // them:
    // somethingWrong = somethingWrong || train.hasNumericalAttributes();
    // somethingWrong = somethingWrong || train.hasMissingAttributes();

    outputTr = parameters.getTrainingOutputFile();
    outputTst = parameters.getTestOutputFile();
    outputBC = parameters.getOutputFile(0);

    // Now we parse the parameters, for example:
    semilla = Long.parseLong(parameters.getParameter(0));
    // ...
    tamPoblacion = Integer.parseInt(parameters.getParameter(1));
    numGeneraciones = Integer.parseInt(parameters.getParameter(2));
    numGenMigration = Integer.parseInt(parameters.getParameter(3));
    Nr = Integer.parseInt(parameters.getParameter(4));
    Nf = Integer.parseInt(parameters.getParameter(5));
    K = Integer.parseInt(parameters.getParameter(6));
    probMut = Double.parseDouble(parameters.getParameter(7));

    entradas = train.getnInputs();

    Poblacion = new ArrayList<Individual>(tamPoblacion);
    for (int i = 0; i < tamPoblacion; i++) {
      Individual indi = new Individual(entradas);
      Poblacion.add(indi);
    }

    Poblacion2 = new ArrayList<Individual>(tamPoblacion);
    Hijos = new ArrayList<Individual>(tamPoblacion / 2);
    SistemaDifuso = new ArrayList<Individual>(Nr);
    BestSistemaDifuso = new ArrayList<Individual>(Nr);

    vectorNr = new int[Nr];
  }
Exemple #2
0
  /**
   * It reads the data from the input files (training, validation and test) and parse all the
   * parameters from the parameters array.
   *
   * @param parameters parseParameters It contains the input files, output files and parameters
   */
  public Algorithm(parseParameters parameters) {

    train = new myDataset();
    val = new myDataset();
    test = new myDataset();
    try {
      System.out.println("\nReading the training set: " + parameters.getTrainingInputFile());
      // train.readClassificationSet(parameters.getTrainingInputFile(), true);
      train.readRegressionSet(parameters.getTrainingInputFile(), true);

      System.out.println("\nReading the validation set: " + parameters.getValidationInputFile());
      val.readRegressionSet(parameters.getValidationInputFile(), false);

      // val.readClassificationSet(parameters.getValidationInputFile(), false);
      System.out.println("\nReading the test set: " + parameters.getTestInputFile());
      test.readRegressionSet(parameters.getTestInputFile(), false);

      // test.readClassificationSet(parameters.getTestInputFile(), false);
    } catch (IOException e) {
      System.err.println("There was a problem while reading the input data-sets: " + e);
      somethingWrong = true;
    }

    // We may check if there are some numerical attributes, because our algorithm may not handle
    // them:
    // somethingWrong = somethingWrong || train.hasNumericalAttributes();
    // somethingWrong = somethingWrong || train.hasMissingAttributes();

    outputTr = parameters.getTrainingOutputFile();
    outputTst = parameters.getTestOutputFile();

    // Now we parse the parameters, for example:

    seed = Long.parseLong(parameters.getParameter(0));
    iterations = Integer.parseInt(parameters.getParameter(1));
    tam_poblacion = Integer.parseInt(parameters.getParameter(2));
    num_bits_gen = Integer.parseInt(parameters.getParameter(3));

    // ...

  }