Changeset 5435 for trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/VonNeumannTopologyInitializer.cs
- Timestamp:
- 02/04/11 21:34:45 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/VonNeumannTopologyInitializer.cs
r5316 r5435 24 24 using HeuristicLab.Encodings.IntegerVectorEncoding; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 27 28 28 [Item("Von Neumann Topology Initializer", "Every particle is connected with the two following and the two previous particles wrapping around at the beginning and the end of the population.")] 29 29 [StorableClass] 30 public class VonNeumannTopologyInitializer : TopologyInitializer {30 public sealed class VonNeumannTopologyInitializer : TopologyInitializer { 31 31 32 32 #region Construction & Cloning 33 public VonNeumannTopologyInitializer() { } 33 34 34 [StorableConstructor] 35 pr otectedVonNeumannTopologyInitializer(bool deserializing) : base(deserializing) { }36 pr otected VonNeumannTopologyInitializer(VonNeumannTopologyInitializer original, Cloner cloner)37 : base(original, cloner) {38 } 35 private VonNeumannTopologyInitializer(bool deserializing) : base(deserializing) { } 36 private VonNeumannTopologyInitializer(VonNeumannTopologyInitializer original, Cloner cloner) : base(original, cloner) { } 37 public VonNeumannTopologyInitializer() : base() { } 38 39 39 public override IDeepCloneable Clone(Cloner cloner) { 40 40 return new VonNeumannTopologyInitializer(this, cloner); 41 41 } 42 42 43 #endregion 43 44 44 45 public override IOperation Apply() { 45 46 ItemArray<IntegerVector> neighbors = new ItemArray<IntegerVector>(SwarmSize); 46 for (int i = 0; i <SwarmSize; i++) {47 for (int i = 0; i < SwarmSize; i++) { 47 48 neighbors[i] = new IntegerVector(new[] { 48 49 (SwarmSize + i-2) % SwarmSize, … … 55 56 return base.Apply(); 56 57 } 57 58 58 } 59 59 }
Note: See TracChangeset
for help on using the changeset viewer.