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