Example #1
0
  public static void main(String[] args) {

    System.out.println("SingleMachine_ProbMatrix_Evaporation080302");
    // openga.applications.data.singleMachine singleMachineData = new
    // openga.applications.data.singleMachine();
    int jobSets[] = new int[] {20, 30, 40, 50, 60, 90}; // 20, 30, 40, 50, 60, 90, 100, 200
    int counter = 0;
    int popSize[] = new int[] {100}; // 50, 100, 155, 210
    double crossoverRate[] = new double[] {0.9}, // 0.8, 0.5
        mutationRate[] = new double[] {0.5}; // 0.6, 0.3
    int populationSize[] = new int[] {100}; // 200, 100
    int repeatExperiments = 30;

    int startingGeneration[] = new int[] {200}; // 200, 500
    double startingGenerationPercent[] = new double[] {0.5}; // 0.1, 0.3, 0.5
    int interval[] = new int[] {10};
    double intervalPercent[] = new double[] {0.02}; // 0.01, 0.05, 0.1

    int strategy[] = new int[] {0};
    boolean applyEvaporation = false;
    String evaporationMethod[] =
        new String[] {"add"}; // "constant", "method1", "method2", "Threshold", "add"

    double lamdalearningrate[] = new double[] {1}; // 0.7
    double betalearningrate[] = new double[] {1}; // 0.1
    double w1 = 1;
    double w2 = 1;

    // Sourd Instance
    for (int m = 0; m < jobSets.length; m++) { // jobSets.length
      for (int k = 0; k < 49; k++) { // 49 9
        // if((jobSets[m] <= 50 && (k == 0 || k == 3 || k == 6 || k == 21 || k == 24 || k == 27 || k
        // == 42 || k == 45 || k == 48)) ||  (jobSets[m] > 50 && k < 9)){
        if ((jobSets[m] <= 50) || (jobSets[m] > 50 && k < 9)) {
          for (int j = 0; j < startingGeneration.length; j++) {
            for (int n = 0; n < interval.length; n++) {
              for (int p = 0; p < strategy.length; p++) {
                for (int q = 0; q < evaporationMethod.length; q++) {
                  for (int i = 0; i < repeatExperiments; i++) {
                    singleMachinePREDA singleMachine1 = new singleMachinePREDA();
                    System.out.println("Combinations: " + counter);
                    openga.applications.data.singleMachine readSingleMachineData1 =
                        new openga.applications.data.singleMachine();
                    int numberOfJobs = jobSets[m];
                    String fileName = readSingleMachineData1.getFileName(numberOfJobs, k);
                    // fileName = "bky"+numberOfJobs+"_1";
                    // fileName = "sks388a";
                    System.out.print(fileName + "\t");
                    readSingleMachineData1.setData("sks/" + fileName + ".txt");
                    readSingleMachineData1.getDataFromFile();
                    int dueDate[] = readSingleMachineData1.getDueDate();
                    int processingTime[] = readSingleMachineData1.getPtime();

                    singleMachine1.setData(numberOfJobs, dueDate, processingTime, fileName);
                    singleMachine1.setProbabilityMatrixData(startingGeneration[j], interval[n]);
                    singleMachine1.setSequenceStrategy(strategy[p]);
                    singleMachine1.setLearning(lamdalearningrate[0], betalearningrate[0]);
                    singleMachine1.setEvaporationMethod(applyEvaporation, evaporationMethod[q]);
                    singleMachine1.initiateVars();
                    singleMachine1.start();
                    counter++;
                  } // end for
                }
              }
            }
          }
        } // end if
      }
    }

    System.exit(0);

    /*
    //BKY Instance
    int incrementSteps = 5;
    for(int i = 0 ; i < repeatExperiments ; i ++ ){
    for(int j = 0 ; j < jobSets.length ; j ++ ){//jobSets.length
    for(int k = 0 ; k < startingGeneration.length ; k ++ ){
    for (int m = 0; m < interval.length; m++) {
    for (int n = 0; n < strategy.length; n++) {
    for(int p = 296 ; p < 297 ; ){
    openga.applications.data.readSingleMachine readSingleMachineData1 = new openga.applications.data.readSingleMachine();
    int numberOfJobs = jobSets[j];
    String fileName = readSingleMachineData1.getFileName(numberOfJobs, p);
    readSingleMachineData1.setData("instances/SingleMachineBKS/"+fileName+".txt");
    if(readSingleMachineData1.testReadData()){//to test whether the file exist
    singleMachinewithProbMatrix singleMachine1 = new singleMachinewithProbMatrix();
    System.out.println("Combinations: "+counter+"\t"+fileName);
    //System.out.print(fileName+"\t");
    readSingleMachineData1.getDataFromFile();
    int dueDate[] = readSingleMachineData1.getDueDate();
    int processingTime[] = readSingleMachineData1.getPtime();

    singleMachine1.setData(numberOfJobs, dueDate, processingTime, fileName);
    singleMachine1.setParameters(popSize[0], crossoverRate[0], mutationRate[0], 100000);

    singleMachine1.setProbabilityMatrixData(startingGeneration[k], interval[m]);
    singleMachine1.setSequenceStrategy(strategy[n]);
    singleMachine1.setEvaporationMethod(false, evaporationMethod[0]);

    singleMachine1.initiateVars();
    singleMachine1.start();
    counter ++;
    }
    p += incrementSteps;
    }
    }
    }
    }
    }
    }//end for of BKY
     */

  }
  public static void main(String[] args) {
    System.out.println("SPGA2_forParallel 20060302 Mining Gene Clone Mating with Archive");
    int numberOfSubPopulations[] = new int[] {40}; // 10, 20, 30, 40
    int popSize[] = new int[] {210}; // 100, 155, 210
    int numberOfJob[] = new int[] {35, 50, 65}; // 35, 50, 65
    int numberOfMachines[] = new int[] {10, 15, 18}; // 10, 15, 18
    int totalSolnsToExamine[] = new int[] {1000000}; // 1000000, 1500000, 2000000
    boolean applySecCRX[] = new boolean[] {false}; // false, true
    boolean applySecMutation[] = new boolean[] {true};
    boolean applyClone[] = new boolean[] {false, true};
    int tournamentSize[] = new int[] {10}; // 2, 10
    int cloneStrategies[] =
        new int[] {2}; // 0: random, 1: swap, 2:inverse, 3:shift, 4:adjacent.0, 1, 2, 3, 4
    double timeToClone[] = new double[] {0}; // 0, 0.25, 0.5, 0.75

    double crossoverRate = 0.9, mutationRate = 0.1, elitism = 0.2;
    int repeatExperiments = 15;
    int counter = 0;

    /*
        for(int i = 0 ; i < repeatExperiments ; i ++ ){
          for(int j = 0 ; j < applyClone.length ; j ++ ){
            for(int k = 0 ; k < tournamentSize.length ; k ++ ){
              for(int r = 0 ; r < numberOfJob.length ; r ++ ){
                System.out.println("combinations: "+counter++);
                SPGA2_forParallelMachine SPGA2_forParallelMachine1 = new SPGA2_forParallelMachine();
                SPGA2_forParallelMachine1.setParallelMachineData(numberOfJob[r], numberOfMachines[r]);
                SPGA2_forParallelMachine1.setParameters(numberOfSubPopulations[0], popSize[0],
                    totalSolnsToExamine[0], crossoverRate, mutationRate, elitism, applySecCRX[0], applySecMutation[0]);
                SPGA2_forParallelMachine1.setCloneActive(applyClone[j]);
                SPGA2_forParallelMachine1.setTournamentSize(tournamentSize[k]);
                SPGA2_forParallelMachine1.initiateVars();
                SPGA2_forParallelMachine1.start();
                SPGA2_forParallelMachine1 = null;
                System.gc();
              }
            }
          }
        }// end i

         for(int i = 0 ; i < repeatExperiments ; i ++ ){
          for(int j = 0 ; j < numberOfJob.length ; j ++ ){
             for(int r = 0 ; r < cloneStrategies.length ; r ++ ){
                for(int k = 0 ; k < timeToClone.length ; k ++ ){
                  System.out.println("combinations: "+counter++);
                  SPGA2_forParallelMachine SPGA2_forParallelMachine1 = new SPGA2_forParallelMachine();
                  SPGA2_forParallelMachine1.setParallelMachineData(numberOfJob[j], numberOfMachines[j]);
                  SPGA2_forParallelMachine1.setParameters(numberOfSubPopulations[0], popSize[0],
                      totalSolnsToExamine[0], crossoverRate, mutationRate, elitism, applySecCRX[0], applySecMutation[0]);
                  SPGA2_forParallelMachine1.setCloneActive(applyClone[0], cloneStrategies[r]);
                  SPGA2_forParallelMachine1.setTournamentSize(tournamentSize[0]);
                  SPGA2_forParallelMachine1.initiateVars();
                  SPGA2_forParallelMachine1.setTimeToClone(timeToClone[k]);
                  SPGA2_forParallelMachine1.start();
                  SPGA2_forParallelMachine1 = null;
                  System.gc();
                }
             }
          }
        }// end i

    */

    for (int i = 0; i < repeatExperiments; i++) {
      for (int r = 0; r < numberOfJob.length; r++) {
        System.out.println("combinations: " + counter++);
        SPGA2_forParallelMachine SPGA2_forParallelMachine1 = new SPGA2_forParallelMachine();
        SPGA2_forParallelMachine1.setParallelMachineData(numberOfJob[r], numberOfMachines[r]);
        SPGA2_forParallelMachine1.setParameters(
            numberOfSubPopulations[0],
            popSize[0],
            totalSolnsToExamine[0],
            crossoverRate,
            mutationRate,
            elitism,
            applySecCRX[0],
            applySecMutation[0]);
        SPGA2_forParallelMachine1.setCloneActive(applyClone[0], 2);
        SPGA2_forParallelMachine1.initiateVars();
        SPGA2_forParallelMachine1.start();
        SPGA2_forParallelMachine1.setTimeToClone(timeToClone[0]);
        SPGA2_forParallelMachine1 = null;
        System.gc();
      } // end r
    } // end i

    /*
        for(int i = 0 ; i < repeatExperiments ; i ++ ){
          for(int j = 0 ; j < numberOfSubPopulations.length ; j ++ ){
            for(int k = 0 ; k < popSize.length ; k ++ ){
              for(int L = 0 ; L < applySecCRX.length ; L ++ ){
                for(int m = 0 ; m < applySecMutation.length ; m ++ ){
                  for(int r = 0 ; r < numberOfJob.length ; r ++ ){
                    System.out.println(numberOfJob[r]+"\t"+numberOfSubPopulations[j]+"\t"+ popSize[k]);
                    System.out.println("combinations: "+counter++);
                    SPGA2_forParallelMachine SPGA2_forParallelMachine1 = new SPGA2_forParallelMachine();
                    SPGA2_forParallelMachine1.setParallelMachineData(numberOfJob[r], numberOfMachines[r]);
                    SPGA2_forParallelMachine1.setParameters(numberOfSubPopulations[j], popSize[k],
                        totalSolnsToExamine[0], crossoverRate, mutationRate, elitism, applySecCRX[L], applySecMutation[m]);
                    SPGA2_forParallelMachine1.initiateVars();
                    SPGA2_forParallelMachine1.start();
                    SPGA2_forParallelMachine1 = null;
                    System.gc();
                    //System.exit(0);
                  }//end r
                }//end m
              }// end L
            }// end k
          }// end j
        }// end i
    */
    System.exit(0);
  }