Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj	(revision 5681)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj	(revision 5796)
@@ -104,4 +104,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ParticleOperators\RealVectorParticleCreator.cs" />
     <Compile Include="Crossovers\BlendAlphaBetaCrossover.cs" />
     <Compile Include="Interfaces\IRealVectorManipulator.cs" />
@@ -111,5 +112,12 @@
     <Compile Include="BoundsChecker.cs" />
     <Compile Include="Creators\UniformRandomRealVectorCreator.cs" />
+    <Compile Include="Interfaces\IRealVectorParticleCreator.cs" />
+    <Compile Include="Interfaces\IRealVectorParticleUpdater.cs" />
+    <Compile Include="Interfaces\IRealVectorSwarmUpdater.cs" />
     <Compile Include="Manipulators\SelfAdaptiveNormalAllPositionsManipulator.cs" />
+    <Compile Include="ParticleOperators\RealVectorNeighborhoodParticleUpdater.cs" />
+    <Compile Include="ParticleOperators\RealVectorParticleUpdater.cs" />
+    <Compile Include="ParticleOperators\RealVectorSwarmUpdater.cs" />
+    <Compile Include="ParticleOperators\RealVectorTotallyConnectedParticleUpdater.cs" />
     <Compile Include="RealVectorCreator.cs" />
     <Compile Include="RealVectorCrossover.cs" />
