Exemple #1
0
 protected void crowdingDistanceSelection(Ranking ranking) {
   population.clear();
   int rankingIndex = 0;
   while (populationIsNotFull()) {
     if (subfrontFillsIntoThePopulation(ranking, rankingIndex)) {
       addRankedSolutionsToPopulation(ranking, rankingIndex);
       rankingIndex++;
     } else {
       computeCrowdingDistance(ranking, rankingIndex);
       addLastRankedSolutions(ranking, rankingIndex);
     }
   }
 }
Exemple #2
0
 /**
  * Execute the ElitistES algorithm
 * @throws JMException 
  */
  public SolutionSet execute() throws JMException, ClassNotFoundException {
    int maxEvaluations ;
    int evaluations    ;

    SolutionSet population          ;
    SolutionSet offspringPopulation ;  

    Operator   mutationOperator ;
    Comparator comparator       ;
    
    comparator = new ObjectiveComparator(0) ; // Single objective comparator
    
    // Read the params
    maxEvaluations = ((Integer)this.getInputParameter("maxEvaluations")).intValue();                
   
    // Initialize the variables
    population          = new SolutionSet(mu_) ;   
    offspringPopulation = new SolutionSet(mu_ + lambda_) ;
    
    evaluations  = 0;                

    // Read the operators
    mutationOperator  = this.operators_.get("mutation");

    System.out.println("(" + mu_ + " + " + lambda_+")ES") ;
     
    // Create the parent population of mu solutions
    Solution newIndividual;
    for (int i = 0; i < mu_; i++) {
      newIndividual = new Solution(problem_);                    
      evaluations++;
      population.add(newIndividual);
    } //for
    
    finish {
	// 
    	async {
    		for (int i = 0; i < mu_; i++) {
    			evaluate_internal(population, i, null);
    		}
    	}
    }
     
    // Main loop
    int offsprings ;
    offsprings = lambda_ / mu_ ; 
    while (evaluations < maxEvaluations) {
      // STEP 1. Generate the mu+lambda population
      for (int i = 0; i < mu_; i++) {
        for (int j = 0; j < offsprings; j++) {
          Solution offspring = new Solution(population.get(i)) ;
          offspringPopulation.add(offspring) ;
          evaluations ++ ;
        } // for
      } // for
      
      finish {
	// 
      	async {
      		for (int i = 0; i < mu_*offsprings; i++) {
      			evaluate_internal(offspringPopulation, i, mutationOperator);
      		}
      	}
      }
       
      
      // STEP 2. Add the mu individuals to the offspring population
      for (int i = 0 ; i < mu_; i++) {
        offspringPopulation.add(population.get(i)) ;
      } // for
      population.clear() ;

      // STEP 3. Sort the mu+lambda population
      offspringPopulation.sort(comparator) ;
            
      // STEP 4. Create the new mu population
      for (int i = 0; i < mu_; i++)
        population.add(offspringPopulation.get(i)) ;

      System.out.println("Evaluation: " + evaluations + " Fitness: " + 
          population.get(0).getObjective(0)) ; 

      // STEP 6. Delete the mu+lambda population
      offspringPopulation.clear() ;
    } // while
    
    // Return a population with the best individual
    SolutionSet resultPopulation = new SolutionSet(1) ;
    resultPopulation.add(population.get(0)) ;
    
Exemple #3
0
  /**
   * Runs of the PESA2 algorithm.
   *
   * @return a <code>SolutionSet</code> that is a set of non dominated solutions as a result of the
   *     algorithm execution
   * @throws JMException
   */
  public SolutionSet execute() throws JMException, ClassNotFoundException {
    int archiveSize, bisections, maxEvaluations, evaluations, populationSize;
    AdaptiveGridArchive archive;
    SolutionSet solutionSet;
    Operator crossover, mutation, selection;

    // Read parameters
    populationSize = ((Integer) (inputParameters_.get("populationSize"))).intValue();
    archiveSize = ((Integer) (inputParameters_.get("archiveSize"))).intValue();
    bisections = ((Integer) (inputParameters_.get("bisections"))).intValue();
    maxEvaluations = ((Integer) (inputParameters_.get("maxEvaluations"))).intValue();

    // Get the operators
    crossover = operators_.get("crossover");
    mutation = operators_.get("mutation");

    // Initialize the variables
    evaluations = 0;
    archive = new AdaptiveGridArchive(archiveSize, bisections, problem_.getNumberOfObjectives());
    solutionSet = new SolutionSet(populationSize);
    HashMap parameters = null;
    selection = new PESA2Selection(parameters);

    // -> Create the initial individual and evaluate it and his constraints
    for (int i = 0; i < populationSize; i++) {
      Solution solution = new Solution(problem_);
      problem_.evaluate(solution);
      problem_.evaluateConstraints(solution);
      solutionSet.add(solution);
    }

    // Incorporate non-dominated solution to the archive
    for (int i = 0; i < solutionSet.size(); i++) {
      archive.add(solutionSet.get(i)); // Only non dominated are accepted by
      // the archive
    }

    // Clear the init solutionSet
    solutionSet.clear();

    // Iterations....
    Solution[] parents = new Solution[2];
    do {
      // -> Create the offSpring solutionSet
      while (solutionSet.size() < populationSize) {
        parents[0] = (Solution) selection.execute(archive);
        parents[1] = (Solution) selection.execute(archive);

        Solution[] offSpring = (Solution[]) crossover.execute(parents);
        mutation.execute(offSpring[0]);
        problem_.evaluate(offSpring[0]);
        problem_.evaluateConstraints(offSpring[0]);
        evaluations++;
        solutionSet.add(offSpring[0]);
      }

      for (int i = 0; i < solutionSet.size(); i++) archive.add(solutionSet.get(i));

      // Clear the solutionSet
      solutionSet.clear();

    } while (evaluations < maxEvaluations);
    // Return the  solutionSet of non-dominated individual
    return archive;
  } // execute