Example #1
0
  /** Initialize all parameter of the algorithm */
  public void initParams() {

    swarmSize_ = ((Integer) getInputParameter("swarmSize")).intValue();
    archiveSize_ = ((Integer) getInputParameter("archiveSize")).intValue();
    maxIterations_ = ((Integer) getInputParameter("maxIterations")).intValue();

    indicators_ = (QualityIndicator) getInputParameter("indicators");

    polynomialMutation_ = operators_.get("mutation");

    parallelEvaluator_.startEvaluator(problem_);

    iteration_ = 1;

    success_ = false;

    particles_ = new SolutionSet(swarmSize_);
    best_ = new Solution[swarmSize_];

    // Create comparators for dominance and crowding distance
    dominance_ = new DominanceComparator();
    crowdingDistanceComparator_ = new CrowdingDistanceComparator();
    distance_ = new Distance();

    // Create the speed_ vector
    speed_ = new double[swarmSize_][problem_.getNumberOfVariables()];

    deltaMax_ = new double[problem_.getNumberOfVariables()];
    deltaMin_ = new double[problem_.getNumberOfVariables()];
    for (int i = 0; i < problem_.getNumberOfVariables(); i++) {
      deltaMax_[i] = (problem_.getUpperLimit(i) - problem_.getLowerLimit(i)) / 2.0;
      deltaMin_[i] = -deltaMax_[i];
    } // for

    leaders_ = new DominanceAndDecompositionArchive(archiveSize_, problem_.getNumberOfObjectives());
  } // initParams
Example #2
0
  /**
   * Runs of the SMPSO 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 {
    initParams();
    success_ = false;
    // ->Step 1 (and 3) Create the initial population and evaluate
    for (int i = 0; i < swarmSize_; i++) {
      Solution particle = new Solution(problem_);
      particles_.add(particle);
      parallelEvaluator_.addSolutionForEvaluation(particle);
    }

    parallelEvaluator_.parallelEvaluation();

    // -> Step2. Initialize the speed_ of each particle to 0
    for (int i = 0; i < swarmSize_; i++) {
      for (int j = 0; j < problem_.getNumberOfVariables(); j++) {
        speed_[i][j] = 0.0;
      }
    }

    // Step4 and 5
    for (int i = 0; i < particles_.size(); i++) {
      Solution particle = new Solution(particles_.get(i));
      leaders_.add(particle);
    }

    // -> Step 6. Initialize the memory of each particle
    for (int i = 0; i < particles_.size(); i++) {
      Solution particle = new Solution(particles_.get(i));
      best_[i] = particle;
    }

    // Crowding the leaders_
    distance_.crowdingDistanceAssignment(leaders_, problem_.getNumberOfObjectives());

    // -> Step 7. Iterations ..
    while (iteration_ < maxIterations_) {

      try {
        // Compute the speed_
        computeSpeed(iteration_, maxIterations_);
      } catch (IOException ex) {
        Logger.getLogger(SMPSODDSteadyState.class.getName()).log(Level.SEVERE, null, ex);
      }

      // Compute the new positions for the particles_
      computeNewPositions();

      // Mutate the particles_
      mopsoMutation(iteration_, maxIterations_);

      for (int i = 0; i < particles_.size(); i++) {
        Solution particle = particles_.get(i);
        parallelEvaluator_.addSolutionForEvaluation(particle);
      }

      parallelEvaluator_.parallelEvaluation();

      // Actualize the archive
      for (int i = 0; i < particles_.size(); i++) {
        Solution particle = new Solution(particles_.get(i));
        leaders_.add(particle);
      }

      // Actualize the memory of this particle
      for (int i = 0; i < particles_.size(); i++) {
        int flag = dominance_.compare(particles_.get(i), best_[i]);
        if (flag != 1) { // the new particle is best_ than the older remeber
          Solution particle = new Solution(particles_.get(i));
          best_[i] = particle;
        }
      }

      // Assign crowding distance to the leaders_
      distance_.crowdingDistanceAssignment(leaders_, problem_.getNumberOfObjectives());
      iteration_++;
    }

    parallelEvaluator_.stopEvaluator();
    return this.leaders_;
  } // execute