Changeset 15277 for stable/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2007ParticleUpdater.cs
- Timestamp:
- 07/21/17 11:18:40 (7 years ago)
- Location:
- stable
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15071,15076,15091-15093,15096,15102,15114,15181,15201,15214,15223-15224,15228
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.RealVectorEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.RealVectorEncoding merged: 15071,15091,15096,15102,15114,15181,15201,15214
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2007ParticleUpdater.cs
r15096 r15277 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Data; 26 using HeuristicLab.Parameters; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 … … 29 30 [Item("SPSO 2007 Particle Updater", "Updates the particle's position according to the formulae described in SPSO 2007.")] 30 31 [StorableClass] 31 public sealed class SPSO2007ParticleUpdater : RealVectorParticleUpdater {32 public sealed class SPSO2007ParticleUpdater : SPSOParticleUpdater { 32 33 33 34 #region Construction & Cloning … … 41 42 #endregion 42 43 43 public static void UpdateVelocity(IRandom random, RealVector velocity, double maxVelocity, RealVector position, double inertia, RealVector personalBest, double personalBestAttraction, RealVector neighborBest, double neighborBestAttraction) {44 public static void UpdateVelocity(IRandom random, RealVector velocity, RealVector position, RealVector personalBest, RealVector neighborBest, double inertia = 0.721, double personalBestAttraction = 1.193, double neighborBestAttraction = 1.193, double maxVelocity = double.MaxValue) { 44 45 for (int i = 0; i < velocity.Length; i++) { 45 double r_p = random.NextDouble() * 1.193;46 double r_g = random.NextDouble() * 1.193;46 double r_p = random.NextDouble(); 47 double r_g = random.NextDouble(); 47 48 velocity[i] = 48 49 velocity[i] * inertia + … … 69 70 if (position[i] < min) { 70 71 position[i] = min; 71 velocity[i] = 0; 72 velocity[i] = 0; // SPSO 2007 72 73 } 73 74 if (position[i] > max) { 74 75 position[i] = max; 75 velocity[i] = 0; 76 velocity[i] = 0; // SPSO 2007 76 77 } 77 78 } … … 90 91 var neighborBest = NeighborBestParameter.ActualValue; 91 92 var neighborBestAttraction = NeighborBestAttractionParameter.ActualValue.Value; 92 93 UpdateVelocity(random, velocity, maxVelocity, position, inertia, personalBest, personalBestAttraction, neighborBest, neighborBestAttraction);93 94 UpdateVelocity(random, velocity, position, personalBest, neighborBest, inertia, personalBestAttraction, neighborBestAttraction, maxVelocity); 94 95 UpdatePosition(bounds, velocity, position); 95 96
Note: See TracChangeset
for help on using the changeset viewer.