Index: trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorSwarmUpdater.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorSwarmUpdater.cs	(revision 5560)
+++ trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorSwarmUpdater.cs	(revision 5561)
@@ -25,7 +25,7 @@
 namespace HeuristicLab.Encodings.RealVectorEncoding {
   public interface IRealVectorSwarmUpdater : ISwarmUpdater, IRealVectorOperator {
-    ILookupParameter<RealVector> NeighborsBestParameter { get; }
-    ILookupParameter<RealVector> PersonalBestParameter { get; }
-    ILookupParameter<RealVector> RealVectorParameter { get; }
+    IScopeTreeLookupParameter<RealVector> NeighborsBestParameter { get; }
+    IScopeTreeLookupParameter<RealVector> PersonalBestParameter { get; }
+    IScopeTreeLookupParameter<RealVector> RealVectorParameter { get; }
   }
 }
Index: trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs	(revision 5560)
+++ trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs	(revision 5561)
@@ -20,4 +20,5 @@
 #endregion
 
+using System.Linq;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -36,47 +37,61 @@
 
     #region Parameter properties
-    public ILookupParameter<DoubleValue> QualityParameter {
-      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
-    }
-    public ILookupParameter<DoubleValue> PersonalBestQualityParameter {
-      get { return (ILookupParameter<DoubleValue>)Parameters["PersonalBestQuality"]; }
-    }
-    public ILookupParameter<DoubleValue> NeighborsBestQualityParameter {
-      get { return (ILookupParameter<DoubleValue>)Parameters["NeighborsBestQuality"]; }
-    }
-    public ILookupParameter<RealVector> RealVectorParameter {
-      get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
-    }
-    public ILookupParameter<RealVector> PersonalBestParameter {
-      get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
-    }
-    public ILookupParameter<RealVector> NeighborsBestParameter {
-      get { return (ILookupParameter<RealVector>)Parameters["NeighborsBest"]; }
+    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
+      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
+    }
+    public IScopeTreeLookupParameter<DoubleValue> PersonalBestQualityParameter {
+      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["PersonalBestQuality"]; }
+    }
+    public IScopeTreeLookupParameter<DoubleValue> NeighborsBestQualityParameter {
+      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["NeighborsBestQuality"]; }
+    }
+    public IScopeTreeLookupParameter<RealVector> RealVectorParameter {
+      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVector"]; }
+    }
+    public IScopeTreeLookupParameter<RealVector> PersonalBestParameter {
+      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["PersonalBest"]; }
+    }
+    public IScopeTreeLookupParameter<RealVector> NeighborsBestParameter {
+      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["NeighborsBest"]; }
     }
     public IValueLookupParameter<BoolValue> MaximizationParameter {
       get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
     }
+    public ILookupParameter<DoubleValue> BestQualityParameter {
+      get { return (ILookupParameter<DoubleValue>)Parameters["BestQuality"]; }
+    }
+    public ILookupParameter<RealVector> BestPointParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["BestPoint"]; }
+    }
+    public IScopeTreeLookupParameter<IntArray> NeighborsParameter {
+      get { return (IScopeTreeLookupParameter<IntArray>)Parameters["Neighbors"]; }
+    }
     #endregion
 
     #region Parameter values
-    private double Quality {
-      get { return QualityParameter.ActualValue.Value; }
-    }
-    private double PersonalBestQuality {
-      get { return PersonalBestQualityParameter.ActualValue.Value; }
-      set { PersonalBestQualityParameter.ActualValue = new DoubleValue(value); }
-    }
-    private double NeighborsBestQuality {
-      get { return NeighborsBestQualityParameter.ActualValue.Value; }
-      set { NeighborsBestQualityParameter.ActualValue = new DoubleValue(value); }
-    }
-    private RealVector RealVector {
+    private DoubleValue BestQuality {
+      get { return BestQualityParameter.ActualValue; }
+    }
+    private RealVector BestPoint {
+      get { return BestPointParameter.ActualValue; }
+      set { BestPointParameter.ActualValue = value; }
+    }
+    private ItemArray<DoubleValue> Quality {
+      get { return QualityParameter.ActualValue; }
+    }
+    private ItemArray<DoubleValue> PersonalBestQuality {
+      get { return PersonalBestQualityParameter.ActualValue; }
+    }
+    private ItemArray<DoubleValue> NeighborsBestQuality {
+      get { return NeighborsBestQualityParameter.ActualValue; }
+    }
+    private ItemArray<RealVector> RealVector {
       get { return RealVectorParameter.ActualValue; }
     }
-    private RealVector PersonalBest {
+    private ItemArray<RealVector> PersonalBest {
       get { return PersonalBestParameter.ActualValue; }
       set { PersonalBestParameter.ActualValue = value; }
     }
-    private RealVector NeighborsBest {
+    private ItemArray<RealVector> NeighborsBest {
       get { return NeighborsBestParameter.ActualValue; }
       set { NeighborsBestParameter.ActualValue = value; }
@@ -84,4 +99,7 @@
     private bool Maximization {
       get { return MaximizationParameter.ActualValue.Value; }
+    }
+    private ItemArray<IntArray> Neighbors {
+      get { return NeighborsParameter.ActualValue; }
     }
     #endregion
@@ -94,10 +112,13 @@
     public RealVectorSwarmUpdater()
       : base() {
-      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "Particle's quality"));
-      Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestQuality", "Particle's personal best quality"));
-      Parameters.Add(new LookupParameter<DoubleValue>("NeighborsBestQuality", "Global best particle quality"));
-      Parameters.Add(new LookupParameter<RealVector>("RealVector", "Particle's position"));
-      Parameters.Add(new LookupParameter<RealVector>("PersonalBest", "Particle's personal best position"));
-      Parameters.Add(new LookupParameter<RealVector>("NeighborsBest", "Neighborhood (or global in case of totally connected neighborhood) best particle position"));
+      Parameters.Add(new LookupParameter<DoubleValue>("BestQuality", "Overall best quality."));
+      Parameters.Add(new LookupParameter<RealVector>("BestPoint", "Global best particle position"));
+      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "Particle's quality"));
+      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("PersonalBestQuality", "Particle's personal best quality"));
+      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("NeighborsBestQuality", "Global best particle quality"));
+      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVector", "Particle's position"));
+      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("PersonalBest", "Particle's personal best position"));
+      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("NeighborsBest", "Neighborhood (or global in case of totally connected neighborhood) best particle position"));
+      Parameters.Add(new ScopeTreeLookupParameter<IntArray>("Neighbors", "The list of neighbors for each particle."));
       Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
     }
