Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/02/11 15:22:54 (13 years ago)
Author:
epitzer
Message:

Additional improvements to PSO (#852)

  • simplify and clean up RealVectorSwarmUpdater
  • make the RealVectorParticleCreator an AlgorithmOperator
  • standardize naming of local variables in ParticleUpdaters
  • remove default parameter values from main loop
  • new implementation of MultiPSOTopologyUpdater (using shuffling)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorNeighborhoodParticleUpdater.cs

    r5568 r5592  
    3030  public sealed class RealVectorNeighborhoodParticleUpdater : RealVectorParticleUpdater, ILocalParticleUpdater {
    3131
     32    #region Construction & Cloning
    3233    [StorableConstructor]
    3334    private RealVectorNeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { }
    3435    private RealVectorNeighborhoodParticleUpdater(RealVectorNeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { }
    3536    public RealVectorNeighborhoodParticleUpdater() : base() { }
    36 
    3737    public override IDeepCloneable Clone(Cloner cloner) {
    3838      return new RealVectorNeighborhoodParticleUpdater(this, cloner);
    3939    }
     40    #endregion
    4041
    4142    public override IOperation Apply() {
     43      double inertia = Inertia.Value;
     44      double personalBestAttraction = PersonalBestAttraction.Value;
     45      double neighborBestAttraction = NeighborBestAttraction.Value;
     46
    4247      RealVector velocity = new RealVector(Velocity.Length);
    4348      RealVector position = new RealVector(RealVector.Length);
    4449      double r_p = Random.NextDouble();
    4550      double r_g = Random.NextDouble();
    46       double omega = Inertia.Value;
    47       double phi_p = PersonalBestAttraction.Value;
    48       double phi_g = NeighborBestAttraction.Value;
     51
    4952      for (int i = 0; i < velocity.Length; i++) {
    5053        velocity[i] =
    51           Velocity[i] * omega +
    52           (PersonalBest[i] - RealVector[i]) * phi_p * r_p +
    53           (BestPoint[i] - RealVector[i]) * phi_g * r_g;
     54          Velocity[i] * inertia +
     55          (PersonalBest[i] - RealVector[i]) * personalBestAttraction * r_p +
     56          (BestPoint[i] - RealVector[i]) * neighborBestAttraction * r_g;
    5457      }
     58
    5559      BoundsChecker.Apply(velocity, VelocityBounds);
    5660      for (int i = 0; i < velocity.Length; i++) {
     
    5862      }
    5963      BoundsChecker.Apply(position, Bounds);
     64
    6065      RealVector = position;
    6166      Velocity = velocity;
Note: See TracChangeset for help on using the changeset viewer.