Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/02/11 15:22:54 (14 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/RealVectorTotallyConnectedParticleUpdater.cs

    r5568 r5592  
    3131
    3232    #region Construction & Cloning
    33 
    3433    [StorableConstructor]
    3534    private RealVectorTotallyConnectedParticleUpdater(bool deserializing) : base(deserializing) { }
    3635    private RealVectorTotallyConnectedParticleUpdater(RealVectorTotallyConnectedParticleUpdater original, Cloner cloner) : base(original, cloner) { }
    3736    public RealVectorTotallyConnectedParticleUpdater() : base() { }
    38 
    3937    public override IDeepCloneable Clone(Cloner cloner) {
    4038      return new RealVectorTotallyConnectedParticleUpdater(this, cloner);
    4139    }
    42 
    4340    #endregion
    4441
    4542    public override IOperation Apply() {
    46       base.Apply();
     43      double inertia = Inertia.Value;
     44      double personalBestAttraction = PersonalBestAttraction.Value;
     45      double neighborBestAttraction = NeighborBestAttraction.Value;
     46
    4747      RealVector velocity = new RealVector(Velocity.Length);
    4848      RealVector position = new RealVector(RealVector.Length);
    4949      double r_p = Random.NextDouble();
    5050      double r_g = Random.NextDouble();
    51       double omega = Inertia.Value;
    52       double phi_p = PersonalBestAttraction.Value;
    53       double phi_g = NeighborBestAttraction.Value;
     51
    5452      for (int i = 0; i < velocity.Length; i++) {
    5553        velocity[i] =
    56           Velocity[i] * omega +
    57           (PersonalBest[i] - RealVector[i]) * phi_p * r_p +
    58           (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;
    5957      }
     58
    6059      BoundsChecker.Apply(velocity, VelocityBounds);
    6160      for (int i = 0; i < velocity.Length; i++) {
     
    6362      }
    6463      BoundsChecker.Apply(position, Bounds);
     64
    6565      RealVector = position;
    6666      Velocity = velocity;
Note: See TracChangeset for help on using the changeset viewer.