Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5592 for trunk


Ignore:
Timestamp:
03/02/11 15:22:54 (14 years ago)
Author:
epitzer
Message:

Additional improvements to PSO (#852)

  • simplify and clean up RealVectorSwarmUpdater
  • make the RealVectorParticleCreator an AlgorithmOperator
  • standardize naming of local variables in ParticleUpdaters
  • remove default parameter values from main loop
  • new implementation of MultiPSOTopologyUpdater (using shuffling)
Location:
trunk/sources
Files:
7 edited

Legend:

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

    r5560 r5592  
    3131
    3232namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
    33   [Item("Multi PSO Topology Updater", "Splits swarm into swarmsize / (nrOfConnections + 1) 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.")]
     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.")]
    3434  [StorableClass]
    3535  public sealed class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater {
     36
    3637    public override bool CanChangeName {
    3738      get { return false; }
     
    4243      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
    4344    }
    44     public IValueLookupParameter<IntValue> NrOfConnectionsParameter {
    45       get { return (IValueLookupParameter<IntValue>)Parameters["NrOfConnections"]; }
     45    public IValueLookupParameter<IntValue> NrOfSwarmsParameter {
     46      get { return (IValueLookupParameter<IntValue>)Parameters["NrOfSwarms"]; }
    4647    }
    4748    public ILookupParameter<IntValue> SwarmSizeParameter {
     
    6364      get { return RandomParameter.ActualValue; }
    6465    }
    65     private int NrOfConnections {
    66       get { return NrOfConnectionsParameter.ActualValue.Value; }
     66    private int NrOfSwarms {
     67      get { return NrOfSwarmsParameter.ActualValue.Value; }
    6768    }
    6869    private int SwarmSize {
     
    8182    #endregion
    8283
     84    #region Construction & Cloning
    8385    [StorableConstructor]
    8486    private MultiPSOTopologyUpdater(bool deserializing) : base(deserializing) { }
    8587    private MultiPSOTopologyUpdater(MultiPSOTopologyUpdater original, Cloner cloner) : base(original, cloner) { }
    86    
    8788    public MultiPSOTopologyUpdater()
    8889      : base() {
    8990      Parameters.Add(new LookupParameter<IRandom>("Random", "A random number generator."));
    90       Parameters.Add(new ValueLookupParameter<IntValue>("NrOfConnections", "Nr of connected neighbors.", new IntValue(3)));
     91      Parameters.Add(new ValueLookupParameter<IntValue>("NrOfSwarms", "Nr of connected sub-swarms.", new IntValue(3)));
    9192      Parameters.Add(new LookupParameter<IntValue>("SwarmSize", "Number of particles in the swarm."));
    9293      Parameters.Add(new ScopeTreeLookupParameter<IntArray>("Neighbors", "The list of neighbors for each particle."));
     
    9495      Parameters.Add(new ValueLookupParameter<IntValue>("RegroupingPeriod", "Update interval (=iterations) for regrouping of neighborhoods.", new IntValue(5)));
    9596    }
    96 
    9797    public override IDeepCloneable Clone(Cloner cloner) {
    9898      return new MultiPSOTopologyUpdater(this, cloner);
    9999    }
     100    #endregion
    100101
    101     // Splits the swarm into non-overlapping sub swarms
    102102    public override IOperation Apply() {
    103103      if (CurrentIteration > 0 && CurrentIteration % RegroupingPeriod == 0) {
    104104        ItemArray<IntArray> neighbors = new ItemArray<IntArray>(SwarmSize);
    105         Dictionary<int, List<int>> neighborsPerParticle = new Dictionary<int, List<int>>();
    106         for (int i = 0; i < SwarmSize; i++) {
    107           neighborsPerParticle.Add(i, new List<int>());
     105
     106        var particles = Enumerable.Range(0, SwarmSize).ToList();
     107        for (int i = SwarmSize-1; i>0; i--) {
     108          int j = Random.Next(i+1);
     109          int t = particles[j];
     110          particles[j] = particles[i];
     111          particles[i] = t;
    108112        }
    109113
    110         // partition swarm into groups
    111         Dictionary<int, List<int>> groups = new Dictionary<int, List<int>>();
    112         int groupId = 0;
    113         var numbers = Enumerable.Range(0, SwarmSize).ToList();
    114         for (int i = 0; i < SwarmSize; i++) {
    115           int nextParticle = numbers[Random.Next(0, numbers.Count)];
    116           if (!groups.ContainsKey(groupId)) {
    117             groups.Add(groupId, new List<int>());
    118           }
    119           groups[groupId].Add(nextParticle);
    120           if (groups[groupId].Count - 1 == NrOfConnections) {
    121             groupId++;
    122           }
    123           numbers.Remove(nextParticle);
     114        for (int partitionNr = 0; partitionNr<NrOfSwarms; partitionNr++) {
     115          int start = partitionNr*SwarmSize/NrOfSwarms;
     116          int end = (partitionNr+1)*SwarmSize/NrOfSwarms;
     117          for (int i = start; i<end; i++)
     118            neighbors[particles[i]] = GetSegment(particles, start, end, i);
    124119        }
    125120
    126         // add neighbors to each particle
    127         foreach (List<int> group in groups.Values) {
    128           foreach (int sib1 in group) {
    129             foreach (int sib2 in group) {
    130               if (sib1 != sib2 && !neighborsPerParticle[sib1].Contains(sib2)) {
    131                 neighborsPerParticle[sib1].Add(sib2);
    132               }
    133             }
    134           }
    135         }
    136 
    137         for (int particle = 0; particle < neighborsPerParticle.Count; particle++) {
    138           neighbors[particle] = new IntArray(neighborsPerParticle[particle].ToArray());
    139         }
    140121        Neighbors = neighbors;
    141122      }
    142123      return base.Apply();
    143124    }
     125
     126    public static IntArray GetSegment(IEnumerable<int> list, int start, int end, int excludedIndex) {
     127      return new IntArray(list
     128        .Skip(start)
     129        .Take(end-start)
     130        .Where((p, j) => start+j != excludedIndex)
     131        .ToArray());
     132    }
    144133  }
    145134}
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimizationMainLoop.cs

    r5581 r5592  
    3333  [StorableClass]
    3434  public class ParticleSwarmOptimizationMainLoop : AlgorithmOperator {
     35
    3536    #region Parameter Properties
    3637    public IValueLookupParameter<IRandom> RandomParameter {
     
    9697      #region Create parameters
    9798      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
    98       Parameters.Add(new ValueLookupParameter<IntValue>("SwarmSize", "Size of the particle swarm.", new IntValue(10)));
    99       Parameters.Add(new ValueLookupParameter<IntValue>("MaxIterations", "Maximal number of iterations.", new IntValue(1000)));
     99      Parameters.Add(new ValueLookupParameter<IntValue>("SwarmSize", "Size of the particle swarm."));
     100      Parameters.Add(new ValueLookupParameter<IntValue>("MaxIterations", "Maximal number of iterations."));
    100101
    101102      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorNeighborhoodParticleUpdater.cs

    r5568 r5592  
    3030  public sealed class RealVectorNeighborhoodParticleUpdater : RealVectorParticleUpdater, ILocalParticleUpdater {
    3131
     32    #region Construction & Cloning
    3233    [StorableConstructor]
    3334    private RealVectorNeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { }
    3435    private RealVectorNeighborhoodParticleUpdater(RealVectorNeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { }
    3536    public RealVectorNeighborhoodParticleUpdater() : base() { }
    36 
    3737    public override IDeepCloneable Clone(Cloner cloner) {
    3838      return new RealVectorNeighborhoodParticleUpdater(this, cloner);
    3939    }
     40    #endregion
    4041
    4142    public override IOperation Apply() {
     43      double inertia = Inertia.Value;
     44      double personalBestAttraction = PersonalBestAttraction.Value;
     45      double neighborBestAttraction = NeighborBestAttraction.Value;
     46
    4247      RealVector velocity = new RealVector(Velocity.Length);
    4348      RealVector position = new RealVector(RealVector.Length);
    4449      double r_p = Random.NextDouble();
    4550      double r_g = Random.NextDouble();
    46       double omega = Inertia.Value;
    47       double phi_p = PersonalBestAttraction.Value;
    48       double phi_g = NeighborBestAttraction.Value;
     51
    4952      for (int i = 0; i < velocity.Length; i++) {
    5053        velocity[i] =
    51           Velocity[i] * omega +
    52           (PersonalBest[i] - RealVector[i]) * phi_p * r_p +
    53           (BestPoint[i] - RealVector[i]) * phi_g * r_g;
     54          Velocity[i] * inertia +
     55          (PersonalBest[i] - RealVector[i]) * personalBestAttraction * r_p +
     56          (BestPoint[i] - RealVector[i]) * neighborBestAttraction * r_g;
    5457      }
     58
    5559      BoundsChecker.Apply(velocity, VelocityBounds);
    5660      for (int i = 0; i < velocity.Length; i++) {
     
    5862      }
    5963      BoundsChecker.Apply(position, Bounds);
     64
    6065      RealVector = position;
    6166      Velocity = velocity;
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleCreator.cs

    r5560 r5592  
    2020#endregion
    2121
    22 using System;
    23 using HeuristicLab.Operators;
     22using HeuristicLab.Common;
    2423using HeuristicLab.Core;
    2524using HeuristicLab.Data;
     25using HeuristicLab.Operators;
    2626using HeuristicLab.Parameters;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Optimization;
    3028
    3129namespace HeuristicLab.Encodings.RealVectorEncoding {
    3230  [Item("RealVectorParticleCreator", "Creates a particle with position, zero velocity vector and personal best.")]
    3331  [StorableClass]
    34   public class RealVectorParticleCreator : SingleSuccessorOperator, IRealVectorParticleCreator {
    35     #region IRealVectorParticleCreator Members
     32  public class RealVectorParticleCreator : AlgorithmOperator, IRealVectorParticleCreator {
     33
     34    #region Parameters
    3635    public ILookupParameter<IntValue> ProblemSizeParameter {
    37      get { return (ILookupParameter<IntValue>)Parameters["ProblemSize"]; }
     36      get { return (ILookupParameter<IntValue>)Parameters["ProblemSize"]; }
    3837    }
    39 
     38    public IValueLookupParameter<DoubleMatrix> BoundsParameter {
     39      get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
     40    }
    4041    public ILookupParameter<RealVector> RealVectorParameter {
    4142      get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
    4243    }
    43 
    4444    public ILookupParameter<RealVector> PersonalBestParameter {
    4545      get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
    4646    }
    47 
    48     public IValueLookupParameter<DoubleMatrix> BoundsParameter {
    49       get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    50     }
    51 
    5247    public ILookupParameter<RealVector> VelocityParameter {
    5348      get { return (ILookupParameter<RealVector>)Parameters["Velocity"]; }
    5449    }
    55 
    5650    #endregion
    5751
    58     public RealVectorParticleCreator() : base() {
     52    #region Parameter Values
     53    protected int ProblemSize {
     54      get { return ProblemSizeParameter.ActualValue.Value; }
     55    }
     56    protected RealVector Velocity {
     57      set { VelocityParameter.ActualValue = value; }
     58    }
     59    #endregion
     60
     61    #region Construction & Cloning
     62    [StorableConstructor]
     63    protected RealVectorParticleCreator(bool deserializing) : base(deserializing) { }
     64    protected RealVectorParticleCreator(RealVectorParticleCreator original, Cloner cloner) : base(original, cloner) { }
     65    public RealVectorParticleCreator()
     66      : base() {
    5967      Parameters.Add(new LookupParameter<IntValue>("ProblemSize", "The dimension of the problem."));
    6068      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension."));
    6169      Parameters.Add(new LookupParameter<RealVector>("RealVector", "Particle's current solution"));
    6270      Parameters.Add(new LookupParameter<RealVector>("PersonalBest", "Particle's personal best solution."));
    63       Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));   
    64     }
     71      Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));
    6572
    66     public override IOperation Apply() {
    67       VelocityParameter.ActualValue = new RealVector(ProblemSizeParameter.ActualValue.Value);
    68       UniformRandomRealVectorCreator realVectorCreater = new UniformRandomRealVectorCreator();
     73      UniformRandomRealVectorCreator realVectorCreater = new UniformRandomRealVectorCreator();
    6974      Assigner personalBestPositionAssigner = new Assigner();
    7075
    71       this.Name = "Particle Creator";
     76      OperatorGraph.InitialOperator = realVectorCreater;
    7277
    73       //realVectorCreater.Name = "(SolutionCreator)";
    74       realVectorCreater.RealVectorParameter.ActualName = "RealVector";
     78      realVectorCreater.RealVectorParameter.ActualName = RealVectorParameter.Name;
    7579      realVectorCreater.LengthParameter.ActualName = ProblemSizeParameter.Name;
    76       realVectorCreater.BoundsParameter.ActualName = BoundsParameter.Name; 
     80      realVectorCreater.BoundsParameter.ActualName = BoundsParameter.Name;
    7781      realVectorCreater.Successor = personalBestPositionAssigner;
    7882
    79       personalBestPositionAssigner.LeftSideParameter.ActualName = "PersonalBest";
    80       personalBestPositionAssigner.RightSideParameter.ActualName = "RealVector";
    81       personalBestPositionAssigner.Successor = null;
    82 
    83       OperationCollection next = new OperationCollection();
    84       next.Add(ExecutionContext.CreateChildOperation(realVectorCreater));
    85       next.Add(base.Apply());
    86       return next;
     83      personalBestPositionAssigner.LeftSideParameter.ActualName = PersonalBestParameter.Name;
     84      personalBestPositionAssigner.RightSideParameter.ActualName = RealVectorParameter.Name;
     85      personalBestPositionAssigner.Successor = null;
    8786    }
    88 
    8987    public override IDeepCloneable Clone(Cloner cloner) {
    9088      return new RealVectorParticleCreator(this, cloner);
    9189    }
     90    #endregion
    9291
    93     protected RealVectorParticleCreator(RealVectorParticleCreator original, Cloner cloner)
    94       : base(original, cloner) {
     92    public override IOperation Apply() {
     93      Velocity = new RealVector(ProblemSize);
     94      return base.Apply();
    9595    }
    9696
    97     [StorableConstructor]
    98     protected RealVectorParticleCreator(bool deserializing) : base(deserializing) { }
     97
    9998  }
    10099}
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleUpdater.cs

    r5568 r5592  
    2828
    2929namespace HeuristicLab.Encodings.RealVectorEncoding {
     30
    3031  [Item("RealVectorParticleUpdater", "Updates a certain particle taking the current position and velocity into account, as well as the best point and the best point in a local neighborhood.")]
    3132  [StorableClass]
    3233  public abstract class RealVectorParticleUpdater : SingleSuccessorOperator, IRealVectorParticleUpdater {
     34
    3335    public override bool CanChangeName {
    3436      get { return false; }
     
    110112
    111113    #region Construction & Cloning
    112 
    113114    [StorableConstructor]
    114115    protected RealVectorParticleUpdater(bool deserializing) : base(deserializing) { }
    115116    protected RealVectorParticleUpdater(RealVectorParticleUpdater original, Cloner cloner) : base(original, cloner) { }
    116 
    117117    public RealVectorParticleUpdater()
    118118      : base() {
     
    129129      Parameters.Add(new LookupParameter<DoubleValue>("NeighborBestAttraction", "The weight for the global best position."));
    130130    }
    131 
    132131    #endregion
    133132  }
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs

    r5581 r5592  
    3333  [StorableClass]
    3434  public sealed class RealVectorSwarmUpdater : SingleSuccessorOperator, IRealVectorSwarmUpdater {
     35
    3536    public override bool CanChangeName {
    3637      get { return false; }
     
    7980    private DoubleValue BestQuality {
    8081      get { return BestQualityParameter.ActualValue; }
     82      set { BestQualityParameter.ActualValue = value; }
    8183    }
    8284    private RealVector BestPoint {
     
    149151
    150152    public override IOperation Apply() {
    151       InitializeBestPoint();
    152       UpdateNeighbors();
    153       UpdateSwarm();
    154       if (VelocityBoundsUpdater != null) {
    155         var ops = new OperationCollection();
    156         ops.Add(ExecutionContext.CreateChildOperation(VelocityBoundsUpdater));
    157         ops.Add(ExecutionContext.CreateOperation(Successor));
    158         return ops;
    159       } else {
    160         return base.Apply();
    161       }
    162     }
    163 
    164     private void InitializeBestPoint() {
     153      UpdateGlobalBest();
     154      UpdateNeighborBest();
     155      UpdatePersonalBest();
     156      return UpdateVelocityBounds();
     157    }
     158
     159    private void UpdateGlobalBest() {
    165160      if (BestQuality == null)
    166         BestQualityParameter.ActualValue = new DoubleValue();
     161        BestQuality = new DoubleValue();
    167162      BestQuality.Value = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value);
    168       int bestIndex = Quality.FindIndex(v => v.Value == BestQuality.Value);
    169       BestPoint = (RealVector)RealVector[bestIndex].Clone();
    170     }
    171 
    172     private void UpdateNeighbors() {
    173       if (Neighbors != null & Neighbors.Length > 0) {
    174         if (this.NeighborBest == null || NeighborBest.Length != Neighbors.Length)
    175           NeighborBest = new ItemArray<RealVector>(Neighbors.Length);
     163      BestPoint = (RealVector)RealVector[Quality.FindIndex(v => v.Value == BestQuality.Value)].Clone();
     164    }
     165
     166    private void UpdateNeighborBest() {
     167      if (Neighbors.Length > 0) {
     168        var neighborBest = new ItemArray<RealVector>(Neighbors.Length);
     169        var neighborBestQuality = new ItemArray<DoubleValue>(Neighbors.Length);
    176170        for (int n = 0; n < Neighbors.Length; n++) {
    177171          var pairs = Quality.Zip(RealVector, (q, p) => new { Quality = q, Point = p })
    178172            .Where((p, i) => i == n || Neighbors[n].Contains(i));
    179           NeighborBest[n] = Maximization ?
    180           pairs.OrderByDescending(p => p.Quality.Value).First().Point :
    181           pairs.OrderBy(p => p.Quality.Value).First().Point;
     173          var bestNeighbor = Maximization ?
     174            pairs.OrderByDescending(p => p.Quality.Value).First() :
     175            pairs.OrderBy(p => p.Quality.Value).First();
     176          neighborBest[n] = bestNeighbor.Point;
     177          neighborBestQuality[n] = bestNeighbor.Quality;
    182178        }
    183         NeighborBestParameter.ActualValue = NeighborBest;
     179        NeighborBest = neighborBest;
     180        NeighborBestQuality = neighborBestQuality;
    184181      }
    185182    }
    186183
    187     private void UpdateSwarm() {
    188       if (PersonalBestQuality.Length == 0) {
     184    private void UpdatePersonalBest() {
     185      if (PersonalBestQuality.Length == 0)
    189186        PersonalBestQuality = (ItemArray<DoubleValue>)Quality.Clone();
    190         if (VelocityBounds == null)
    191           VelocityBounds = new DoubleMatrix(new double[,] { { -1, 1 } });
    192       }
    193187      for (int i = 0; i < RealVector.Length; i++) {
    194188        if (Maximization && Quality[i].Value > PersonalBestQuality[i].Value ||
     
    198192        }
    199193      }
    200       if (Neighbors.Length > 0) {
    201         var neighborBestQuality = NeighborBestQuality;
    202         var neighborBest = NeighborBest;
    203         if (NeighborBestQuality.Length == 0) {
    204           neighborBestQuality = (ItemArray<DoubleValue>)Quality.Clone();
    205           neighborBest = (ItemArray<RealVector>)RealVector.Clone();
    206         }
    207         for (int i = 0; i < RealVector.Length; i++) {
    208           if (Maximization && PersonalBestQuality[i].Value > neighborBestQuality[i].Value ||
    209              !Maximization && PersonalBestQuality[i].Value < neighborBestQuality[i].Value) {
    210             neighborBestQuality[i].Value = PersonalBestQuality[i].Value;
    211             neighborBest[i] = PersonalBest[i];
    212           }
    213         }
    214         NeighborBestQuality = neighborBestQuality;
    215         NeighborBest = neighborBest;
    216       }
     194    }
     195
     196    private IOperation UpdateVelocityBounds() {
     197      if (VelocityBounds == null)
     198        VelocityBounds = new DoubleMatrix(new double[,] { { -1, 1 } });
     199      return VelocityBoundsUpdater == null ?
     200        base.Apply() :
     201        new OperationCollection() {
     202          ExecutionContext.CreateChildOperation(VelocityBoundsUpdater),
     203          ExecutionContext.CreateOperation(Successor)
     204        };
    217205    }
    218206  }
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorTotallyConnectedParticleUpdater.cs

    r5568 r5592  
    3131
    3232    #region Construction & Cloning
    33 
    3433    [StorableConstructor]
    3534    private RealVectorTotallyConnectedParticleUpdater(bool deserializing) : base(deserializing) { }
    3635    private RealVectorTotallyConnectedParticleUpdater(RealVectorTotallyConnectedParticleUpdater original, Cloner cloner) : base(original, cloner) { }
    3736    public RealVectorTotallyConnectedParticleUpdater() : base() { }
    38 
    3937    public override IDeepCloneable Clone(Cloner cloner) {
    4038      return new RealVectorTotallyConnectedParticleUpdater(this, cloner);
    4139    }
    42 
    4340    #endregion
    4441
    4542    public override IOperation Apply() {
    46       base.Apply();
     43      double inertia = Inertia.Value;
     44      double personalBestAttraction = PersonalBestAttraction.Value;
     45      double neighborBestAttraction = NeighborBestAttraction.Value;
     46
    4747      RealVector velocity = new RealVector(Velocity.Length);
    4848      RealVector position = new RealVector(RealVector.Length);
    4949      double r_p = Random.NextDouble();
    5050      double r_g = Random.NextDouble();
    51       double omega = Inertia.Value;
    52       double phi_p = PersonalBestAttraction.Value;
    53       double phi_g = NeighborBestAttraction.Value;
     51
    5452      for (int i = 0; i < velocity.Length; i++) {
    5553        velocity[i] =
    56           Velocity[i] * omega +
    57           (PersonalBest[i] - RealVector[i]) * phi_p * r_p +
    58           (BestPoint[i] - RealVector[i]) * phi_g * r_g;
     54          Velocity[i] * inertia +
     55          (PersonalBest[i] - RealVector[i]) * personalBestAttraction * r_p +
     56          (BestPoint[i] - RealVector[i]) * neighborBestAttraction * r_g;
    5957      }
     58
    6059      BoundsChecker.Apply(velocity, VelocityBounds);
    6160      for (int i = 0; i < velocity.Length; i++) {
     
    6362      }
    6463      BoundsChecker.Apply(position, Bounds);
     64
    6565      RealVector = position;
    6666      Velocity = velocity;
Note: See TracChangeset for help on using the changeset viewer.