Beispiel #1
0
 /**
  * For single objective problem
  *
  * @param arch1
  * @return
  */
 public int getBestSolnIndex(populationI arch1) {
   int index = 0;
   double bestobj = Double.MAX_VALUE;
   for (int k = 0; k < GaMain.getArchieve().getPopulationSize(); k++) {
     if (bestobj > GaMain.getArchieve().getObjectiveValues(k)[0]) {
       bestobj = GaMain.getArchieve().getObjectiveValues(k)[0];
       index = k;
     }
   }
   return index;
 }
Beispiel #2
0
 public void startMain() {
   openga.util.timeClock timeClock1 = new openga.util.timeClock();
   timeClock1.start();
   GaMain.startGA();
   timeClock1.end();
   // to output the implementation result.
   String implementResult = "";
   int bestInd = getBestSolnIndex(GaMain.getArchieve());
   implementResult =
       instanceName
           + "\t"
           + DEFAULT_crossoverRate
           + "\t"
           + DEFAULT_mutationRate
           + "\t"
           + lamda
           + "\t"
           + (length + 1)
           + "\t"
           + numberOfSalesmen
           + "\t"
           + startingGenDividen
           + "\t"
           + numberOfCrossoverTournament
           + "\t"
           + numberOfMutationTournament
           + "\t"
           + startingGenDividen
           + "\t"
           + GaMain.getArchieve().getSingleChromosome(bestInd).getObjValue()[0]
           + "\t"
           + timeClock1.getExecutionTime() / 1000.0
           + "\n"; // +"\t"+GaMain.getArchieve().getSingleChromosome(0).toString1()
   writeFile("mTSPEDA_20150731DOE_totalDistance", implementResult);
   System.out.print(implementResult);
 }