Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/30/17 21:57:38 (7 years ago)
Author:
abeham
Message:

#2797:

  • Recreated backwards compatibility by readding old operators and renaming new operators to SPSO*
    • If a previously configured algorithm is run again, the same results should be obtained
  • Set all old operators to internal, NonDiscoverableType, and Obsolete (they are also not fixed, e.g. PersonalBest update remains flawed)
  • Added SPSO 2007 velocity initializer and let users choose in SPSOParticleCreator
  • Changed description of PSO
  • Updated sample
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2011ParticleUpdater.cs

    r15096 r15102  
    2929  [Item("SPSO 2011 Particle Updater", "Updates the particle's position according to the formulae described in SPSO 2011.")]
    3030  [StorableClass]
    31   public sealed class SPSO2011ParticleUpdater : RealVectorParticleUpdater {
    32 
     31  public sealed class SPSO2011ParticleUpdater : SPSOParticleUpdater {
    3332    #region Construction & Cloning
    3433    [StorableConstructor]
     
    4140    #endregion
    4241   
    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) {
    4443      var gravity = new double[velocity.Length];
    4544      var direct = new RealVector(velocity.Length);
     
    4746
    4847      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);
    5049        gravity[i] = g_id + position[i];
    5150        direct[i] = (random.NextDouble() - 0.5) * 2;
     
    101100      var neighborBest = NeighborBestParameter.ActualValue;
    102101      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);
    105105      UpdatePosition(bounds, velocity, position);
    106106
Note: See TracChangeset for help on using the changeset viewer.