Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/29/17 15:26:16 (7 years ago)
Author:
abeham
Message:

#2797:

  • Updated PSO to make it more compatible with SPSO 2011
  • Removed truncation of velocity vector and instead rescaled it given the maximum velocity
  • Added non-zero initial velocity according to SPSO 2011
  • Removed complicated bouncing code due to box constraints and instead implemented as described in SPSO 2011
  • Calculating neighbor best has been changed to use personal best
  • Avoiding local and global particle update and instead relying on neighborbest
  • More randomization during velocity update by using a separate random numbers per dimension
  • Reusing problem specific solution creator in RealVectorParticleCreator instead of always using UniformRandomRealVectorCreator
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RandomTopologyInitializer.cs

    r14185 r15091  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3132  [Item("Random Topology Initializer", "Randomly connectes every particle with k other particles.")]
    3233  [StorableClass]
    33   public sealed class RandomTopologyInitializer : TopologyInitializer {
     34  public sealed class RandomTopologyInitializer : TopologyInitializer, IStochasticOperator {
    3435    #region Parameters
    3536    public ILookupParameter<IRandom> RandomParameter {
     
    4041    }
    4142    #endregion
    42 
    43     #region Parameter Values
    44     private IRandom Random {
    45       get { return RandomParameter.ActualValue; }
    46     }
    47     private int NrOfConnections {
    48       get { return NrOfConnectionsParameter.ActualValue.Value; }
    49     }
    50     #endregion
    51 
     43   
    5244    #region Construction & Cloning
    5345    [StorableConstructor]
     
    6557
    6658    public override IOperation Apply() {
    67       ItemArray<IntArray> neighbors = new ItemArray<IntArray>(SwarmSize);
    68       for (int i = 0; i < SwarmSize; i++) {
    69         var numbers = Enumerable.Range(0, SwarmSize).ToList();
     59      var random = RandomParameter.ActualValue;
     60      var swarmSize = SwarmSizeParameter.ActualValue.Value;
     61      var nrOfConnections = NrOfConnectionsParameter.ActualValue.Value;
     62
     63      ItemArray<IntArray> neighbors = new ItemArray<IntArray>(swarmSize);
     64      for (int i = 0; i < swarmSize; i++) {
     65        var numbers = Enumerable.Range(0, swarmSize).ToList();
    7066        numbers.RemoveAt(i);
    71         var selectedNumbers = new List<int>(NrOfConnections);
    72         for (int j = 0; j < NrOfConnections && numbers.Count > 0; j++) {
    73           int index = Random.Next(numbers.Count);
     67        var selectedNumbers = new List<int>(nrOfConnections);
     68        for (int j = 0; j < nrOfConnections && numbers.Count > 0; j++) {
     69          int index = random.Next(numbers.Count);
    7470          selectedNumbers.Add(numbers[index]);
    7571          numbers.RemoveAt(index);
     
    7773        neighbors[i] = new IntArray(selectedNumbers.ToArray());
    7874      }
    79       Neighbors = neighbors;
     75      NeighborsParameter.ActualValue = neighbors;
    8076      return base.Apply();
    8177    }
Note: See TracChangeset for help on using the changeset viewer.