Esempio n. 1
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!");
 }
Esempio n. 2
0
  /** evolve Array of solvers solvers in sequencial (no MultiThread) */
  @Override
  public void iterate() {
    this.numEvaluations = 0;
    this.numGeneration = 0;
    parents.clear();
    // evolve all solvers
    for (EAsolver s : arrayOfSolvers) {
      if (!s.stop.isDone(s)) {
        s.iterate(); // iterate solver
        updateHallOfFame(s.parents);
      }
      parents.addAll(s.hallOfFame);
      // get maximum of evaluations
      this.numEvaluations =
          s.numEvaluations > this.numEvaluations ? s.numEvaluations : this.numEvaluations;
      // get max of generation
      this.numGeneration =
          s.numGeneration > this.numGeneration ? s.numGeneration : this.numGeneration;

      //            this.numEvaluations += s.numEvaluations;
      //            this.numGeneration += s.numGeneration;
    }
    // parents.addAll(hallOfFame);

    // update stastistics
    ((ReportSolverArray) report).updateStats(arrayOfSolvers);
  }