Changeset 15277 for stable/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RingTopologyInitializer.cs
- Timestamp:
- 07/21/17 11:18:40 (7 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15071,15076,15091-15093,15096,15102,15114,15181,15201,15214,15223-15224,15228
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RingTopologyInitializer.cs
r14186 r15277 26 26 27 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 28 [Item("Ring Topology Initializer", " Connected every particle with its preceeding and its following particle.")]28 [Item("Ring Topology Initializer", "Each particle is informed by its preceeding and its succeeding particle wrapping around at the beginning and the end of the swarm (in addition each particle also informs itself).")] 29 29 [StorableClass] 30 30 public sealed class RingTopologyInitializer : TopologyInitializer { … … 43 43 44 44 public override IOperation Apply() { 45 ItemArray<IntArray> neighbors = new ItemArray<IntArray>(SwarmSize); 46 for (int i = 0; i < SwarmSize; i++) { 47 neighbors[i] = new IntArray(new[] { (SwarmSize + i - 1) % SwarmSize, (i + 1) % SwarmSize }); 45 var swarmSize = SwarmSizeParameter.ActualValue.Value; 46 47 ItemArray<IntArray> neighbors = new ItemArray<IntArray>(swarmSize); 48 for (int i = 0; i < swarmSize; i++) { 49 neighbors[i] = new IntArray(new[] { (swarmSize + i - 1) % swarmSize, i, (i + 1) % swarmSize }); 48 50 } 49 Neighbors = neighbors;51 NeighborsParameter.ActualValue = neighbors; 50 52 return base.Apply(); 51 53 }
Note: See TracChangeset
for help on using the changeset viewer.