- Timestamp:
- 07/12/17 16:49:16 (7 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2007ParticleUpdater.cs
r15102 r15214 42 42 #endregion 43 43 44 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 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) { 45 45 for (int i = 0; i < velocity.Length; i++) { 46 double r_p = random.NextDouble() * c;47 double r_g = random.NextDouble() * c;46 double r_p = random.NextDouble(); 47 double r_g = random.NextDouble(); 48 48 velocity[i] = 49 49 velocity[i] * inertia + … … 91 91 var neighborBest = NeighborBestParameter.ActualValue; 92 92 var neighborBestAttraction = NeighborBestAttractionParameter.ActualValue.Value; 93 var maxBeyond = MaxBeyondBestParameter.ActualValue.Value;94 93 95 UpdateVelocity(random, velocity, maxVelocity, position, inertia, personalBest, personalBestAttraction, neighborBest, neighborBestAttraction, maxBeyond);94 UpdateVelocity(random, velocity, position, personalBest, neighborBest, inertia, personalBestAttraction, neighborBestAttraction, maxVelocity); 96 95 UpdatePosition(bounds, velocity, position); 97 96 -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2011ParticleUpdater.cs
r15181 r15214 41 41 #endregion 42 42 43 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) {43 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 44 var gravity = new double[velocity.Length]; 45 45 var direction = new RealVector(velocity.Length); … … 49 49 50 50 for (int i = 0; i < velocity.Length; i++) { 51 var g_id = c * ((personalBest[i] + neighborBest[i] - 2 * position[i]) / 3.0); 51 var g_id = (personalBestAttraction * personalBest[i] 52 + neighborBestAttraction * neighborBest[i] 53 - position[i] * (neighborBestAttraction + personalBestAttraction)) / 3.0; 52 54 // center of the hyper-sphere 53 55 gravity[i] = g_id + position[i]; … … 108 110 var neighborBest = NeighborBestParameter.ActualValue; 109 111 var neighborBestAttraction = NeighborBestAttractionParameter.ActualValue.Value; 110 var maxBeyond = MaxBeyondBestParameter.ActualValue.Value;111 112 112 UpdateVelocity(random, velocity, maxVelocity, position, inertia, personalBest, personalBestAttraction, neighborBest, neighborBestAttraction, maxBeyond);113 UpdateVelocity(random, velocity, position, personalBest, neighborBest, inertia, personalBestAttraction, neighborBestAttraction, maxVelocity); 113 114 UpdatePosition(bounds, velocity, position); 114 115 -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSOParticleUpdater.cs
r15102 r15214 71 71 get { return (ILookupParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; } 72 72 } 73 74 public IValueLookupParameter<DoubleValue> MaxBeyondBestParameter {75 get { return (IValueLookupParameter<DoubleValue>)Parameters["MaxBeyondBest"]; }76 }77 73 #endregion 78 74 … … 93 89 Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestAttraction", "The weight for the particle's personal best position.")); 94 90 Parameters.Add(new LookupParameter<DoubleValue>("NeighborBestAttraction", "The weight for the global best position.")); 95 Parameters.Add(new ValueLookupParameter<DoubleValue>("MaxBeyondBest", "A factor of how much the velocity update may maximally aim beyond the personal and neighbor best.", new DoubleValue(1.193)));96 91 } 97 92 #endregion
Note: See TracChangeset
for help on using the changeset viewer.