Changeset 15091 for trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorTotallyConnectedParticleUpdater.cs
- Timestamp:
- 06/29/17 15:26:16 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorTotallyConnectedParticleUpdater.cs
r14185 r15091 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Optimization; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.PluginInfrastructure; 26 28 27 29 namespace HeuristicLab.Encodings.RealVectorEncoding { 28 30 [Item("Totally Connected Particle Updater", "Updates the particle's position using (among other things) the global best position. Use together with the empty topology initialzer. Point = Point + Velocity*Inertia + (PersonalBestPoint-Point)*Phi_P*r_p + (BestPoint-Point)*Phi_G*r_g")] 29 31 [StorableClass] 30 public sealed class RealVectorTotallyConnectedParticleUpdater : RealVectorParticleUpdater, IGlobalParticleUpdater { 32 [NonDiscoverableType] 33 [Obsolete("Same as the RealVectorNeighborhoodParticleUpdate")] 34 internal sealed class RealVectorTotallyConnectedParticleUpdater : RealVectorParticleUpdater { 31 35 32 36 #region Construction & Cloning … … 41 45 42 46 public override IOperation Apply() { 43 double inertia = Inertia.Value; 44 double personalBestAttraction = PersonalBestAttraction.Value; 45 double neighborBestAttraction = NeighborBestAttraction.Value; 46 47 RealVector velocity = new RealVector(Velocity.Length); 48 RealVector position = new RealVector(RealVector.Length); 49 double r_p = Random.NextDouble(); 50 double r_g = Random.NextDouble(); 51 52 for (int i = 0; i < velocity.Length; i++) { 53 velocity[i] = 54 Velocity[i] * inertia + 55 (PersonalBest[i] - RealVector[i]) * personalBestAttraction * r_p + 56 (BestPoint[i] - RealVector[i]) * neighborBestAttraction * r_g; 57 } 58 59 MoveParticle(velocity, position); 47 UpdateVelocity(); 48 UpdatePosition(); 60 49 61 50 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.