- Timestamp:
- 07/23/17 11:17:18 (8 years ago)
- Location:
- branches/Async
- Files:
-
- 11 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/Async ¶
- Property svn:ignore
-
TabularUnified
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.csproj ¶
r11623 r15281 113 113 </ItemGroup> 114 114 <ItemGroup> 115 <Compile Include="AdaptiveRandomTopologyUpdater.cs" /> 115 116 <Compile Include="MultiPSOTopologyUpdater.cs" /> 116 117 <Compile Include="ParticleSwarmOptimizationMainLoop.cs" /> 117 118 <Compile Include="Plugin.cs" /> 119 <Compile Include="SPSORandomTopologyInitializer.cs" /> 118 120 <Compile Include="RandomTopologyInitializer.cs" /> 119 121 <Compile Include="VonNeumannTopologyInitializer.cs" /> -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/MultiPSOTopologyUpdater.cs ¶
r12012 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 33 33 [Item("Multi PSO Topology Updater", "Splits swarm into NrOfSwarms non-overlapping sub-swarms. Swarms are re-grouped every regroupingPeriod iteration. The operator is implemented as described in Liang, J.J. and Suganthan, P.N 2005. Dynamic multi-swarm particle swarm optimizer. IEEE Swarm Intelligence Symposium, pp. 124-129.")] 34 34 [StorableClass] 35 public sealed class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater {35 public sealed class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater, IStochasticOperator { 36 36 37 37 public override bool CanChangeName { -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs ¶
r13173 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Analysis; … … 35 36 36 37 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 37 [Item("Particle Swarm Optimization (PSO)", "A particle swarm optimization algorithm based on the description in Pedersen, M.E.H. (2010). PhD thesis. University of Southampton.")]38 [Item("Particle Swarm Optimization (PSO)", "A particle swarm optimization algorithm based on Standard PSO (SPSO) as described in Clerc, M. (2012). Standard particle swarm optimisation.")] 38 39 [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 300)] 39 40 [StorableClass] … … 176 177 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 177 178 Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 178 Parameters.Add(new ValueParameter<IntValue>("SwarmSize", "Size of the particle swarm.", new IntValue( 10)));179 Parameters.Add(new ValueParameter<IntValue>("SwarmSize", "Size of the particle swarm.", new IntValue(40))); 179 180 Parameters.Add(new ValueParameter<IntValue>("MaxIterations", "Maximal number of iterations.", new IntValue(1000))); 180 181 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 181 Parameters.Add(new ValueParameter<DoubleValue>("Inertia", "Inertia weight on a particle's movement (omega).", new DoubleValue( 1)));182 Parameters.Add(new ValueParameter<DoubleValue>("PersonalBestAttraction", "Weight for particle's pull towards its personal best soution (phi_p).", new DoubleValue( -0.01)));183 Parameters.Add(new ValueParameter<DoubleValue>("NeighborBestAttraction", "Weight for pull towards the neighborhood best solution or global best solution in case of a totally connected topology (phi_g).", new DoubleValue( 3.7)));182 Parameters.Add(new ValueParameter<DoubleValue>("Inertia", "Inertia weight on a particle's movement (omega).", new DoubleValue(0.721))); 183 Parameters.Add(new ValueParameter<DoubleValue>("PersonalBestAttraction", "Weight for particle's pull towards its personal best soution (phi_p).", new DoubleValue(1.193))); 184 Parameters.Add(new ValueParameter<DoubleValue>("NeighborBestAttraction", "Weight for pull towards the neighborhood best solution or global best solution in case of a totally connected topology (phi_g).", new DoubleValue(1.193))); 184 185 Parameters.Add(new ConstrainedValueParameter<IParticleCreator>("ParticleCreator", "Operator that creates a new particle.")); 185 186 Parameters.Add(new ConstrainedValueParameter<IParticleUpdater>("ParticleUpdater", "Operator that updates a particle.")); … … 188 189 Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("InertiaUpdater", "Updates the omega parameter.")); 189 190 Parameters.Add(new ConstrainedValueParameter<ISwarmUpdater>("SwarmUpdater", "Encoding-specific parameter which is provided by the problem. May provide additional encoding-specific parameters, such as velocity bounds for real valued problems")); 190 ParticleUpdaterParameter.Hidden = true;191 191 192 192 RandomCreator randomCreator = new RandomCreator(); … … 262 262 UpdateAnalyzers(); 263 263 ParameterizeAnalyzers(); 264 UpdateParticleUpdaterParameter(); 264 265 UpdateTopologyParameters(); 265 266 InitializeParticleCreator(); … … 280 281 281 282 private void InitializeParticleCreator() { 283 ParticleCreatorParameter.ValidValues.Clear(); 282 284 if (Problem != null) { 283 285 IParticleCreator oldParticleCreator = ParticleCreator; 284 286 IParticleCreator defaultParticleCreator = Problem.Operators.OfType<IParticleCreator>().FirstOrDefault(); 285 ParticleCreatorParameter.ValidValues.Clear(); 286 foreach (IParticleCreator Creator in Problem.Operators.OfType<IParticleCreator>().OrderBy(x => x.Name)) { 287 ParticleCreatorParameter.ValidValues.Add(Creator); 287 foreach (var creator in Problem.Operators.OfType<IParticleCreator>().OrderBy(x => x.Name)) { 288 ParticleCreatorParameter.ValidValues.Add(creator); 288 289 } 289 290 if (oldParticleCreator != null) { 290 IParticleCreator creator = ParticleCreatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldParticleCreator.GetType());291 var creator = ParticleCreatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldParticleCreator.GetType()); 291 292 if (creator != null) ParticleCreator = creator; 292 293 else oldParticleCreator = null; … … 328 329 updater.IndexParameter.ActualName = "Iterations"; 329 330 updater.ValueParameter.ActualName = "CurrentInertia"; 330 updater.StartValueParameter. Value = new DoubleValue(1);331 updater.EndValueParameter.Value = new DoubleValue( 1E-10);331 updater.StartValueParameter.ActualName = InertiaParameter.Name; 332 updater.EndValueParameter.Value = new DoubleValue(0.70); 332 333 } 333 334 } … … 346 347 347 348 private void UpdateTopologyInitializer() { 348 ITopologyInitializer oldTopologyInitializer = TopologyInitializer;349 var oldTopologyInitializer = TopologyInitializer; 349 350 TopologyInitializerParameter.ValidValues.Clear(); 350 351 foreach (ITopologyInitializer topologyInitializer in ApplicationManager.Manager.GetInstances<ITopologyInitializer>().OrderBy(x => x.Name)) { 351 352 TopologyInitializerParameter.ValidValues.Add(topologyInitializer); 352 353 } 354 353 355 if (oldTopologyInitializer != null && TopologyInitializerParameter.ValidValues.Any(x => x.GetType() == oldTopologyInitializer.GetType())) 354 356 TopologyInitializer = TopologyInitializerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTopologyInitializer.GetType()); … … 357 359 358 360 private void ParameterizeTopologyUpdaters() { 359 foreach (var updater in TopologyUpdaterParameter.ValidValues) { 360 var multiPsoUpdater = updater as MultiPSOTopologyUpdater; 361 if (multiPsoUpdater != null) { 362 multiPsoUpdater.CurrentIterationParameter.ActualName = "Iterations"; 363 } 364 } 365 } 366 367 private void UpdateTopologyParameters() { 368 ITopologyUpdater oldTopologyUpdater = TopologyUpdater; 369 IParticleUpdater oldParticleUpdater = ParticleUpdater; 370 ClearTopologyParameters(); 371 if (Problem != null) { 372 IParticleUpdater defaultParticleUpdater = null; 373 if (TopologyInitializer != null) { 374 foreach (ITopologyUpdater topologyUpdater in ApplicationManager.Manager.GetInstances<ITopologyUpdater>()) 375 TopologyUpdaterParameter.ValidValues.Add(topologyUpdater); 376 defaultParticleUpdater = Problem.Operators.OfType<ILocalParticleUpdater>().FirstOrDefault(); 377 foreach (IParticleUpdater particleUpdater in Problem.Operators.OfType<ILocalParticleUpdater>().OrderBy(x => x.Name)) 378 ParticleUpdaterParameter.ValidValues.Add(particleUpdater); 379 } else { 380 defaultParticleUpdater = Problem.Operators.OfType<IGlobalParticleUpdater>().FirstOrDefault(); 381 foreach (IParticleUpdater particleUpdater in Problem.Operators.OfType<IGlobalParticleUpdater>().OrderBy(x => x.Name)) 382 ParticleUpdaterParameter.ValidValues.Add(particleUpdater); 383 } 384 if (oldTopologyUpdater != null) { 385 ITopologyUpdater newTopologyUpdater = TopologyUpdaterParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldParticleUpdater.GetType()); 386 if (newTopologyUpdater != null) TopologyUpdater = newTopologyUpdater; 387 } 361 foreach (var updater in TopologyUpdaterParameter.ValidValues.OfType<MultiPSOTopologyUpdater>()) { 362 updater.CurrentIterationParameter.ActualName = "Iterations"; 363 } 364 } 365 366 private void UpdateParticleUpdaterParameter() { 367 var oldParticleUpdater = ParticleUpdater; 368 ParticleUpdaterParameter.ValidValues.Clear(); 369 if (Problem != null) { 370 var defaultParticleUpdater = Problem.Operators.OfType<IParticleUpdater>().FirstOrDefault(); 371 372 foreach (var particleUpdater in Problem.Operators.OfType<IParticleUpdater>().OrderBy(x => x.Name)) 373 ParticleUpdaterParameter.ValidValues.Add(particleUpdater); 374 388 375 if (oldParticleUpdater != null) { 389 IParticleUpdater newParticleUpdater = ParticleUpdaterParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldParticleUpdater.GetType());376 var newParticleUpdater = ParticleUpdaterParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldParticleUpdater.GetType()); 390 377 if (newParticleUpdater != null) ParticleUpdater = newParticleUpdater; 391 378 else oldParticleUpdater = null; … … 393 380 if (oldParticleUpdater == null && defaultParticleUpdater != null) 394 381 ParticleUpdater = defaultParticleUpdater; 395 396 ParameterizeTopologyUpdaters(); 397 } 398 } 399 400 private void ClearTopologyParameters() { 382 } 383 } 384 385 private void UpdateTopologyParameters() { 386 ITopologyUpdater oldTopologyUpdater = TopologyUpdater; 401 387 TopologyUpdaterParameter.ValidValues.Clear(); 402 ParticleUpdaterParameter.ValidValues.Clear(); 388 if (Problem != null) { 389 if (TopologyInitializerParameter.Value != null) { 390 foreach (ITopologyUpdater topologyUpdater in ApplicationManager.Manager.GetInstances<ITopologyUpdater>()) 391 TopologyUpdaterParameter.ValidValues.Add(topologyUpdater); 392 393 if (oldTopologyUpdater != null) { 394 ITopologyUpdater newTopologyUpdater = TopologyUpdaterParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTopologyUpdater.GetType()); 395 if (newTopologyUpdater != null) TopologyUpdater = newTopologyUpdater; 396 } 397 ParameterizeTopologyUpdaters(); 398 } 399 } 403 400 } 404 401 -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimizationMainLoop.cs ¶
r12012 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 122 122 Placeholder evaluatorPlaceholder = new Placeholder(); 123 123 Placeholder analyzerPlaceholder = new Placeholder(); 124 Placeholder analyzer2Placeholder = new Placeholder(); 124 125 UniformSubScopesProcessor uniformSubScopeProcessor = new UniformSubScopesProcessor(); 125 126 Placeholder particleUpdaterPlaceholder = new Placeholder(); … … 192 193 conditionalBranch.ConditionParameter.ActualName = "ContinueIteration"; 193 194 conditionalBranch.TrueBranch = analyzerPlaceholder; 195 conditionalBranch.FalseBranch = analyzer2Placeholder; 196 197 analyzer2Placeholder.Name = "(Analyzer)"; 198 analyzer2Placeholder.OperatorParameter.ActualName = AnalyzerParameter.Name; 194 199 #endregion 195 200 } -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/Plugin.cs.frame ¶
r13321 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 /// Plugin class for HeuristicLab.Algorithms.ParticleSwarmOptimization plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Algorithms.ParticleSwarmOptimization", "3.3.1 3.$WCREV$")]28 [Plugin("HeuristicLab.Algorithms.ParticleSwarmOptimization", "3.3.14.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/Properties/AssemblyInfo.cs.frame ¶
r13321 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 31 31 [assembly: AssemblyCompany("")] 32 32 [assembly: AssemblyProduct("HeuristicLab")] 33 [assembly: AssemblyCopyright("(c) 2002-201 5HEAL")]33 [assembly: AssemblyCopyright("(c) 2002-2016 HEAL")] 34 34 [assembly: AssemblyTrademark("")] 35 35 [assembly: AssemblyCulture("")] … … 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.3.0.0")] 55 [assembly: AssemblyFileVersion("3.3.1 3.$WCREV$")]55 [assembly: AssemblyFileVersion("3.3.14.$WCREV$")] -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RandomTopologyInitializer.cs ¶
r12012 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.Optimization; 27 28 using HeuristicLab.Parameters; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 30 31 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 31 [Item("Random Topology Initializer", "Randomly connectes every particle with k other particles.")]32 [Item("Random Distinct Topology Initializer", "Each particle is informed by exactly k+1 distinct other particles (including itself).")] 32 33 [StorableClass] 33 public sealed class RandomTopologyInitializer : TopologyInitializer {34 public sealed class RandomTopologyInitializer : TopologyInitializer, IStochasticOperator { 34 35 #region Parameters 35 36 public ILookupParameter<IRandom> RandomParameter { … … 40 41 } 41 42 #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 52 44 #region Construction & Cloning 53 45 [StorableConstructor] … … 65 57 66 58 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(); 70 66 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 + 1); 68 selectedNumbers.Add(i); 69 for (int j = 0; j < nrOfConnections && numbers.Count > 0; j++) { 70 int index = random.Next(numbers.Count); 74 71 selectedNumbers.Add(numbers[index]); 75 72 numbers.RemoveAt(index); … … 77 74 neighbors[i] = new IntArray(selectedNumbers.ToArray()); 78 75 } 79 Neighbors = neighbors;76 NeighborsParameter.ActualValue = neighbors; 80 77 return base.Apply(); 81 78 } -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RingTopologyInitializer.cs ¶
r12012 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 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 } -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TopologyInitializer.cs ¶
r12012 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 40 40 get { return (IScopeTreeLookupParameter<IntArray>)Parameters["Neighbors"]; } 41 41 } 42 43 42 public ILookupParameter<IntValue> SwarmSizeParameter { 44 43 get { return (ILookupParameter<IntValue>)Parameters["SwarmSize"]; } 45 }46 47 #endregion48 49 #region Parameter Values50 protected ItemArray<IntArray> Neighbors {51 get { return NeighborsParameter.ActualValue; }52 set { NeighborsParameter.ActualValue = value; }53 }54 protected int SwarmSize {55 get { return SwarmSizeParameter.ActualValue.Value; }56 44 } 57 45 #endregion -
TabularUnified branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/VonNeumannTopologyInitializer.cs ¶
r12012 r15281 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 27 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 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.")]28 [Item("Von Neumann Topology Initializer", "Every particle is informed by the two following and the two previous particles 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 VonNeumannTopologyInitializer : TopologyInitializer { … … 44 44 45 45 public override IOperation Apply() { 46 ItemArray<IntArray> neighbors = new ItemArray<IntArray>(SwarmSize); 47 for (int i = 0; i < SwarmSize; i++) { 46 var swarmSize = SwarmSizeParameter.ActualValue.Value; 47 48 ItemArray<IntArray> neighbors = new ItemArray<IntArray>(swarmSize); 49 for (int i = 0; i < swarmSize; i++) { 48 50 neighbors[i] = new IntArray(new[] { 49 (SwarmSize + i-2) % SwarmSize, 50 (SwarmSize + i-1) % SwarmSize, 51 (i+1) % SwarmSize, 52 (i+2) % SwarmSize 51 (swarmSize + i-2) % swarmSize, 52 (swarmSize + i-1) % swarmSize, 53 i, 54 (i+1) % swarmSize, 55 (i+2) % swarmSize 53 56 }); 54 57 } 55 Neighbors = neighbors;58 NeighborsParameter.ActualValue = neighbors; 56 59 return base.Apply(); 57 60 }
Note: See TracChangeset
for help on using the changeset viewer.