Changeset 15102 for trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2011ParticleUpdater.cs
- Timestamp:
- 06/30/17 21:57:38 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2011ParticleUpdater.cs
r15096 r15102 29 29 [Item("SPSO 2011 Particle Updater", "Updates the particle's position according to the formulae described in SPSO 2011.")] 30 30 [StorableClass] 31 public sealed class SPSO2011ParticleUpdater : RealVectorParticleUpdater { 32 31 public sealed class SPSO2011ParticleUpdater : SPSOParticleUpdater { 33 32 #region Construction & Cloning 34 33 [StorableConstructor] … … 41 40 #endregion 42 41 43 public static void UpdateVelocity(IRandom random, RealVector velocity, double maxVelocity, RealVector position, double inertia, RealVector personalBest, double personalBestAttraction, RealVector neighborBest, double neighborBestAttraction ) {42 public static void UpdateVelocity(IRandom random, RealVector velocity, double maxVelocity, RealVector position, double inertia, RealVector personalBest, double personalBestAttraction, RealVector neighborBest, double neighborBestAttraction, double c = 1.193) { 44 43 var gravity = new double[velocity.Length]; 45 44 var direct = new RealVector(velocity.Length); … … 47 46 48 47 for (int i = 0; i < velocity.Length; i++) { 49 var g_id = 1.193* ((personalBest[i] + neighborBest[i] - 2 * position[i]) / 3.0);48 var g_id = c * ((personalBest[i] + neighborBest[i] - 2 * position[i]) / 3.0); 50 49 gravity[i] = g_id + position[i]; 51 50 direct[i] = (random.NextDouble() - 0.5) * 2; … … 101 100 var neighborBest = NeighborBestParameter.ActualValue; 102 101 var neighborBestAttraction = NeighborBestAttractionParameter.ActualValue.Value; 103 104 UpdateVelocity(random, velocity, maxVelocity, position, inertia, personalBest, personalBestAttraction, neighborBest, neighborBestAttraction); 102 var maxBeyond = MaxBeyondBestParameter.ActualValue.Value; 103 104 UpdateVelocity(random, velocity, maxVelocity, position, inertia, personalBest, personalBestAttraction, neighborBest, neighborBestAttraction, maxBeyond); 105 105 UpdatePosition(bounds, velocity, position); 106 106
Note: See TracChangeset
for help on using the changeset viewer.