@@ -110,15 +131,74 @@
 
     public override IOperation Apply() {
-      if (Maximization && Quality > PersonalBestQuality ||
-         !Maximization && Quality < PersonalBestQuality) {
-        PersonalBestQuality = Quality;
-        PersonalBest = RealVector;
-        if (Maximization && PersonalBestQuality > NeighborsBestQuality ||
-           !Maximization && PersonalBestQuality < NeighborsBestQuality) {
-             NeighborsBestQuality = PersonalBestQuality;
-             NeighborsBest = PersonalBest;
-        }
-      }
+      InitializeBestPoint();
+      UpdateNeighbors();
+      UpdateVelocityBounds();
+      UpdateSwarm();
       return base.Apply();
+    }
+
+    private void InitializeBestPoint() {
+      if (BestQuality == null)
+        BestQualityParameter.ActualValue = new DoubleValue(); 
+      BestQuality.Value = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value);
+      int bestIndex = Quality.FindIndex(v => v.Value == BestQuality.Value);
+      BestPoint = (RealVector)RealVector[bestIndex].Clone();
+    }
+
+    private void UpdateNeighbors() {
+      if (Neighbors != null & Neighbors.Length > 0) {
+        if (this.NeighborsBest == null || NeighborsBest.Length != Neighbors.Length)
+          NeighborsBest = new ItemArray<RealVector>(Neighbors.Length);
+        for (int n = 0; n < Neighbors.Length; n++) {
+          var pairs = Quality.Zip(RealVector, (q, p) => new { Quality = q, Point = p })
+            .Where((p, i) => i == n || Neighbors[n].Contains(i));
+          NeighborsBest[n] = Maximization ?
+          pairs.OrderByDescending(p => p.Quality.Value).First().Point :
+          pairs.OrderBy(p => p.Quality.Value).First().Point;
+        }
+        NeighborsBestParameter.ActualValue = NeighborsBest;
+      }
+    }
+
+    private void UpdateVelocityBounds() {
+      // ToDo: Add code
+    }
+
+    private void UpdateSwarm() {
+      if (PersonalBestQuality.Length == 0) {
+        PersonalBestQualityParameter.ActualValue = new ItemArray<DoubleValue>(RealVector.Length);
+        for (int i = 0; i < RealVector.Length; i++) {
+          if (Maximization) {
+            PersonalBestQuality[i] = new DoubleValue();
+          } else {
+            PersonalBestQuality[i] = new DoubleValue(double.MaxValue); 
+          }
+        }
+      }
+      if (NeighborsBestQuality.Length == 0) {
+        NeighborsBestQualityParameter.ActualValue = new ItemArray<DoubleValue>(RealVector.Length);
+        for (int i = 0; i < RealVector.Length; i++) {
+          if (Maximization) {
+            NeighborsBestQuality[i] = new DoubleValue();
+          } else {
+            NeighborsBestQuality[i] = new DoubleValue(double.MaxValue);
+          }
+        }
+      }
+      if (NeighborsBest.Length == 0) {
+        NeighborsBestParameter.ActualValue = new ItemArray<RealVector>(RealVector.Length);
+      }
+      for (int i = 0; i < RealVector.Length; i++) {
+        if (Maximization && Quality[i].Value > PersonalBestQuality[i].Value ||
+          !Maximization && Quality[i].Value < PersonalBestQuality[i].Value) {
+          PersonalBestQuality[i].Value = Quality[i].Value;
+          PersonalBest[i] = RealVector[i];
+          if (Maximization && PersonalBestQuality[i].Value > NeighborsBestQuality[i].Value ||
+             !Maximization && PersonalBestQuality[i].Value < NeighborsBestQuality[i].Value) {
+            NeighborsBestQuality[i].Value = PersonalBestQuality[i].Value;
+            NeighborsBest[i] = PersonalBest[i];
+          }
+        }
+      }
     }
 