@@ -230,4 +238,5 @@
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorParticleCreator.cs
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorParticleCreator.cs	(revision 5796)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorParticleCreator.cs	(revision 5796)
@@ -0,0 +1,34 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Optimization;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Encodings.RealVectorEncoding {
+  public interface IRealVectorParticleCreator : IParticleCreator, IRealVectorOperator {
+    ILookupParameter<IntValue> ProblemSizeParameter { get; }
+    ILookupParameter<RealVector> RealVectorParameter { get; }
+    ILookupParameter<RealVector> PersonalBestParameter { get; }
+    IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
+    ILookupParameter<RealVector> VelocityParameter { get; }
+  }
+}
Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorParticleUpdater.cs
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorParticleUpdater.cs	(revision 5796)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorParticleUpdater.cs	(revision 5796)
@@ -0,0 +1,35 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+
+namespace HeuristicLab.Encodings.RealVectorEncoding {
+  public interface IRealVectorParticleUpdater : IParticleUpdater, IRealVectorOperator {
+    ILookupParameter<RealVector> VelocityParameter { get; }
+    ILookupParameter<DoubleMatrix> VelocityBoundsParameter { get; }
+    ILookupParameter<RealVector> RealVectorParameter { get; }
+    ILookupParameter<DoubleMatrix> BoundsParameter { get; }
+    ILookupParameter<RealVector> PersonalBestParameter { get; }
+    ILookupParameter<RealVector> NeighborBestParameter { get; }
+  }
+}
Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorSwarmUpdater.cs
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorSwarmUpdater.cs	(revision 5796)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorSwarmUpdater.cs	(revision 5796)
@@ -0,0 +1,31 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Core;
+using HeuristicLab.Optimization; 
+
+namespace HeuristicLab.Encodings.RealVectorEncoding {
+  public interface IRealVectorSwarmUpdater : ISwarmUpdater, IRealVectorOperator {
+    IScopeTreeLookupParameter<RealVector> NeighborBestParameter { get; }
+    IScopeTreeLookupParameter<RealVector> PersonalBestParameter { get; }
+    IScopeTreeLookupParameter<RealVector> RealVectorParameter { get; }
+  }
+}
Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorNeighborhoodParticleUpdater.cs
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorNeighborhoodParticleUpdater.cs	(revision 5796)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorNeighborhoodParticleUpdater.cs	(revision 5796)
@@ -0,0 +1,71 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Optimization;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.RealVectorEncoding {
+  [Item("Neighborhood Particle Updater", "Updates the particle's position using (among other things) the best neighbor's position. Point = Point + Velocity*Inertia + (PersonalBestPoint-Point)*Phi_P*r_p + (BestNeighborPoint-Point)*Phi_G*r_g.")]
+  [StorableClass]
+  public sealed class RealVectorNeighborhoodParticleUpdater : RealVectorParticleUpdater, ILocalParticleUpdater {
+
+    #region Construction & Cloning
+    [StorableConstructor]
+    private RealVectorNeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { }
+    private RealVectorNeighborhoodParticleUpdater(RealVectorNeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { }
+    public RealVectorNeighborhoodParticleUpdater() : base() { }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RealVectorNeighborhoodParticleUpdater(this, cloner);
+    }
+    #endregion
+
+    public override IOperation Apply() {
+      double inertia = Inertia.Value;
+      double personalBestAttraction = PersonalBestAttraction.Value;
+      double neighborBestAttraction = NeighborBestAttraction.Value;
+
+      RealVector velocity = new RealVector(Velocity.Length);
+      RealVector position = new RealVector(RealVector.Length);
+      double r_p = Random.NextDouble();
+      double r_g = Random.NextDouble();
+
+      for (int i = 0; i < velocity.Length; i++) {
+        velocity[i] =
+          Velocity[i] * inertia +
+          (PersonalBest[i] - RealVector[i]) * personalBestAttraction * r_p +
+          (BestPoint[i] - RealVector[i]) * neighborBestAttraction * r_g;
+      }
+
+      BoundsChecker.Apply(velocity, VelocityBounds);
+      for (int i = 0; i < velocity.Length; i++) {
+        position[i] = RealVector[i] + velocity[i];
+      }
+      BoundsChecker.Apply(position, Bounds);
+
+      RealVector = position;
+      Velocity = velocity;
+
+      return base.Apply();
+    }
+  }
+}
Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleCreator.cs
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleCreator.cs	(revision 5796)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleCreator.cs	(revision 5796)
@@ -0,0 +1,99 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.RealVectorEncoding {
+  [Item("RealVectorParticleCreator", "Creates a particle with position, zero velocity vector and personal best.")]
+  [StorableClass]
+  public class RealVectorParticleCreator : AlgorithmOperator, IRealVectorParticleCreator {
+
+    #region Parameters
+    public ILookupParameter<IntValue> ProblemSizeParameter {
+      get { return (ILookupParameter<IntValue>)Parameters["ProblemSize"]; }
+    }
+    public IValueLookupParameter<DoubleMatrix> BoundsParameter {
+      get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
+    }
+    public ILookupParameter<RealVector> RealVectorParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
+    }
+    public ILookupParameter<RealVector> PersonalBestParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
+    }
+    public ILookupParameter<RealVector> VelocityParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["Velocity"]; }
+    }
+    #endregion
+
+    #region Parameter Values
+    protected int ProblemSize {
+      get { return ProblemSizeParameter.ActualValue.Value; }
+    }
+    protected RealVector Velocity {
+      set { VelocityParameter.ActualValue = value; }
+    }
+    #endregion
+
+    #region Construction & Cloning
+    [StorableConstructor]
+    protected RealVectorParticleCreator(bool deserializing) : base(deserializing) { }
+    protected RealVectorParticleCreator(RealVectorParticleCreator original, Cloner cloner) : base(original, cloner) { }
+    public RealVectorParticleCreator()
+      : base() {
+      Parameters.Add(new LookupParameter<IntValue>("ProblemSize", "The dimension of the problem."));
+      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension."));
+      Parameters.Add(new LookupParameter<RealVector>("RealVector", "Particle's current solution"));
+      Parameters.Add(new LookupParameter<RealVector>("PersonalBest", "Particle's personal best solution."));
+      Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));
+
+      UniformRandomRealVectorCreator realVectorCreater = new UniformRandomRealVectorCreator();
+      Assigner personalBestPositionAssigner = new Assigner();
+
+      OperatorGraph.InitialOperator = realVectorCreater;
+
+      realVectorCreater.RealVectorParameter.ActualName = RealVectorParameter.Name;
+      realVectorCreater.LengthParameter.ActualName = ProblemSizeParameter.Name;
+      realVectorCreater.BoundsParameter.ActualName = BoundsParameter.Name;
+      realVectorCreater.Successor = personalBestPositionAssigner;
+
+      personalBestPositionAssigner.LeftSideParameter.ActualName = PersonalBestParameter.Name;
+      personalBestPositionAssigner.RightSideParameter.ActualName = RealVectorParameter.Name;
+      personalBestPositionAssigner.Successor = null;
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RealVectorParticleCreator(this, cloner);
+    }
+    #endregion
+
+    public override IOperation Apply() {
+      Velocity = new RealVector(ProblemSize);
+      return base.Apply();
+    }
+
+
+  }
+}
Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleUpdater.cs
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleUpdater.cs	(revision 5796)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleUpdater.cs	(revision 5796)
@@ -0,0 +1,133 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.RealVectorEncoding {
+
+  [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.")]
+  [StorableClass]
+  public abstract class RealVectorParticleUpdater : SingleSuccessorOperator, IRealVectorParticleUpdater {
+
+    public override bool CanChangeName {
+      get { return false; }
+    }
+
+    #region Parameter properties
+    public ILookupParameter<IRandom> RandomParameter {
+      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
+    }
+    public ILookupParameter<RealVector> VelocityParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["Velocity"]; }
+    }
+    public ILookupParameter<RealVector> PersonalBestParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["PersonalBest"]; }
+    }
+    public ILookupParameter<RealVector> NeighborBestParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["NeighborBest"]; }
+    }
+    public LookupParameter<RealVector> BestRealVectorParameter {
+      get { return (LookupParameter<RealVector>)Parameters["BestRealVector"]; }
+    }
+    public ILookupParameter<RealVector> RealVectorParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
+    }
+    public ILookupParameter<DoubleMatrix> BoundsParameter {
+      get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
+    }
+    public ILookupParameter<DoubleMatrix> VelocityBoundsParameter {
+      get { return (ILookupParameter<DoubleMatrix>)Parameters["VelocityBounds"]; }
+    }
+    public ILookupParameter<DoubleValue> InertiaParameter {
+      get { return (ILookupParameter<DoubleValue>)Parameters["CurrentInertia"]; }
+    }
+    public ILookupParameter<DoubleValue> PersonalBestAttractionParameter {
+      get { return (ILookupParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; }
+    }
+    public ILookupParameter<DoubleValue> NeighborBestAttractionParameter {
+      get { return (ILookupParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; }
+    }
+    #endregion
+
+    #region Parameter Values
+    protected IRandom Random {
+      get { return RandomParameter.ActualValue; }
+    }
+    protected RealVector Velocity {
+      get { return VelocityParameter.ActualValue; }
+      set { VelocityParameter.ActualValue = value; }
+    }
+    protected RealVector PersonalBest {
+      get { return PersonalBestParameter.ActualValue; }
+    }
+    protected RealVector BestPoint {
+      get { return BestRealVectorParameter.ActualValue; }
+    }
+    protected RealVector RealVector {
+      get { return RealVectorParameter.ActualValue; }
+      set { RealVectorParameter.ActualValue = value; }
+    }
+    protected RealVector NeighborBest {
+      get { return NeighborBestParameter.ActualValue; }
+    }
+    protected DoubleMatrix Bounds {
+      get { return BoundsParameter.ActualValue; }
+    }
+    protected DoubleMatrix VelocityBounds {
+      get { return VelocityBoundsParameter.ActualValue; }
+    }
+    protected DoubleValue Inertia {
+      get { return InertiaParameter.ActualValue; }
+    }
+    protected DoubleValue PersonalBestAttraction {
+      get { return PersonalBestAttractionParameter.ActualValue; }
+    }
+    protected DoubleValue NeighborBestAttraction {
+      get { return NeighborBestAttractionParameter.ActualValue; }
+    }
+    #endregion
+
+    #region Construction & Cloning
+    [StorableConstructor]
+    protected RealVectorParticleUpdater(bool deserializing) : base(deserializing) { }
+    protected RealVectorParticleUpdater(RealVectorParticleUpdater original, Cloner cloner) : base(original, cloner) { }
+    public RealVectorParticleUpdater()
+      : base() {
+      Parameters.Add(new LookupParameter<IRandom>("Random", "Random number generator."));
+      Parameters.Add(new LookupParameter<RealVector>("RealVector", "Particle's current solution"));
+      Parameters.Add(new LookupParameter<RealVector>("Velocity", "Particle's current velocity."));
+      Parameters.Add(new LookupParameter<RealVector>("PersonalBest", "Particle's personal best solution."));
+      Parameters.Add(new LookupParameter<RealVector>("BestRealVector", "Global best position."));
+      Parameters.Add(new LookupParameter<RealVector>("NeighborBest", "Best neighboring solution."));
+      Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
+      Parameters.Add(new LookupParameter<DoubleMatrix>("VelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
+      Parameters.Add(new LookupParameter<DoubleValue>("CurrentInertia", "The weight for the particle's velocity vector."));
+      Parameters.Add(new LookupParameter<DoubleValue>("PersonalBestAttraction", "The weight for the particle's personal best position."));
+      Parameters.Add(new LookupParameter<DoubleValue>("NeighborBestAttraction", "The weight for the global best position."));
+    }
+    #endregion
+  }
+}
Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs	(revision 5796)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs	(revision 5796)
@@ -0,0 +1,207 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.RealVectorEncoding {
+  [Item("Swarm Updater", "Updates personal best point and quality as well as global best point and quality.")]
+  [StorableClass]
+  public sealed class RealVectorSwarmUpdater : SingleSuccessorOperator, IRealVectorSwarmUpdater {
+
+    public override bool CanChangeName {
+      get { return false; }
+    }
+
+    #region Parameter properties
+    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
+      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
+    }
+    public IScopeTreeLookupParameter<DoubleValue> PersonalBestQualityParameter {
+      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["PersonalBestQuality"]; }
+    }
+    public IScopeTreeLookupParameter<DoubleValue> NeighborBestQualityParameter {
+      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["NeighborBestQuality"]; }
+    }
+    public IScopeTreeLookupParameter<RealVector> RealVectorParameter {
+      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVector"]; }
+    }
+    public IScopeTreeLookupParameter<RealVector> PersonalBestParameter {
+      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["PersonalBest"]; }
+    }
+    public IScopeTreeLookupParameter<RealVector> NeighborBestParameter {
+      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["NeighborBest"]; }
+    }
+    public ILookupParameter<BoolValue> MaximizationParameter {
+      get { return (ILookupParameter<BoolValue>)Parameters["Maximization"]; }
+    }
+    public ILookupParameter<DoubleValue> BestQualityParameter {
+      get { return (ILookupParameter<DoubleValue>)Parameters["BestQuality"]; }
+    }
+    public ILookupParameter<RealVector> BestRealVectorParameter {
+      get { return (ILookupParameter<RealVector>)Parameters["BestRealVector"]; }
+    }
+    public IScopeTreeLookupParameter<IntArray> NeighborsParameter {
+      get { return (IScopeTreeLookupParameter<IntArray>)Parameters["Neighbors"]; }
+    }
+    public ValueLookupParameter<IDiscreteDoubleMatrixModifier> VelocityBoundsUpdaterParameter {
+      get { return (ValueLookupParameter<IDiscreteDoubleMatrixModifier>)Parameters["VelocityBoundsUpdater"]; }
+    }
+    public LookupParameter<DoubleMatrix> VelocityBoundsParameter {
+      get { return (LookupParameter<DoubleMatrix>)Parameters["VelocityBounds"]; }
+    }
+    #endregion
+
+    #region Parameter values
+    private DoubleValue BestQuality {
+      get { return BestQualityParameter.ActualValue; }
+      set { BestQualityParameter.ActualValue = value; }
+    }
+    private RealVector BestRealVector {
+      get { return BestRealVectorParameter.ActualValue; }
+      set { BestRealVectorParameter.ActualValue = value; }
+    }
+    private ItemArray<DoubleValue> Quality {
+      get { return QualityParameter.ActualValue; }
+    }
+    private ItemArray<DoubleValue> PersonalBestQuality {
+      get { return PersonalBestQualityParameter.ActualValue; }
+      set { PersonalBestQualityParameter.ActualValue = value; }
+    }
+    private ItemArray<DoubleValue> NeighborBestQuality {
+      get { return NeighborBestQualityParameter.ActualValue; }
+      set { NeighborBestQualityParameter.ActualValue = value; }
+    }
+    private ItemArray<RealVector> RealVector {
+      get { return RealVectorParameter.ActualValue; }
+    }
+    private ItemArray<RealVector> PersonalBest {
+      get { return PersonalBestParameter.ActualValue; }
+      set { PersonalBestParameter.ActualValue = value; }
+    }
+    private ItemArray<RealVector> NeighborBest {
+      get { return NeighborBestParameter.ActualValue; }
+      set { NeighborBestParameter.ActualValue = value; }
+    }
+    private bool Maximization {
+      get { return MaximizationParameter.ActualValue.Value; }
+    }
+    private ItemArray<IntArray> Neighbors {
+      get { return NeighborsParameter.ActualValue; }
+    }
+    private IDiscreteDoubleMatrixModifier VelocityBoundsUpdater {
+      get { return VelocityBoundsUpdaterParameter.ActualValue; }
+    }
+    private DoubleMatrix VelocityBounds {
+      get { return VelocityBoundsParameter.ActualValue; }
+      set { VelocityBoundsParameter.ActualValue = value; }
+    }
+    #endregion
+
+    #region Construction & Cloning
+
+    [StorableConstructor]
+    private RealVectorSwarmUpdater(bool deserializing) : base(deserializing) { }
+    private RealVectorSwarmUpdater(RealVectorSwarmUpdater original, Cloner cloner) : base(original, cloner) { }
+    public RealVectorSwarmUpdater()
+      : base() {
+      Parameters.Add(new LookupParameter<DoubleValue>("BestQuality", "Overall best quality."));
+      Parameters.Add(new LookupParameter<RealVector>("BestRealVector", "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>("NeighborBestQuality", "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>("NeighborBest", "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 LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
+      Parameters.Add(new ValueLookupParameter<IDiscreteDoubleMatrixModifier>("VelocityBoundsUpdater", "Modifies the velocity bounds in the course of optimization."));
+      Parameters.Add(new LookupParameter<DoubleMatrix>("VelocityBounds", "Maximum velocity for each dimension."));
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RealVectorSwarmUpdater(this, cloner);
+    }
+
+    #endregion
+
+    public override IOperation Apply() {
+      UpdateGlobalBest();
+      UpdateNeighborBest();
+      UpdatePersonalBest();
+      return UpdateVelocityBounds();
+    }
+
+    private void UpdateGlobalBest() {
+      if (BestQuality == null)
+        BestQuality = new DoubleValue();
+      BestQuality.Value = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value);
+      BestRealVector = (RealVector)RealVector[Quality.FindIndex(v => v.Value == BestQuality.Value)].Clone();
+    }
+
+    private void UpdateNeighborBest() {
+      if (Neighbors.Length > 0) {
+        var neighborBest = new ItemArray<RealVector>(Neighbors.Length);
+        var neighborBestQuality = new ItemArray<DoubleValue>(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));
+          var bestNeighbor = Maximization ?
+            pairs.OrderByDescending(p => p.Quality.Value).First() :
+            pairs.OrderBy(p => p.Quality.Value).First();
+          neighborBest[n] = bestNeighbor.Point;
+          neighborBestQuality[n] = bestNeighbor.Quality;
+        }
+        NeighborBest = neighborBest;
+        NeighborBestQuality = neighborBestQuality;
+      }
+    }
+
+    private void UpdatePersonalBest() {
+      if (PersonalBestQuality.Length == 0)
+        PersonalBestQuality = (ItemArray<DoubleValue>)Quality.Clone();
+      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];
+        }
+      }
+    }
+
+    private IOperation UpdateVelocityBounds() {
+      if (VelocityBounds == null)
+        VelocityBounds = new DoubleMatrix(new double[,] { { -1, 1 } });
+      return VelocityBoundsUpdater == null ?
+        base.Apply() :
+        new OperationCollection() { 
+          ExecutionContext.CreateChildOperation(VelocityBoundsUpdater),
+          ExecutionContext.CreateOperation(Successor)
+        };
+    }
+  }
+}
Index: branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorTotallyConnectedParticleUpdater.cs
===================================================================
--- branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorTotallyConnectedParticleUpdater.cs	(revision 5796)
+++ branches/DataAnalysis Refactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorTotallyConnectedParticleUpdater.cs	(revision 5796)
@@ -0,0 +1,71 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Optimization;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Encodings.RealVectorEncoding {
+  [Item("Totally Connected Particle Updater", "Updates the particle's position using (among other things) the global best position. Use together with the empty topology initialzer. Point = Point + Velocity*Inertia + (PersonalBestPoint-Point)*Phi_P*r_p + (BestPoint-Point)*Phi_G*r_g")]
+  [StorableClass]
+  public sealed class RealVectorTotallyConnectedParticleUpdater : RealVectorParticleUpdater, IGlobalParticleUpdater {
+
+    #region Construction & Cloning
+    [StorableConstructor]
+    private RealVectorTotallyConnectedParticleUpdater(bool deserializing) : base(deserializing) { }
+    private RealVectorTotallyConnectedParticleUpdater(RealVectorTotallyConnectedParticleUpdater original, Cloner cloner) : base(original, cloner) { }
+    public RealVectorTotallyConnectedParticleUpdater() : base() { }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RealVectorTotallyConnectedParticleUpdater(this, cloner);
+    }
+    #endregion
+
+    public override IOperation Apply() {
+      double inertia = Inertia.Value;
+      double personalBestAttraction = PersonalBestAttraction.Value;
+      double neighborBestAttraction = NeighborBestAttraction.Value;
+
+      RealVector velocity = new RealVector(Velocity.Length);
+      RealVector position = new RealVector(RealVector.Length);
+      double r_p = Random.NextDouble();
+      double r_g = Random.NextDouble();
+
+      for (int i = 0; i < velocity.Length; i++) {
+        velocity[i] =
+          Velocity[i] * inertia +
+          (PersonalBest[i] - RealVector[i]) * personalBestAttraction * r_p +
+          (BestPoint[i] - RealVector[i]) * neighborBestAttraction * r_g;
+      }
+
+      BoundsChecker.Apply(velocity, VelocityBounds);
+      for (int i = 0; i < velocity.Length; i++) {
+        position[i] = RealVector[i] + velocity[i];
+      }
+      BoundsChecker.Apply(position, Bounds);
+
+      RealVector = position;
+      Velocity = velocity;
+
+      return base.Apply();
+    }
+  }
+}
