Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/04/11 16:34:11 (14 years ago)
Author:
epitzer
Message:

Configurable ParticleUpdater, and topologies, different topology initializers and support for dynamic topology changes (#852)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleUpdater.cs

    r5034 r5209  
    3131
    3232  [StorableClass]
    33   public class ParticleUpdater : SingleSuccessorOperator {
     33  public abstract class ParticleUpdater : SingleSuccessorOperator, IParticleUpdater {
    3434
    3535    #region Parameter properties
     
    4545    public LookupParameter<RealVector> PersonalBestPointParameter {
    4646      get { return (LookupParameter<RealVector>)Parameters["PersonalBestPoint"]; }
     47    }
     48    public LookupParameter<RealVector> BestNeighborPointParameter {
     49      get { return (LookupParameter<RealVector>)Parameters["BestNeighborPoint"]; }
    4750    }
    4851    public LookupParameter<RealVector> BestPointParameter {
     
    8487      get { return BestPointParameter.ActualValue; }
    8588    }
     89    public RealVector BestNeighborPoint {
     90      get { return BestNeighborPointParameter.ActualValue; }
     91    }
    8692    public DoubleMatrix Bounds {
    8793      get { return BoundsParameter.ActualValue; }
     
    101107    #endregion
    102108
     109    public override bool CanChangeName {
     110      get { return false; }
     111    }
     112
    103113    #region Construction & Cloning
    104114
     
    116126      Parameters.Add(new LookupParameter<RealVector>("PersonalBestPoint", "Particle's personal best position"));
    117127      Parameters.Add(new LookupParameter<RealVector>("BestPoint", "Global best position"));
     128      Parameters.Add(new LookupParameter<RealVector>("BestNeighborPoint", "Best neighboring position"));
    118129      Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
    119130      Parameters.Add(new LookupParameter<DoubleMatrix>("VelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
     
    123134    }
    124135
    125     public override IDeepCloneable Clone(Cloner cloner) {
    126       return new ParticleUpdater(this, cloner);
    127     }
    128 
    129136    #endregion
    130137
    131     public override IOperation Apply() {
    132       RealVector velocity = new RealVector(Velocity.Length);
    133       RealVector position = new RealVector(Point.Length);
    134       double r_p = Random.NextDouble();
    135       double r_g = Random.NextDouble();
    136       for (int i = 0; i < velocity.Length; i++) {
    137         velocity[i] =
    138           Velocity[i] * Omega +
    139           (PersonalBestPoint[i] - Point[i]) * Phi_P * r_p +
    140           (BestPoint[i] - Point[i]) * Phi_G * r_g;
    141       }
    142       BoundsChecker.Apply(velocity, VelocityBounds);
    143       for (int i = 0; i < velocity.Length; i++) {
    144         position[i] = Point[i] + velocity[i];
    145       }
    146       BoundsChecker.Apply(position, Bounds);
    147       Point = position;
    148       Velocity = velocity;
    149 
    150       return base.Apply();
    151     }
    152 
    153     public override bool CanChangeName {
    154       get { return false; }
    155     }
    156138  }
    157139}
Note: See TracChangeset for help on using the changeset viewer.