Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/23/17 11:17:18 (7 years ago)
Author:
abeham
Message:

#2258: merged r14001:15280 from trunk into branch

Location:
branches/Async
Files:
11 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/Async

  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.csproj

    r11623 r15281  
    113113  </ItemGroup>
    114114  <ItemGroup>
     115    <Compile Include="AdaptiveRandomTopologyUpdater.cs" />
    115116    <Compile Include="MultiPSOTopologyUpdater.cs" />
    116117    <Compile Include="ParticleSwarmOptimizationMainLoop.cs" />
    117118    <Compile Include="Plugin.cs" />
     119    <Compile Include="SPSORandomTopologyInitializer.cs" />
    118120    <Compile Include="RandomTopologyInitializer.cs" />
    119121    <Compile Include="VonNeumannTopologyInitializer.cs" />
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/MultiPSOTopologyUpdater.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3333  [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.")]
    3434  [StorableClass]
    35   public sealed class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater {
     35  public sealed class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater, IStochasticOperator {
    3636
    3737    public override bool CanChangeName {
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs

    r13173 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using HeuristicLab.Analysis;
     
    3536
    3637namespace 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.")]
    3839  [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 300)]
    3940  [StorableClass]
     
    176177      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    177178      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)));
    179180      Parameters.Add(new ValueParameter<IntValue>("MaxIterations", "Maximal number of iterations.", new IntValue(1000)));
    180181      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)));
    184185      Parameters.Add(new ConstrainedValueParameter<IParticleCreator>("ParticleCreator", "Operator that creates a new particle."));
    185186      Parameters.Add(new ConstrainedValueParameter<IParticleUpdater>("ParticleUpdater", "Operator that updates a particle."));
     
    188189      Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("InertiaUpdater", "Updates the omega parameter."));
    189190      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;
    191191
    192192      RandomCreator randomCreator = new RandomCreator();
     
    262262      UpdateAnalyzers();
    263263      ParameterizeAnalyzers();
     264      UpdateParticleUpdaterParameter();
    264265      UpdateTopologyParameters();
    265266      InitializeParticleCreator();
     
    280281
    281282    private void InitializeParticleCreator() {
     283      ParticleCreatorParameter.ValidValues.Clear();
    282284      if (Problem != null) {
    283285        IParticleCreator oldParticleCreator = ParticleCreator;
    284286        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);
    288289        }
    289290        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());
    291292          if (creator != null) ParticleCreator = creator;
    292293          else oldParticleCreator = null;
     
    328329        updater.IndexParameter.ActualName = "Iterations";
    329330        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);
    332333      }
    333334    }
     
    346347
    347348    private void UpdateTopologyInitializer() {
    348       ITopologyInitializer oldTopologyInitializer = TopologyInitializer;
     349      var oldTopologyInitializer = TopologyInitializer;
    349350      TopologyInitializerParameter.ValidValues.Clear();
    350351      foreach (ITopologyInitializer topologyInitializer in ApplicationManager.Manager.GetInstances<ITopologyInitializer>().OrderBy(x => x.Name)) {
    351352        TopologyInitializerParameter.ValidValues.Add(topologyInitializer);
    352353      }
     354
    353355      if (oldTopologyInitializer != null && TopologyInitializerParameter.ValidValues.Any(x => x.GetType() == oldTopologyInitializer.GetType()))
    354356        TopologyInitializer = TopologyInitializerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTopologyInitializer.GetType());
     
    357359
    358360    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
    388375        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());
    390377          if (newParticleUpdater != null) ParticleUpdater = newParticleUpdater;
    391378          else oldParticleUpdater = null;
     
    393380        if (oldParticleUpdater == null && defaultParticleUpdater != null)
    394381          ParticleUpdater = defaultParticleUpdater;
    395 
    396         ParameterizeTopologyUpdaters();
    397       }
    398     }
    399 
    400     private void ClearTopologyParameters() {
     382      }
     383    }
     384
     385    private void UpdateTopologyParameters() {
     386      ITopologyUpdater oldTopologyUpdater = TopologyUpdater;
    401387      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      }
    403400    }
    404401
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimizationMainLoop.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    122122      Placeholder evaluatorPlaceholder = new Placeholder();
    123123      Placeholder analyzerPlaceholder = new Placeholder();
     124      Placeholder analyzer2Placeholder = new Placeholder();
    124125      UniformSubScopesProcessor uniformSubScopeProcessor = new UniformSubScopesProcessor();
    125126      Placeholder particleUpdaterPlaceholder = new Placeholder();
     
    192193      conditionalBranch.ConditionParameter.ActualName = "ContinueIteration";
    193194      conditionalBranch.TrueBranch = analyzerPlaceholder;
     195      conditionalBranch.FalseBranch = analyzer2Placeholder;
     196
     197      analyzer2Placeholder.Name = "(Analyzer)";
     198      analyzer2Placeholder.OperatorParameter.ActualName = AnalyzerParameter.Name;
    194199      #endregion
    195200    }
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/Plugin.cs.frame

    r13321 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626  /// Plugin class for HeuristicLab.Algorithms.ParticleSwarmOptimization plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Algorithms.ParticleSwarmOptimization", "3.3.13.$WCREV$")]
     28  [Plugin("HeuristicLab.Algorithms.ParticleSwarmOptimization", "3.3.14.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/Properties/AssemblyInfo.cs.frame

    r13321 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3131[assembly: AssemblyCompany("")]
    3232[assembly: AssemblyProduct("HeuristicLab")]
    33 [assembly: AssemblyCopyright("(c) 2002-2015 HEAL")]
     33[assembly: AssemblyCopyright("(c) 2002-2016 HEAL")]
    3434[assembly: AssemblyTrademark("")]
    3535[assembly: AssemblyCulture("")]
     
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.13.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.3.14.$WCREV$")]
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RandomTopologyInitializer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Optimization;
    2728using HeuristicLab.Parameters;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
    3031namespace 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).")]
    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 + 1);
     68        selectedNumbers.Add(i);
     69        for (int j = 0; j < nrOfConnections && numbers.Count > 0; j++) {
     70          int index = random.Next(numbers.Count);
    7471          selectedNumbers.Add(numbers[index]);
    7572          numbers.RemoveAt(index);
     
    7774        neighbors[i] = new IntArray(selectedNumbers.ToArray());
    7875      }
    79       Neighbors = neighbors;
     76      NeighborsParameter.ActualValue = neighbors;
    8077      return base.Apply();
    8178    }
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RingTopologyInitializer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626
    2727namespace 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).")]
    2929  [StorableClass]
    3030  public sealed class RingTopologyInitializer : TopologyInitializer {
     
    4343
    4444    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 });
    4850      }
    49       Neighbors = neighbors;
     51      NeighborsParameter.ActualValue = neighbors;
    5052      return base.Apply();
    5153    }
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TopologyInitializer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4040      get { return (IScopeTreeLookupParameter<IntArray>)Parameters["Neighbors"]; }
    4141    }
    42 
    4342    public ILookupParameter<IntValue> SwarmSizeParameter {
    4443      get { return (ILookupParameter<IntValue>)Parameters["SwarmSize"]; }
    45     }
    46 
    47     #endregion
    48 
    49     #region Parameter Values
    50     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; }
    5644    }
    5745    #endregion
  • branches/Async/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/VonNeumannTopologyInitializer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626
    2727namespace 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).")]
    2929  [StorableClass]
    3030  public sealed class VonNeumannTopologyInitializer : TopologyInitializer {
     
    4444
    4545    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++) {
    4850        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
    5356        });
    5457      }
    55       Neighbors = neighbors;
     58      NeighborsParameter.ActualValue = neighbors;
    5659      return base.Apply();
    5760    }
Note: See TracChangeset for help on using the changeset viewer.