Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/21/17 11:18:40 (7 years ago)
Author:
abeham
Message:

#2797: merged revisions 15071, 15076, 15091, 15092, 15093, 15096, 15102, 15114, 15181, 15201, 15214, 15223, 15224, 15228 to stable

Location:
stable
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Encodings.RealVectorEncoding

  • stable/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2007ParticleUpdater.cs

    r15096 r15277  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Parameters;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
     
    2930  [Item("SPSO 2007 Particle Updater", "Updates the particle's position according to the formulae described in SPSO 2007.")]
    3031  [StorableClass]
    31   public sealed class SPSO2007ParticleUpdater : RealVectorParticleUpdater {
     32  public sealed class SPSO2007ParticleUpdater : SPSOParticleUpdater {
    3233
    3334    #region Construction & Cloning
     
    4142    #endregion
    4243   
    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) {
    4445      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();
    4748        velocity[i] =
    4849          velocity[i] * inertia +
     
    6970        if (position[i] < min) {
    7071          position[i] = min;
    71           velocity[i] = 0;
     72          velocity[i] = 0; // SPSO 2007
    7273        }
    7374        if (position[i] > max) {
    7475          position[i] = max;
    75           velocity[i] = 0;
     76          velocity[i] = 0; // SPSO 2007
    7677        }
    7778      }
     
    9091      var neighborBest = NeighborBestParameter.ActualValue;
    9192      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);
    9495      UpdatePosition(bounds, velocity, position);
    9596
Note: See TracChangeset for help on using the changeset viewer.