Example #1
0
 public void start() {
   System.out.println();
   openga.util.timeClock timeClock1 = new openga.util.timeClock();
   timeClock1.start();
   GaMain.startGA();
   timeClock1.end();
   // System.out.println("\nThe final result");
   int bestInd = getBestSolnIndex(GaMain.getArchieve());
   System.out.println(GaMain.getArchieve().getSingleChromosome(bestInd).toString1());
   String implementationResult = "";
   implementationResult +=
       fileName
           + "\t"
           + numberOfJob
           + "\t"
           + DEFAULT_crossoverRate
           + "\t"
           + DEFAULT_mutationRate
           + "\t"
           + DEFAULT_PopSize
           + "\t"
           + GaMain.getArchieve().getSingleChromosome(bestInd).getObjValue()[0]
           + "\t"
           + timeClock1.getExecutionTime() / 1000.0
           + "\n";
   // implementationResult += fileName + "\t" + evaporationMethod + "\t" +
   // GaMain.getArchieve().getSingleChromosome(bestInd).getObjValue()[0] + "\t" +
   // timeClock1.getExecutionTime() / 1000.0 + "\n";
   // implementationResult += fileName+"\t"+numberOfJob+"\t"+startingGeneration+"\t"+interval+"\t"+
   // GaMain.getArchieve().getSingleChromosome(bestInd).getObjValue()[0]+"\t"+timeClock1.getExecutionTime()/1000.0+"\n";
   writeFile("SingleMachine_PREDA1002", implementationResult);
   System.out.println(implementationResult);
 }
Example #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);
 }
  public void start() {
    openga.util.timeClock timeClock1 = new openga.util.timeClock();
    timeClock1.start();

    // we control the number of iteration of GA here.
    for (int m = 0; m < DEFAULT_generations; m++) {
      // System.out.println(m);

      if (m == timeToClone * DEFAULT_generations) {
        // To clone solution
        for (int k = 0; k < numberOfSubPopulations; k++) {
          GaMain[k].setCloneOperatpr(clone1, applyClone);
        }
      }

      for (int i = 0; i < numberOfSubPopulations; i++) {
        if (m == 0) { // initial each population and its objective values.
          GaMain[i].InitialRun();
          if (i == 0) {
            GaMain[i].initFirstArchieve();
          }
        }
        // start the GA processes.
        GaMain[i].startGA();
      }
    }

    timeClock1.end();
    // System.out.println(timeClock1.getExecutionTime());
    // to output the implementation result.
    String implementResult = "";
    double refSet[][] = getReferenceSet();

    double objArray[][] = GaMain[0].getArchieveObjectiveValueArray();
    double D1r = calcSolutionQuality(refSet, objArray);
    implementResult =
        numberOfJob
            + "\t"
            + 1
            + "\t"
            + 1
            + "\t"
            + D1r
            + "\t"
            + timeClock1.getExecutionTime() / 1000
            + "\n";
    objArray = null;
    writeFile("SPGA2_forParallel 20060302 Mining Gene Clone Mating with Archive", implementResult);
    System.out.println(implementResult);
    /*
        implementResult = "";
        for(int k = 0 ; k < GaMain[0].getArchieve().getPopulationSize() ; k ++ ){
          implementResult += GaMain[0].getArchieve().getSingleChromosome(k).toString1()+"\t";//sequnence
          for(int j = 0 ; j < numberOfObjs ; j ++ ){//for each objectives
            implementResult += GaMain[0].getArchieve().getObjectiveValues(k)[j]+"\t";
          }
          implementResult += "\n";
        }
        //writeFile("SPGA2_forParallelMachineParetoSet"+System.currentTimeMillis(), implementResult);
    */

    for (int i = 0; i < numberOfSubPopulations; i++) {
      GaMain[i].destroidArchive();
      GaMain[i] = null;
    }
  }