Changeset 5592 for trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorNeighborhoodParticleUpdater.cs
- Timestamp:
- 03/02/11 15:22:54 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorNeighborhoodParticleUpdater.cs
r5568 r5592 30 30 public sealed class RealVectorNeighborhoodParticleUpdater : RealVectorParticleUpdater, ILocalParticleUpdater { 31 31 32 #region Construction & Cloning 32 33 [StorableConstructor] 33 34 private RealVectorNeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { } 34 35 private RealVectorNeighborhoodParticleUpdater(RealVectorNeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { } 35 36 public RealVectorNeighborhoodParticleUpdater() : base() { } 36 37 37 public override IDeepCloneable Clone(Cloner cloner) { 38 38 return new RealVectorNeighborhoodParticleUpdater(this, cloner); 39 39 } 40 #endregion 40 41 41 42 public override IOperation Apply() { 43 double inertia = Inertia.Value; 44 double personalBestAttraction = PersonalBestAttraction.Value; 45 double neighborBestAttraction = NeighborBestAttraction.Value; 46 42 47 RealVector velocity = new RealVector(Velocity.Length); 43 48 RealVector position = new RealVector(RealVector.Length); 44 49 double r_p = Random.NextDouble(); 45 50 double r_g = Random.NextDouble(); 46 double omega = Inertia.Value; 47 double phi_p = PersonalBestAttraction.Value; 48 double phi_g = NeighborBestAttraction.Value; 51 49 52 for (int i = 0; i < velocity.Length; i++) { 50 53 velocity[i] = 51 Velocity[i] * omega +52 (PersonalBest[i] - RealVector[i]) * p hi_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; 54 57 } 58 55 59 BoundsChecker.Apply(velocity, VelocityBounds); 56 60 for (int i = 0; i < velocity.Length; i++) { … … 58 62 } 59 63 BoundsChecker.Apply(position, Bounds); 64 60 65 RealVector = position; 61 66 Velocity = velocity;
Note: See TracChangeset
for help on using the changeset viewer.