Exemplo n.º 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);
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
  public void initiateVars() {
    GaMain = new singleThreadGAwithProbabilityMatrixPREDA();
    Population = new population();
    Selection = new binaryTournament();
    Crossover = new twoPointCrossover2(); //
    Crossover2 = new PMX();

    Mutation = new swapMutation();
    // Mutation   = new swapMutationWithMining2();//swapMutationWithMining2 shiftMutationWithMining2
    Mutation2 = new inverseMutation();
    ObjectiveFunction = new ObjectiveFunctionScheduleI[numberOfObjs];
    ObjectiveFunction[0] =
        new ObjectiveEarlinessTardinessPenalty(); // the first objective, tardiness,
                                                  // ObjectiveTardiness
                                                  // ObjectiveEarlinessTardinessPenalty
    Fitness = new singleObjectiveFitness();
    objectiveMinimization = new boolean[numberOfObjs];
    objectiveMinimization[0] = true;
    // objectiveMinimization[1] = true;
    encodeType = true;
    clone1 = new solutionVectorCloneWithMutation(); // swap mutation
    // set schedule data to the objectives
    ObjectiveFunction[0].setScheduleData(dueDay, processingTime, numberOfMachines);
    // set the data to the GA main program.
    GaMain.setLearningRate(lamda, beta); // Interaction Learning rate
    GaMain.setWeight(w1, w2); // model=uni*w1 + bi*w2
    GaMain.setProbabilityMatrixData(startingGeneration, interval);
    GaMain.setSequenceStrategy(strategy);
    totalSolnsToExamine = 125000;
    DEFAULT_PopSize = 100;
    // System.out.println(DEFAULT_PopSize);
    // System.exit(0);
    DEFAULT_generations = totalSolnsToExamine / (DEFAULT_PopSize);
    GaMain.setEvaporationMethod(applyEvaporation, evaporationMethod);
    GaMain.setData(
        Population,
        Selection,
        Crossover,
        Mutation,
        ObjectiveFunction,
        Fitness,
        DEFAULT_generations,
        DEFAULT_PopSize,
        DEFAULT_PopSize,
        numberOfJob,
        DEFAULT_crossoverRate,
        DEFAULT_mutationRate,
        objectiveMinimization,
        numberOfObjs,
        encodeType,
        elitism);
    GaMain.setSecondaryCrossoverOperator(Crossover2, false);
    GaMain.setSecondaryMutationOperator(Mutation2, false);
  }