Пример #1
0
  public static String getConfigurationInfo(EAsolver solver) {
    StringBuffer txt = new StringBuffer();
    txt.append(MyString.toComment(MyString.LINE + "\n Solver configuration \n" + MyString.LINE));
    txt.append("\n" + toString(solver) + "\n");
    txt.append(
        MyString.toComment(MyString.LINE + "\n Solver Information \n" + MyString.LINE + "\n"));
    txt.append(MyString.toComment(getSolverInfo(solver) + "\n"));

    // copyright
    txt.append(MyString.toComment(MyString.getCopyright()));
    return txt.toString();
  }
Пример #2
0
 /**
  * solve the array of solvers in parallell
  *
  * @param verbose
  */
 public void solve(boolean verbose) {
   InitializeEvolution(verbose); // reset solvers
   // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   // running solvers
   ThreadRunSolver[] thr = new ThreadRunSolver[arrayOfSolvers.length];
   for (int i = 0; i < arrayOfSolvers.length; i++) {
     final int index = i;
     thr[i] = new ThreadRunSolver(arrayOfSolvers[index]);
     thr[i].start();
   }
   // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   // waiting to solvers finish
   for (Thread thread : thr) {
     try {
       thread.join();
     } catch (InterruptedException ex) {
       Logger.getLogger(EAsolver.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
   // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   // save report
   // report = new ReportSolverArray(this);
   ((ReportSolverArray) report).updateEvolutionStatistics(arrayOfSolvers);
   ((ReportSolverArray) report).save();
   System.out.println(
       MyString.toString(new Date()) + " : Simulation " + report.filename + " Complete!");
 }
Пример #3
0
  /**
   * converts solver to String
   *
   * @param solver
   * @return
   */
  public static String toString(EAsolver solver) {
    final int SIZE = 20;
    StringBuffer txt = new StringBuffer();
    txt.append(MyString.setSize(SOLVER_NAME, SIZE) + " = " + solver.solverName + "\n");

    txt.append(MyString.setSize(RANDOM_SEED, SIZE) + " = " + solver.randomSeed + "\n");
    txt.append(MyString.setSize(NUMBER_OF_RUNS, SIZE) + " = " + solver.numberOfRun + "\n");

    txt.append("\n");
    txt.append(MyString.setSize(SOLVER_TYPE, SIZE) + "= " + getSolverType(solver) + "\n");
    txt.append(
        MyString.setSize(STOP_CRITERIA, SIZE)
            + "= "
            + getSimpleGenetic(STOP_CRITERIA_LIB, solver.stop)
            + "\n");
    txt.append("\n");
    txt.append(
        MyString.setSize(PROBLEM_NAME, SIZE)
            + "= "
            + getSimpleGenetic(PROBLEM_NAME_LIB, solver.problem)
            + "\n");
    txt.append(
        MyString.setSize(POPULATION_TYPE, SIZE)
            + "= "
            + getSimpleGenetic(POPULATION_TYPE_LIB, solver.parents)
            + "\n");
    txt.append("\n");
    txt.append(
        MyString.setSize(OPERATOR_SELECTION, SIZE)
            + "= "
            + getSimpleGenetic(OPERATOR_SELECTION_LIB, solver.selection)
            + "\n");
    txt.append(
        MyString.setSize(OPERATOR_RECOMBINATION, SIZE)
            + "= "
            + getSimpleGenetic(OPERATOR_RECOMBINATION_LIB, solver.recombination)
            + "\n");
    txt.append(
        MyString.setSize(OPERATOR_MUTATION, SIZE)
            + "= "
            + getSimpleGenetic(OPERATOR_MUTATION_LIB, solver.mutation)
            + "\n");
    txt.append(
        MyString.setSize(OPERATOR_REPLACEMENT, SIZE)
            + "= "
            + getSimpleGenetic(OPERATOR_REPLACEMENT_LIB, solver.replacement)
            + "\n");
    txt.append(
        MyString.setSize(OPERATOR_RESCALING, SIZE)
            + "= "
            + getSimpleGenetic(OPERATOR_RESCALING_LIB, solver.rescaling)
            + "\n");
    txt.append("\n");
    for (AbstractStatistics s : solver.report.getStatistics()) {
      txt.append(
          MyString.setSize(STATISTIC, SIZE) + "= " + getSimpleGenetic(STATISTIC_LIB, s) + "\n");
    }
    return txt.toString();
  }