Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/BestPointInitializer.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/BestPointInitializer.cs (revision 5807)
+++ (revision )
@@ -1,104 +1,0 @@
-#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 .
- */
-#endregion
-
-using System.Linq;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.RealVectorEncoding;
-using HeuristicLab.Operators;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- [Item("Best Point Initializer", "Determines the best quality and point of the current particle population.")]
- [StorableClass]
- public sealed class BestPointInitializer : SingleSuccessorOperator {
- public override bool CanChangeName {
- get { return false; }
- }
-
- #region Parameter properties
- public IScopeTreeLookupParameter QualityParameter {
- get { return (IScopeTreeLookupParameter)Parameters["Quality"]; }
- }
- public ILookupParameter BestQualityParameter {
- get { return (ILookupParameter)Parameters["BestQuality"]; }
- }
- public IScopeTreeLookupParameter PointParameter {
- get { return (IScopeTreeLookupParameter)Parameters["Point"]; }
- }
- public ILookupParameter BestPointParameter {
- get { return (ILookupParameter)Parameters["BestPoint"]; }
- }
- public IValueLookupParameter MaximizationParameter {
- get { return (IValueLookupParameter)Parameters["Maximization"]; }
- }
- #endregion
-
- #region Parameter values
- private ItemArray Quality {
- get { return QualityParameter.ActualValue; }
- }
- private double BestQuality {
- get { return BestQualityParameter.ActualValue.Value; }
- set { BestQualityParameter.ActualValue = new DoubleValue(value); }
- }
- private ItemArray Point {
- get { return PointParameter.ActualValue; }
- }
- private RealVector BestPoint {
- get { return BestPointParameter.ActualValue; }
- set { BestPointParameter.ActualValue = value; }
- }
- private bool Maximization {
- get { return MaximizationParameter.ActualValue.Value; }
- }
- #endregion
-
- #region Construction & Cloning
-
- [StorableConstructor]
- private BestPointInitializer(bool deserializing) : base(deserializing) { }
- private BestPointInitializer(BestPointInitializer original, Cloner cloner) : base(original, cloner) { }
- public BestPointInitializer()
- : base() {
- Parameters.Add(new ScopeTreeLookupParameter("Quality", "Particle's quality"));
- Parameters.Add(new LookupParameter("BestQuality", "Global best particle quality"));
- Parameters.Add(new ScopeTreeLookupParameter("Point", "Particle's position"));
- Parameters.Add(new LookupParameter("BestPoint", "Globa best particle position"));
- Parameters.Add(new ValueLookupParameter("Maximization", "True if the problem is a maximization problem, otherwise false."));
- }
-
- public override IDeepCloneable Clone(Cloner cloner) {
- return new BestPointInitializer(this, cloner);
- }
-
- #endregion
-
- public override IOperation Apply() {
- BestQuality = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value);
- int bestIndex = Quality.FindIndex(v => v.Value == BestQuality);
- BestPoint = (RealVector)Point[bestIndex].Clone();
- return base.Apply();
- }
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IDiscreteDoubleMatrixModifier.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IDiscreteDoubleMatrixModifier.cs (revision 5807)
+++ (revision )
@@ -1,38 +1,0 @@
-#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 .
- */
-#endregion
-
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Optimization;
-using HeuristicLab.Parameters;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- public interface IDiscreteDoubleMatrixModifier : IItem {
- ILookupParameter ValueParameter { get; }
- ILookupParameter ScaleParameter { get; }
- ConstrainedValueParameter ScalingOperatorParameter { get; }
- IValueLookupParameter StartValueParameter { get; }
- IValueLookupParameter EndValueParameter { get; }
- ILookupParameter IndexParameter { get; }
- IValueLookupParameter StartIndexParameter { get; }
- IValueLookupParameter EndIndexParameter { get; }
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IGlobalParticleUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IGlobalParticleUpdater.cs (revision 5807)
+++ (revision )
@@ -1,25 +1,0 @@
-#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 .
- */
-#endregion
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- public interface IGlobalParticleUpdater : IParticleUpdater {
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ILocalParticleUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ILocalParticleUpdater.cs (revision 5807)
+++ (revision )
@@ -1,25 +1,0 @@
-#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 .
- */
-#endregion
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- public interface ILocalParticleUpdater : IParticleUpdater {
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IParticleUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IParticleUpdater.cs (revision 5807)
+++ (revision )
@@ -1,44 +1,0 @@
-#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 .
- */
-#endregion
-
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.RealVectorEncoding;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- public interface IParticleUpdater : IOperator {
-
- ILookupParameter VelocityParameter { get; }
- ILookupParameter VelocityBoundsParameter { get; }
-
- ILookupParameter PointParameter { get; }
- ILookupParameter BoundsParameter { get; }
-
- ILookupParameter PersonalBestPointParameter { get; }
- ILookupParameter BestNeighborPointParameter { get; }
- ILookupParameter BestPointParameter { get; }
-
- ILookupParameter OmegaParameter { get; }
- ILookupParameter Phi_PParameter { get; }
- ILookupParameter Phi_GParameter { get; }
- }
-
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ITopologyInitializer.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ITopologyInitializer.cs (revision 5807)
+++ (revision )
@@ -1,31 +1,0 @@
-#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 .
- */
-#endregion
-
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.IntegerVectorEncoding;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- public interface ITopologyInitializer : IOperator {
- IScopeTreeLookupParameter NeighborsParameter { get; }
- ILookupParameter SwarmSizeParameter { get; }
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ITopologyUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ITopologyUpdater.cs (revision 5807)
+++ (revision )
@@ -1,29 +1,0 @@
-#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 .
- */
-#endregion
-
-using HeuristicLab.Core;
-using HeuristicLab.Encodings.IntegerVectorEncoding;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- public interface ITopologyUpdater : IOperator {
- IScopeTreeLookupParameter NeighborsParameter { get; }
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborUpdater.cs (revision 5807)
+++ (revision )
@@ -1,110 +1,0 @@
-#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 .
- */
-#endregion
-
-using System.Linq;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.IntegerVectorEncoding;
-using HeuristicLab.Encodings.RealVectorEncoding;
-using HeuristicLab.Operators;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- [Item("Neighbor Updater", "Determines the best quality and point among the defined list of neigbors for every particle and its individual neighborhood.")]
- [StorableClass]
- public sealed class NeighborUpdater : SingleSuccessorOperator {
- public override bool CanChangeName {
- get { return false; }
- }
-
- #region Parameters
- public IScopeTreeLookupParameter PointsParameter {
- get { return (IScopeTreeLookupParameter)Parameters["Point"]; }
- }
- public IScopeTreeLookupParameter NeighborsParameter {
- get { return (IScopeTreeLookupParameter)Parameters["Neighbors"]; }
- }
- public IScopeTreeLookupParameter BestNeighborPointParameter {
- get { return (IScopeTreeLookupParameter)Parameters["BestNeighborPoint"]; }
- }
- public IScopeTreeLookupParameter QualityParameter {
- get { return (IScopeTreeLookupParameter)Parameters["Quality"]; }
- }
- public ILookupParameter MaximizationParameter {
- get { return (ILookupParameter)Parameters["Maximization"]; }
- }
- #endregion
-
- #region Parameter Values
- private ItemArray Points {
- get { return PointsParameter.ActualValue; }
- }
- private ItemArray Neighbors {
- get { return NeighborsParameter.ActualValue; }
- }
- private ItemArray BestNeighborPoints {
- get { return BestNeighborPointParameter.ActualValue; }
- set { BestNeighborPointParameter.ActualValue = value; }
- }
- private ItemArray Qualities {
- get { return QualityParameter.ActualValue; }
- }
- private bool Maximization {
- get { return MaximizationParameter.ActualValue.Value; }
- }
- #endregion
-
- #region Construction & Cloning
- [StorableConstructor]
- private NeighborUpdater(bool deserializing) : base(deserializing) { }
- private NeighborUpdater(NeighborUpdater original, Cloner cloner) : base(original, cloner) { }
- public NeighborUpdater() {
- Parameters.Add(new ScopeTreeLookupParameter("Point", "The position of the particle."));
- Parameters.Add(new ScopeTreeLookupParameter("Neighbors", "The list of neighbors for each particle."));
- Parameters.Add(new ScopeTreeLookupParameter("BestNeighborPoint", "The position of the best neighboring particle."));
- Parameters.Add(new ScopeTreeLookupParameter("Quality", "The list of qualities of all particles."));
- Parameters.Add(new LookupParameter("Maximization", "Whether the problem is a maximization problem."));
- }
-
- public override IDeepCloneable Clone(Cloner cloner) {
- return new NeighborUpdater(this, cloner);
- }
- #endregion
-
- public override IOperation Apply() {
- if (Neighbors != null & Neighbors.Length > 0) {
- if (BestNeighborPoints == null || BestNeighborPoints.Length != Neighbors.Length)
- BestNeighborPoints = new ItemArray(Neighbors.Length);
- for (int n = 0; n < Neighbors.Length; n++) {
- var pairs = Qualities.Zip(Points, (q, p) => new { Quality = q, Point = p })
- .Where((p, i) => i == n || Neighbors[n].Contains(i));
- BestNeighborPoints[n] = Maximization ?
- pairs.OrderByDescending(p => p.Quality.Value).First().Point :
- pairs.OrderBy(p => p.Quality.Value).First().Point;
- }
- BestNeighborPointParameter.ActualValue = BestNeighborPoints;
- }
- return base.Apply();
- }
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborhoodParticleUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborhoodParticleUpdater.cs (revision 5807)
+++ (revision )
@@ -1,66 +1,0 @@
-#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 .
- */
-#endregion
-
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Encodings.RealVectorEncoding;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- [Item("Neighborhood Particle Updater", "Updates the particle's position using (among other things) the best neighbor's position. Point = Point + Velocity*Omega + (PersonalBestPoint-Point)*Phi_P*r_p + (BestNeighborPoint-Point)*Phi_G*r_g.")]
- [StorableClass]
- public sealed class NeighborhoodParticleUpdater : ParticleUpdater, ILocalParticleUpdater {
-
- [StorableConstructor]
- private NeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { }
- private NeighborhoodParticleUpdater(NeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { }
- public NeighborhoodParticleUpdater() : base() { }
-
- public override IDeepCloneable Clone(Cloner cloner) {
- return new NeighborhoodParticleUpdater(this, cloner);
- }
-
- public override IOperation Apply() {
- RealVector velocity = new RealVector(Velocity.Length);
- RealVector position = new RealVector(Point.Length);
- double r_p = Random.NextDouble();
- double r_g = Random.NextDouble();
- double omega = Omega.Value;
- double phi_p = Phi_P.Value;
- double phi_g = Phi_G.Value;
- for (int i = 0; i < velocity.Length; i++) {
- velocity[i] =
- Velocity[i] * omega +
- (PersonalBestPoint[i] - Point[i]) * phi_p * r_p +
- (BestNeighborPoint[i] - Point[i]) * phi_g * r_g;
- }
- BoundsChecker.Apply(velocity, VelocityBounds);
- for (int i = 0; i < velocity.Length; i++) {
- position[i] = Point[i] + velocity[i];
- }
- BoundsChecker.Apply(position, Bounds);
- Point = position;
- Velocity = velocity;
-
- return base.Apply();
- }
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleUpdater.cs (revision 5807)
+++ (revision )
@@ -1,134 +1,0 @@
-#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 .
- */
-#endregion
-
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.RealVectorEncoding;
-using HeuristicLab.Operators;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- [Item("ParticleUpdater", "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 ParticleUpdater : SingleSuccessorOperator, IParticleUpdater {
- public override bool CanChangeName {
- get { return false; }
- }
-
- #region Parameter properties
- public ILookupParameter RandomParameter {
- get { return (ILookupParameter)Parameters["Random"]; }
- }
- public ILookupParameter PointParameter {
- get { return (ILookupParameter)Parameters["Point"]; }
- }
- public ILookupParameter VelocityParameter {
- get { return (ILookupParameter)Parameters["Velocity"]; }
- }
- public ILookupParameter PersonalBestPointParameter {
- get { return (ILookupParameter)Parameters["PersonalBestPoint"]; }
- }
- public ILookupParameter BestNeighborPointParameter {
- get { return (ILookupParameter)Parameters["BestNeighborPoint"]; }
- }
- public ILookupParameter BestPointParameter {
- get { return (ILookupParameter)Parameters["BestPoint"]; }
- }
- public ILookupParameter BoundsParameter {
- get { return (ILookupParameter)Parameters["Bounds"]; }
- }
- public ILookupParameter VelocityBoundsParameter {
- get { return (ILookupParameter)Parameters["VelocityBounds"]; }
- }
- public ILookupParameter OmegaParameter {
- get { return (ILookupParameter)Parameters["Omega"]; }
- }
- public ILookupParameter Phi_PParameter {
- get { return (ILookupParameter)Parameters["Phi_P"]; }
- }
- public ILookupParameter Phi_GParameter {
- get { return (ILookupParameter)Parameters["Phi_G"]; }
- }
- #endregion
-
- #region Parameter Values
- protected IRandom Random {
- get { return RandomParameter.ActualValue; }
- }
- protected RealVector Point {
- get { return PointParameter.ActualValue; }
- set { PointParameter.ActualValue = value; }
- }
- protected RealVector Velocity {
- get { return VelocityParameter.ActualValue; }
- set { VelocityParameter.ActualValue = value; }
- }
- protected RealVector PersonalBestPoint {
- get { return PersonalBestPointParameter.ActualValue; }
- }
- protected RealVector BestPoint {
- get { return BestPointParameter.ActualValue; }
- }
- protected RealVector BestNeighborPoint {
- get { return BestNeighborPointParameter.ActualValue; }
- }
- protected DoubleMatrix Bounds {
- get { return BoundsParameter.ActualValue; }
- }
- protected DoubleMatrix VelocityBounds {
- get { return VelocityBoundsParameter.ActualValue; }
- }
- protected DoubleValue Omega {
- get { return OmegaParameter.ActualValue; }
- }
- protected DoubleValue Phi_P {
- get { return Phi_PParameter.ActualValue; }
- }
- protected DoubleValue Phi_G {
- get { return Phi_GParameter.ActualValue; }
- }
- #endregion
-
- #region Construction & Cloning
-
- [StorableConstructor]
- protected ParticleUpdater(bool deserializing) : base(deserializing) { }
- protected ParticleUpdater(ParticleUpdater original, Cloner cloner) : base(original, cloner) { }
- public ParticleUpdater()
- : base() {
- Parameters.Add(new LookupParameter("Random", "Random number generator."));
- Parameters.Add(new LookupParameter("Point", "Particle's current position"));
- Parameters.Add(new LookupParameter("Velocity", "Particle's current velocity."));
- Parameters.Add(new LookupParameter("PersonalBestPoint", "Particle's personal best position"));
- Parameters.Add(new LookupParameter("BestPoint", "Global best position"));
- Parameters.Add(new LookupParameter("BestNeighborPoint", "Best neighboring position"));
- Parameters.Add(new LookupParameter("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
- Parameters.Add(new LookupParameter("VelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
- Parameters.Add(new LookupParameter("Omega", "The weight for the particle's velocity vector."));
- Parameters.Add(new LookupParameter("Phi_P", "The weight for the particle's personal best position."));
- Parameters.Add(new LookupParameter("Phi_G", "The weight for the global best position."));
- }
-
- #endregion
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/SwarmUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/SwarmUpdater.cs (revision 5807)
+++ (revision )
@@ -1,126 +1,0 @@
-#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 .
- */
-#endregion
-
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.RealVectorEncoding;
-using HeuristicLab.Operators;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- [Item("Swarm Updater", "Updates personal best point and quality as well as global best point and quality.")]
- [StorableClass]
- public sealed class SwarmUpdater : SingleSuccessorOperator {
- public override bool CanChangeName {
- get { return false; }
- }
-
- #region Parameter properties
- public ILookupParameter QualityParameter {
- get { return (ILookupParameter)Parameters["Quality"]; }
- }
- public ILookupParameter PersonalBestQualityParameter {
- get { return (ILookupParameter)Parameters["PersonalBestQuality"]; }
- }
- public ILookupParameter BestQualityParameter {
- get { return (ILookupParameter)Parameters["BestQuality"]; }
- }
- public ILookupParameter PointParameter {
- get { return (ILookupParameter)Parameters["Point"]; }
- }
- public ILookupParameter PersonalBestPointParameter {
- get { return (ILookupParameter)Parameters["PersonalBestPoint"]; }
- }
- public ILookupParameter BestPointParameter {
- get { return (ILookupParameter)Parameters["BestPoint"]; }
- }
- public IValueLookupParameter MaximizationParameter {
- get { return (IValueLookupParameter)Parameters["Maximization"]; }
- }
- #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 BestQuality {
- get { return BestQualityParameter.ActualValue.Value; }
- set { BestQualityParameter.ActualValue = new DoubleValue(value); }
- }
- private RealVector Point {
- get { return PointParameter.ActualValue; }
- }
- private RealVector PersonalBestPoint {
- get { return PersonalBestPointParameter.ActualValue; }
- set { PersonalBestPointParameter.ActualValue = value; }
- }
- private RealVector BestPoint {
- get { return BestPointParameter.ActualValue; }
- set { BestPointParameter.ActualValue = value; }
- }
- private bool Maximization {
- get { return MaximizationParameter.ActualValue.Value; }
- }
- #endregion
-
- #region Construction & Cloning
-
- [StorableConstructor]
- private SwarmUpdater(bool deserializing) : base(deserializing) { }
- private SwarmUpdater(SwarmUpdater original, Cloner cloner) : base(original, cloner) { }
- public SwarmUpdater()
- : base() {
- Parameters.Add(new LookupParameter("Quality", "Particle's quality"));
- Parameters.Add(new LookupParameter("PersonalBestQuality", "Particle's personal best quality"));
- Parameters.Add(new LookupParameter("BestQuality", "Global best particle quality"));
- Parameters.Add(new LookupParameter("Point", "Particle's position"));
- Parameters.Add(new LookupParameter("PersonalBestPoint", "Particle's personal best position"));
- Parameters.Add(new LookupParameter("BestPoint", "Globa best particle position"));
- Parameters.Add(new ValueLookupParameter("Maximization", "True if the problem is a maximization problem, otherwise false."));
- }
-
- public override IDeepCloneable Clone(Cloner cloner) {
- return new SwarmUpdater(this, cloner);
- }
-
- #endregion
-
- public override IOperation Apply() {
- if (Maximization && Quality > PersonalBestQuality ||
- !Maximization && Quality < PersonalBestQuality) {
- PersonalBestQuality = Quality;
- PersonalBestPoint = Point;
- if (Maximization && PersonalBestQuality > BestQuality ||
- !Maximization && PersonalBestQuality < BestQuality) {
- BestQuality = PersonalBestQuality;
- BestPoint = PersonalBestPoint;
- }
- }
- return base.Apply();
- }
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TotallyConnectedParticleUpdater.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TotallyConnectedParticleUpdater.cs (revision 5807)
+++ (revision )
@@ -1,71 +1,0 @@
-#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 .
- */
-#endregion
-
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Encodings.RealVectorEncoding;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.ParticleSwarmOptimization {
- [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*Omega + (PersonalBestPoint-Point)*Phi_P*r_p + (BestPoint-Point)*Phi_G*r_g")]
- [StorableClass]
- public sealed class TotallyConnectedParticleUpdater : ParticleUpdater, IGlobalParticleUpdater {
-
- #region Construction & Cloning
-
- [StorableConstructor]
- private TotallyConnectedParticleUpdater(bool deserializing) : base(deserializing) { }
- private TotallyConnectedParticleUpdater(TotallyConnectedParticleUpdater original, Cloner cloner) : base(original, cloner) { }
- public TotallyConnectedParticleUpdater() : base() { }
-
- public override IDeepCloneable Clone(Cloner cloner) {
- return new TotallyConnectedParticleUpdater(this, cloner);
- }
-
- #endregion
-
- public override IOperation Apply() {
- base.Apply();
- RealVector velocity = new RealVector(Velocity.Length);
- RealVector position = new RealVector(Point.Length);
- double r_p = Random.NextDouble();
- double r_g = Random.NextDouble();
- double omega = Omega.Value;
- double phi_p = Phi_P.Value;
- double phi_g = Phi_G.Value;
- for (int i = 0; i < velocity.Length; i++) {
- velocity[i] =
- Velocity[i] * omega +
- (PersonalBestPoint[i] - Point[i]) * phi_p * r_p +
- (BestPoint[i] - Point[i]) * phi_g * r_g;
- }
- BoundsChecker.Apply(velocity, VelocityBounds);
- for (int i = 0; i < velocity.Length; i++) {
- position[i] = Point[i] + velocity[i];
- }
- BoundsChecker.Apply(position, Bounds);
- Point = position;
- Velocity = velocity;
-
- return base.Apply();
- }
- }
-}
Index: anches/DataAnalysis Refactoring/HeuristicLab.Clients.Common/3.3/Disposable.cs
===================================================================
--- /branches/DataAnalysis Refactoring/HeuristicLab.Clients.Common/3.3/Disposable.cs (revision 5807)
+++ (revision )
@@ -1,51 +1,0 @@
-#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 .
- */
-#endregion
-
-using System;
-using HeuristicLab.Common;
-
-namespace HeuristicLab.Clients.Common {
- public class Disposable : IDisposable {
- protected object obj;
- public object Obj {
- get { return obj; }
- }
-
- public Disposable(object obj) {
- this.obj = obj;
- }
-
- public void Dispose() {
- if (OnDisposing != null)
- OnDisposing(this, new EventArgs