Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/12/17 16:49:16 (7 years ago)
Author:
abeham
Message:

#2797:

  • Fixed adaptive random topology updater
  • Adapted default values of the best attraction parameters
  • Changed code of the new topology initializer
  • Fixed the parameters of the SPSO particle updaters (c parameter is actually (personal|neighbor)bestattraction), reordered the method signature and provided defaults
  • Removed the max beyond parameter again
  • Updated the sample and updated the unit test
    • In the sample no inertia updating is used, but the topology initializers / updaters of SPSO are used
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  
    4242    #endregion
    4343   
    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) {
    4545      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();
    4848        velocity[i] =
    4949          velocity[i] * inertia +
     
    9191      var neighborBest = NeighborBestParameter.ActualValue;
    9292      var neighborBestAttraction = NeighborBestAttractionParameter.ActualValue.Value;
    93       var maxBeyond = MaxBeyondBestParameter.ActualValue.Value;
    9493
    95       UpdateVelocity(random, velocity, maxVelocity, position, inertia, personalBest, personalBestAttraction, neighborBest, neighborBestAttraction, maxBeyond);
     94      UpdateVelocity(random, velocity, position, personalBest, neighborBest, inertia, personalBestAttraction, neighborBestAttraction, maxVelocity);
    9695      UpdatePosition(bounds, velocity, position);
    9796
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSO2011ParticleUpdater.cs

    r15181 r15214  
    4141    #endregion
    4242   
    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) {
    4444      var gravity = new double[velocity.Length];
    4545      var direction = new RealVector(velocity.Length);
     
    4949
    5050      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;
    5254        // center of the hyper-sphere
    5355        gravity[i] = g_id + position[i];
     
    108110      var neighborBest = NeighborBestParameter.ActualValue;
    109111      var neighborBestAttraction = NeighborBestAttractionParameter.ActualValue.Value;
    110       var maxBeyond = MaxBeyondBestParameter.ActualValue.Value;
    111112
    112       UpdateVelocity(random, velocity, maxVelocity, position, inertia, personalBest, personalBestAttraction, neighborBest, neighborBestAttraction, maxBeyond);
     113      UpdateVelocity(random, velocity, position, personalBest, neighborBest, inertia, personalBestAttraction, neighborBestAttraction, maxVelocity);
    113114      UpdatePosition(bounds, velocity, position);
    114115
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/SPSOParticleUpdater.cs

    r15102 r15214  
    7171      get { return (ILookupParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; }
    7272    }
    73 
    74     public IValueLookupParameter<DoubleValue> MaxBeyondBestParameter {
    75       get { return (IValueLookupParameter<DoubleValue>)Parameters["MaxBeyondBest"]; }
    76     }
    7773    #endregion
    7874
     
    9389      Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestAttraction", "The weight for the particle's personal best position."));
    9490      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)));
    9691    }
    9792    #endregion
Note: See TracChangeset for help on using the changeset viewer.