Changeset 5435
- Timestamp:
- 02/04/11 21:34:45 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3
- Files:
-
- 4 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/BestPointInitializer.cs
r5410 r5435 30 30 31 31 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 32 33 32 [Item("Best Point Initializer", "Determines the best quality and point of the current particle population.")] 34 33 [StorableClass] 35 public class BestPointInitializer : SingleSuccessorOperator { 34 public sealed class BestPointInitializer : SingleSuccessorOperator { 35 public override bool CanChangeName { 36 get { return false; } 37 } 36 38 37 39 #region Parameter properties … … 54 56 55 57 #region Parameter values 56 p ublicItemArray<DoubleValue> Quality {58 private ItemArray<DoubleValue> Quality { 57 59 get { return QualityParameter.ActualValue; } 58 60 } 59 p ublicdouble BestQuality {61 private double BestQuality { 60 62 get { return BestQualityParameter.ActualValue.Value; } 61 63 set { BestQualityParameter.ActualValue = new DoubleValue(value); } 62 64 } 63 p ublicItemArray<RealVector> Point {65 private ItemArray<RealVector> Point { 64 66 get { return PointParameter.ActualValue; } 65 67 } 66 p ublicRealVector BestPoint {68 private RealVector BestPoint { 67 69 get { return BestPointParameter.ActualValue; } 68 70 set { BestPointParameter.ActualValue = value; } 69 71 } 70 p ublicbool Maximization {72 private bool Maximization { 71 73 get { return MaximizationParameter.ActualValue.Value; } 72 74 } … … 76 78 77 79 [StorableConstructor] 78 protected BestPointInitializer(bool deserializing) : base(deserializing) { } 79 protected BestPointInitializer(BestPointInitializer original, Cloner cloner) 80 : base(original, cloner) { 81 } 82 80 private BestPointInitializer(bool deserializing) : base(deserializing) { } 81 private BestPointInitializer(BestPointInitializer original, Cloner cloner) : base(original, cloner) { } 83 82 public BestPointInitializer() 84 83 : base() { … … 102 101 return base.Apply(); 103 102 } 104 105 public override bool CanChangeName {106 get { return false; }107 }108 103 } 109 104 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/HeuristicLabAlgorithmsParticleSwarmOptimizationPlugin.cs.frame
r5426 r5435 26 26 /// Plugin class for HeuristicLab.Algorithms.ParticleSwarmOptimization plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Algorithms.ParticleSwarmOptimization", "3.3. 0.$WCREV$")]28 [Plugin("HeuristicLab.Algorithms.ParticleSwarmOptimization", "3.3.2.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IDiscreteDoubleMatrixModifier.cs
r5316 r5435 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 5 22 using HeuristicLab.Core; 6 23 using HeuristicLab.Data; … … 9 26 10 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 11 12 28 public interface IDiscreteDoubleMatrixModifier : IItem { 13 29 ILookupParameter<DoubleMatrix> ValueParameter { get; } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IGlobalParticleUpdater.cs
r5342 r5435 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 5 21 6 22 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ILocalParticleUpdater.cs
r5342 r5435 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 5 21 6 22 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IParticleUpdater.cs
r5410 r5435 23 23 using HeuristicLab.Data; 24 24 using HeuristicLab.Encodings.RealVectorEncoding; 25 using HeuristicLab.Parameters;26 25 27 26 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 28 29 27 public interface IParticleUpdater : IOperator { 30 28 -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ITopologyInitializer.cs
r5410 r5435 23 23 using HeuristicLab.Data; 24 24 using HeuristicLab.Encodings.IntegerVectorEncoding; 25 using HeuristicLab.Parameters; 25 26 26 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 27 28 27 public interface ITopologyInitializer : IOperator { 29 28 IScopeTreeLookupParameter<IntegerVector> NeighborsParameter { get; } 30 29 ILookupParameter<IntValue> SwarmSizeParameter { get; } 31 30 } 32 33 31 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ITopologyUpdater.cs
r5410 r5435 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Encodings.IntegerVectorEncoding; 24 using HeuristicLab.Parameters; 24 25 25 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 26 27 public interface ITopologyUpdater : IItem { 26 public interface ITopologyUpdater : IOperator { 28 27 IScopeTreeLookupParameter<IntegerVector> NeighborsParameter { get; } 29 28 } 30 31 29 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/MultiPSOTopologyUpdater.cs
r5410 r5435 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 2 22 using System.Collections.Generic; 3 23 using System.Linq; 4 using System.Text;24 using HeuristicLab.Common; 5 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.IntegerVectorEncoding; 28 using HeuristicLab.Operators; 29 using HeuristicLab.Parameters; 6 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 7 using HeuristicLab.Operators;8 using HeuristicLab.Common;9 using HeuristicLab.Parameters;10 using HeuristicLab.Encodings.IntegerVectorEncoding;11 using HeuristicLab.Data;12 31 13 32 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 14 [Item("Multi PSO Topology Initializer/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 Initializer/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.")] 15 34 [StorableClass] 16 public class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater, ITopologyInitializer { 35 public sealed class MultiPSOTopologyUpdater : SingleSuccessorOperator, ITopologyUpdater, ITopologyInitializer { 36 public override bool CanChangeName { 37 get { return false; } 38 } 39 17 40 #region Parameters 18 41 public ILookupParameter<IRandom> RandomParameter { … … 37 60 38 61 #region Parameter Values 39 p ublicIRandom Random {62 private IRandom Random { 40 63 get { return RandomParameter.ActualValue; } 41 64 } 42 p ublicint NrOfConnections {65 private int NrOfConnections { 43 66 get { return NrOfConnectionsParameter.ActualValue.Value; } 44 67 } 45 p ublicint SwarmSize {68 private int SwarmSize { 46 69 get { return SwarmSizeParameter.ActualValue.Value; } 47 70 } 48 p ublicItemArray<IntegerVector> Neighbors {71 private ItemArray<IntegerVector> Neighbors { 49 72 get { return NeighborsParameter.ActualValue; } 50 73 set { NeighborsParameter.ActualValue = value; } 51 74 } 52 p ublicint CurrentIteration {75 private int CurrentIteration { 53 76 get { return CurrentIterationParameter.ActualValue.Value; } 54 77 } 55 p ublicint RegroupingPeriod {78 private int RegroupingPeriod { 56 79 get { return RegroupingPeriodParameter.ActualValue.Value; } 57 80 } 58 81 #endregion 59 82 83 [StorableConstructor] 84 private MultiPSOTopologyUpdater(bool deserializing) : base(deserializing) { } 85 private MultiPSOTopologyUpdater(MultiPSOTopologyUpdater original, Cloner cloner) : base(original, cloner) { } 60 86 public MultiPSOTopologyUpdater() 61 87 : base() { … … 66 92 Parameters.Add(new LookupParameter<IntValue>("CurrentIteration", "The current iteration of the algorithm.")); 67 93 Parameters.Add(new ValueLookupParameter<IntValue>("RegroupingPeriod", "Update interval (=iterations) for regrouping of neighborhoods.", new IntValue(5))); 94 } 95 96 public override IDeepCloneable Clone(Cloner cloner) { 97 return new MultiPSOTopologyUpdater(this, cloner); 68 98 } 69 99 … … 84 114 int nextParticle = numbers[Random.Next(0, numbers.Count)]; 85 115 if (!groups.ContainsKey(groupId)) { 86 groups.Add(groupId, new List<int>()); 116 groups.Add(groupId, new List<int>()); 87 117 } 88 118 groups[groupId].Add(nextParticle); … … 90 120 groupId++; 91 121 } 92 numbers.Remove(nextParticle); 122 numbers.Remove(nextParticle); 93 123 } 94 124 … … 111 141 return base.Apply(); 112 142 } 113 114 [StorableConstructor]115 protected MultiPSOTopologyUpdater(bool deserializing) : base(deserializing) { }116 117 #region Cloning118 public override IDeepCloneable Clone(Cloner cloner) {119 return new MultiPSOTopologyUpdater(this, cloner);120 }121 122 protected MultiPSOTopologyUpdater(MultiPSOTopologyUpdater original, Cloner cloner)123 : base(original, cloner) {124 }125 #endregion126 143 } 127 144 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborUpdater.cs
r5410 r5435 29 29 using HeuristicLab.Parameters; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 31 32 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 32 33 33 [Item("Neighbor Updater", "Determines the best quality and point among the defined list of neigbors for every particle and its individual neighborhood.")] 34 34 [StorableClass] 35 public class NeighborUpdater : SingleSuccessorOperator { 35 public sealed class NeighborUpdater : SingleSuccessorOperator { 36 public override bool CanChangeName { 37 get { return false; } 38 } 36 39 37 40 #region Parameters … … 54 57 55 58 #region Parameter Values 56 p ublicItemArray<RealVector> Points {59 private ItemArray<RealVector> Points { 57 60 get { return PointsParameter.ActualValue; } 58 61 } 59 p ublicItemArray<IntegerVector> Neighbors {62 private ItemArray<IntegerVector> Neighbors { 60 63 get { return NeighborsParameter.ActualValue; } 61 64 } 62 p ublicItemArray<RealVector> BestNeighborPoints {65 private ItemArray<RealVector> BestNeighborPoints { 63 66 get { return BestNeighborPointParameter.ActualValue; } 64 67 set { BestNeighborPointParameter.ActualValue = value; } 65 68 } 66 p ublicItemArray<DoubleValue> Qualities {69 private ItemArray<DoubleValue> Qualities { 67 70 get { return QualityParameter.ActualValue; } 68 71 } 69 p ublicbool Maximization {72 private bool Maximization { 70 73 get { return MaximizationParameter.ActualValue.Value; } 71 74 } … … 73 76 74 77 #region Construction & Cloning 78 [StorableConstructor] 79 private NeighborUpdater(bool deserializing) : base(deserializing) { } 80 private NeighborUpdater(NeighborUpdater original, Cloner cloner) : base(original, cloner) { } 75 81 public NeighborUpdater() { 76 82 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("Point", "The position of the particle.")); … … 80 86 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "Whether the problem is a maximization problem.")); 81 87 } 82 [StorableConstructor] 83 protected NeighborUpdater(bool deserializing) : base(deserializing) { } 84 protected NeighborUpdater(NeighborUpdater original, Cloner cloner) 85 : base(original, cloner) { 86 } 88 87 89 public override IDeepCloneable Clone(Cloner cloner) { 88 90 return new NeighborUpdater(this, cloner); … … 94 96 if (BestNeighborPoints == null || BestNeighborPoints.Length != Neighbors.Length) 95 97 BestNeighborPoints = new ItemArray<RealVector>(Neighbors.Length); 96 for (int n = 0; n <Neighbors.Length; n++) {98 for (int n = 0; n < Neighbors.Length; n++) { 97 99 var pairs = Qualities.Zip(Points, (q, p) => new { Quality = q, Point = p }) 98 100 .Where((p, i) => i == n || Neighbors[n].Contains(i)); 99 BestNeighborPoints[n] = Maximization ? 101 BestNeighborPoints[n] = Maximization ? 100 102 pairs.OrderByDescending(p => p.Quality.Value).First().Point : 101 103 pairs.OrderBy(p => p.Quality.Value).First().Point; -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborhoodParticleUpdater.cs
r5427 r5435 26 26 27 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 28 29 [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")] 28 [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.")] 30 29 [StorableClass] 31 public class NeighborhoodParticleUpdater : ParticleUpdater, ILocalParticleUpdater { 32 33 #region Construction & Cloning 30 public sealed class NeighborhoodParticleUpdater : ParticleUpdater, ILocalParticleUpdater { 34 31 35 32 [StorableConstructor] 36 pr otectedNeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { }37 pr otectedNeighborhoodParticleUpdater(NeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { }33 private NeighborhoodParticleUpdater(bool deserializing) : base(deserializing) { } 34 private NeighborhoodParticleUpdater(NeighborhoodParticleUpdater original, Cloner cloner) : base(original, cloner) { } 38 35 public NeighborhoodParticleUpdater() : base() { } 39 36 … … 41 38 return new NeighborhoodParticleUpdater(this, cloner); 42 39 } 43 44 #endregion45 40 46 41 public override IOperation Apply() { -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs
r5418 r5435 34 34 using HeuristicLab.PluginInfrastructure; 35 35 using HeuristicLab.Random; 36 using System.Collections.Generic;37 36 38 37 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 39 40 38 [Item("Particle Swarm Optimization", "A particle swarm optimization algorithm based on the description in Pedersen, M.E.H. (2010). PhD thesis. University of Southampton.")] 41 39 [Creatable("Algorithms")] 42 40 [StorableClass] 43 public class ParticleSwarmOptimization : EngineAlgorithm, IStorableContent {41 public sealed class ParticleSwarmOptimization : EngineAlgorithm, IStorableContent { 44 42 45 43 #region Problem Properties … … 135 133 136 134 [StorableConstructor] 137 protected ParticleSwarmOptimization(bool deserializing) 138 : base(deserializing) { 139 } 140 protected ParticleSwarmOptimization(ParticleSwarmOptimization original, Cloner cloner) 135 private ParticleSwarmOptimization(bool deserializing) : base(deserializing) { } 136 private ParticleSwarmOptimization(ParticleSwarmOptimization original, Cloner cloner) 141 137 : base(original, cloner) { 142 138 qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 143 139 Initialize(); 144 140 } 145 146 [StorableHook(HookType.AfterDeserialization)]147 private void AfterDeserialization() {148 Initialize();149 }150 151 141 public ParticleSwarmOptimization() 152 142 : base() { … … 288 278 } 289 279 280 [StorableHook(HookType.AfterDeserialization)] 281 private void AfterDeserialization() { 282 Initialize(); 283 } 284 290 285 public override void Prepare() { 291 286 if (Problem != null) { -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleUpdater.cs
r5410 r5435 29 29 30 30 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 31 31 [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.")] 32 32 [StorableClass] 33 33 public abstract class ParticleUpdater : SingleSuccessorOperator, IParticleUpdater { 34 public override bool CanChangeName { 35 get { return false; } 36 } 34 37 35 38 #region Parameter properties … … 70 73 71 74 #region Parameter Values 72 p ublicIRandom Random {75 protected IRandom Random { 73 76 get { return RandomParameter.ActualValue; } 74 77 } 75 p ublicRealVector Point {78 protected RealVector Point { 76 79 get { return PointParameter.ActualValue; } 77 80 set { PointParameter.ActualValue = value; } 78 81 } 79 p ublicRealVector Velocity {82 protected RealVector Velocity { 80 83 get { return VelocityParameter.ActualValue; } 81 84 set { VelocityParameter.ActualValue = value; } 82 85 } 83 p ublicRealVector PersonalBestPoint {86 protected RealVector PersonalBestPoint { 84 87 get { return PersonalBestPointParameter.ActualValue; } 85 88 } 86 p ublicRealVector BestPoint {89 protected RealVector BestPoint { 87 90 get { return BestPointParameter.ActualValue; } 88 91 } 89 p ublicRealVector BestNeighborPoint {92 protected RealVector BestNeighborPoint { 90 93 get { return BestNeighborPointParameter.ActualValue; } 91 94 } 92 p ublicDoubleMatrix Bounds {95 protected DoubleMatrix Bounds { 93 96 get { return BoundsParameter.ActualValue; } 94 97 } 95 p ublicDoubleMatrix VelocityBounds {98 protected DoubleMatrix VelocityBounds { 96 99 get { return VelocityBoundsParameter.ActualValue; } 97 100 } 98 99 public DoubleValue Omega { 101 protected DoubleValue Omega { 100 102 get { return OmegaParameter.ActualValue; } 101 103 } 102 p ublicDoubleValue Phi_P {104 protected DoubleValue Phi_P { 103 105 get { return Phi_PParameter.ActualValue; } 104 106 } 105 p ublicDoubleValue Phi_G {107 protected DoubleValue Phi_G { 106 108 get { return Phi_GParameter.ActualValue; } 107 109 } 108 110 #endregion 109 110 public override bool CanChangeName {111 get { return false; }112 }113 111 114 112 #region Construction & Cloning … … 116 114 [StorableConstructor] 117 115 protected ParticleUpdater(bool deserializing) : base(deserializing) { } 118 protected ParticleUpdater(ParticleUpdater original, Cloner cloner) 119 : base(original, cloner) { 120 } 121 116 protected ParticleUpdater(ParticleUpdater original, Cloner cloner) : base(original, cloner) { } 122 117 public ParticleUpdater() 123 118 : base() { -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/Properties/AssemblyInfo.frame
r3348 r5435 27 27 // associated with an assembly. 28 28 [assembly: AssemblyTitle("HeuristicLab.Algorithms.ParticleSwarmOptimization")] 29 [assembly: AssemblyDescription(" HeuristicLab ParticleSwarmOptimization (PSO)")]29 [assembly: AssemblyDescription("Plugin that provides an implementation of the particle swarm optimization (PSO) metaheuristic.")] 30 30 [assembly: AssemblyConfiguration("")] 31 31 [assembly: AssemblyCompany("")] … … 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.3.0.0")] 55 [assembly: AssemblyFileVersion("3.3. 0.$WCREV$")]55 [assembly: AssemblyFileVersion("3.3.2.$WCREV$")] -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RandomTopologyInitializer.cs
r5410 r5435 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 30 31 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 31 32 32 [Item("Random Topology Initializer", "Randomly connectes every particle with k other particles.")] 33 33 [StorableClass] 34 public class RandomTopologyInitializer : TopologyInitializer { 35 34 public sealed class RandomTopologyInitializer : TopologyInitializer { 36 35 #region Parameters 37 36 public ILookupParameter<IRandom> RandomParameter { … … 44 43 45 44 #region Parameter Values 46 p ublicIRandom Random {45 private IRandom Random { 47 46 get { return RandomParameter.ActualValue; } 48 47 } 49 p ublicint NrOfConnections {48 private int NrOfConnections { 50 49 get { return NrOfConnectionsParameter.ActualValue.Value; } 51 50 } … … 53 52 54 53 #region Construction & Cloning 54 [StorableConstructor] 55 private RandomTopologyInitializer(bool deserializing) : base(deserializing) { } 56 private RandomTopologyInitializer(RandomTopologyInitializer original, Cloner cloner) : base(original, cloner) { } 55 57 public RandomTopologyInitializer() { 56 58 Parameters.Add(new LookupParameter<IRandom>("Random", "A random number generation.")); 57 59 Parameters.Add(new ValueLookupParameter<IntValue>("NrOfConnections", "Nr of connected neighbors.", new IntValue(3))); 58 60 } 59 [StorableConstructor] 60 protected RandomTopologyInitializer(bool deserializing) : base(deserializing) { } 61 protected RandomTopologyInitializer(RandomTopologyInitializer original, Cloner cloner) 62 : base(original, cloner) { 63 } 61 64 62 public override IDeepCloneable Clone(Cloner cloner) { 65 63 return new RandomTopologyInitializer(this, cloner); … … 69 67 public override IOperation Apply() { 70 68 ItemArray<IntegerVector> neighbors = new ItemArray<IntegerVector>(SwarmSize); 71 for (int i = 0; i <SwarmSize; i++) {69 for (int i = 0; i < SwarmSize; i++) { 72 70 var numbers = Enumerable.Range(0, SwarmSize).ToList(); 73 71 numbers.RemoveAt(i); 74 72 var selectedNumbers = new List<int>(NrOfConnections); 75 for (int j = 0; j <NrOfConnections && numbers.Count > 0; j++) {73 for (int j = 0; j < NrOfConnections && numbers.Count > 0; j++) { 76 74 int index = Random.Next(numbers.Count); 77 75 selectedNumbers.Add(numbers[index]); … … 83 81 return base.Apply(); 84 82 } 85 86 83 } 87 84 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/RingTopologyInitializer.cs
r5316 r5435 24 24 using HeuristicLab.Encodings.IntegerVectorEncoding; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 27 28 28 [Item("Ring Topology Initializer", "Connected every particle with its preceeding and its following particle.")] 29 29 [StorableClass] 30 public class RingTopologyInitializer : TopologyInitializer { 30 public sealed class RingTopologyInitializer : TopologyInitializer { 31 #region Construction & Cloning 31 32 32 #region Construction & Cloning33 public RingTopologyInitializer() { }34 33 [StorableConstructor] 35 pr otectedRingTopologyInitializer(bool deserializing) : base(deserializing) { }36 pr otected RingTopologyInitializer(RingTopologyInitializer original, Cloner cloner)37 : base(original, cloner) {38 } 34 private RingTopologyInitializer(bool deserializing) : base(deserializing) { } 35 private RingTopologyInitializer(RingTopologyInitializer original, Cloner cloner) : base(original, cloner) { } 36 public RingTopologyInitializer() : base() { } 37 39 38 public override IDeepCloneable Clone(Cloner cloner) { 40 39 return new RingTopologyInitializer(this, cloner); 41 40 } 41 42 42 #endregion 43 43 44 44 public override IOperation Apply() { 45 45 ItemArray<IntegerVector> neighbors = new ItemArray<IntegerVector>(SwarmSize); 46 for (int i = 0; i <SwarmSize; i++) {47 neighbors[i] = new IntegerVector(new[] { (SwarmSize + i -1) % SwarmSize, (i+1) % SwarmSize });46 for (int i = 0; i < SwarmSize; i++) { 47 neighbors[i] = new IntegerVector(new[] { (SwarmSize + i - 1) % SwarmSize, (i + 1) % SwarmSize }); 48 48 } 49 49 Neighbors = neighbors; 50 50 return base.Apply(); 51 51 } 52 53 52 } 54 53 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/SwarmUpdater.cs
r5410 r5435 29 29 30 30 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 31 32 31 [Item("Swarm Updater", "Updates personal best point and quality as well as global best point and quality.")] 33 32 [StorableClass] 34 public class SwarmUpdater : SingleSuccessorOperator { 33 public sealed class SwarmUpdater : SingleSuccessorOperator { 34 public override bool CanChangeName { 35 get { return false; } 36 } 35 37 36 38 #region Parameter properties … … 59 61 60 62 #region Parameter values 61 p ublicdouble Quality {63 private double Quality { 62 64 get { return QualityParameter.ActualValue.Value; } 63 65 } 64 p ublicdouble PersonalBestQuality {66 private double PersonalBestQuality { 65 67 get { return PersonalBestQualityParameter.ActualValue.Value; } 66 68 set { PersonalBestQualityParameter.ActualValue = new DoubleValue(value); } 67 69 } 68 p ublicdouble BestQuality {70 private double BestQuality { 69 71 get { return BestQualityParameter.ActualValue.Value; } 70 72 set { BestQualityParameter.ActualValue = new DoubleValue(value); } 71 73 } 72 p ublicRealVector Point {74 private RealVector Point { 73 75 get { return PointParameter.ActualValue; } 74 76 } 75 p ublicRealVector PersonalBestPoint {77 private RealVector PersonalBestPoint { 76 78 get { return PersonalBestPointParameter.ActualValue; } 77 79 set { PersonalBestPointParameter.ActualValue = value; } 78 80 } 79 p ublicRealVector BestPoint {81 private RealVector BestPoint { 80 82 get { return BestPointParameter.ActualValue; } 81 83 set { BestPointParameter.ActualValue = value; } 82 84 } 83 p ublicbool Maximization {85 private bool Maximization { 84 86 get { return MaximizationParameter.ActualValue.Value; } 85 87 } … … 89 91 90 92 [StorableConstructor] 91 protected SwarmUpdater(bool deserializing) : base(deserializing) { } 92 protected SwarmUpdater(SwarmUpdater original, Cloner cloner) 93 : base(original, cloner) { 94 } 95 93 private SwarmUpdater(bool deserializing) : base(deserializing) { } 94 private SwarmUpdater(SwarmUpdater original, Cloner cloner) : base(original, cloner) { } 96 95 public SwarmUpdater() 97 96 : base() { … … 112 111 113 112 public override IOperation Apply() { 114 115 113 if (Maximization && Quality > PersonalBestQuality || 116 114 !Maximization && Quality < PersonalBestQuality) { … … 125 123 return base.Apply(); 126 124 } 127 128 public override bool CanChangeName {129 get { return false; }130 }131 125 } 132 126 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TopologyInitializer.cs
r5410 r5435 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 30 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 30 31 [Item("TopologyInitializer", "Groups the particles into neighborhoods according to a certain strategy.")] 31 32 [StorableClass] 32 33 public abstract class TopologyInitializer : SingleSuccessorOperator, ITopologyInitializer { 34 public override bool CanChangeName { 35 get { return false; } 36 } 33 37 34 38 #region Parameters … … 43 47 44 48 #region Parameter Values 45 p ublicItemArray<IntegerVector> Neighbors {49 protected ItemArray<IntegerVector> Neighbors { 46 50 get { return NeighborsParameter.ActualValue; } 47 51 set { NeighborsParameter.ActualValue = value; } 48 52 } 49 p ublicint SwarmSize {53 protected int SwarmSize { 50 54 get { return SwarmSizeParameter.ActualValue.Value; } 51 55 } … … 53 57 54 58 #region Construction & Cloning 55 protected TopologyInitializer() { 59 [StorableConstructor] 60 protected TopologyInitializer(bool deserializing) : base(deserializing) { } 61 protected TopologyInitializer(TopologyInitializer original, Cloner cloner) : base(original, cloner) { } 62 public TopologyInitializer() { 56 63 Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("Neighbors", "The list of neighbors for each particle.")); 57 64 Parameters.Add(new LookupParameter<IntValue>("SwarmSize", "Number of particles in the swarm.")); 58 }59 [StorableConstructor]60 protected TopologyInitializer(bool deserializing) : base(deserializing) { }61 protected TopologyInitializer(TopologyInitializer original, Cloner cloner)62 : base(original, cloner) {63 65 } 64 66 #endregion -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TotallyConnectedParticleUpdater.cs
r5427 r5435 26 26 27 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 28 29 28 [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")] 30 29 [StorableClass] 31 public class TotallyConnectedParticleUpdater : ParticleUpdater, IGlobalParticleUpdater {30 public sealed class TotallyConnectedParticleUpdater : ParticleUpdater, IGlobalParticleUpdater { 32 31 33 32 #region Construction & Cloning 34 33 35 34 [StorableConstructor] 36 pr otectedTotallyConnectedParticleUpdater(bool deserializing) : base(deserializing) { }37 pr otectedTotallyConnectedParticleUpdater(TotallyConnectedParticleUpdater original, Cloner cloner) : base(original, cloner) { }35 private TotallyConnectedParticleUpdater(bool deserializing) : base(deserializing) { } 36 private TotallyConnectedParticleUpdater(TotallyConnectedParticleUpdater original, Cloner cloner) : base(original, cloner) { } 38 37 public TotallyConnectedParticleUpdater() : base() { } 39 38 -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/VelocityBoundsModifier.cs
r5316 r5435 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using HeuristicLab.Operators; 6 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 7 22 using HeuristicLab.Common; 8 23 using HeuristicLab.Core; 9 24 using HeuristicLab.Data; 25 using HeuristicLab.Operators; 10 26 using HeuristicLab.Optimization; 11 27 using HeuristicLab.Parameters; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 12 29 using HeuristicLab.PluginInfrastructure; 13 30 14 31 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 15 32 [Item("VelocityBoundsModifier", "Modifies the velocity bounds.")] 16 33 [StorableClass] 17 public class VelocityBoundsModifier : SingleSuccessorOperator, IDiscreteDoubleMatrixModifier { 18 34 public sealed class VelocityBoundsModifier : SingleSuccessorOperator, IDiscreteDoubleMatrixModifier { 19 35 #region Parameters 20 36 public ILookupParameter<DoubleMatrix> ValueParameter { … … 47 63 48 64 [StorableConstructor] 49 protected VelocityBoundsModifier(bool deserializing) : base(deserializing) { } 50 protected VelocityBoundsModifier(VelocityBoundsModifier original, Cloner cloner) : base(original, cloner) { 51 Initialize(); 65 private VelocityBoundsModifier(bool deserializing) : base(deserializing) { } 66 private VelocityBoundsModifier(VelocityBoundsModifier original, Cloner cloner) 67 : base(original, cloner) { 68 ParameterizeModifiers(); 52 69 } 53 70 public VelocityBoundsModifier() { … … 60 77 Parameters.Add(new ValueLookupParameter<IntValue>("StartIndex", "The start index at which to start modifying 'Value'.")); 61 78 Parameters.Add(new ValueLookupParameter<IntValue>("EndIndex", "The end index by which 'Value' should have reached 'EndValue'.")); 79 62 80 Initialize(); 81 ParameterizeModifiers(); 63 82 } 83 64 84 public override IDeepCloneable Clone(Cloner cloner) { 65 85 return new VelocityBoundsModifier(this, cloner); 86 } 87 #endregion 88 89 [StorableHook(HookType.AfterDeserialization)] 90 private void AfterDeserialization() { 91 ParameterizeModifiers(); 66 92 } 67 93 … … 69 95 foreach (IDiscreteDoubleValueModifier op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>()) { 70 96 ScalingOperatorParameter.ValidValues.Add(op); 71 op.ValueParameter.ActualName = ScaleParameter.ActualName;72 }73 ScaleParameter.ActualNameChanged += new EventHandler(ScaleParameter_ActualNameChanged);74 StartValueParameter.ActualNameChanged += new EventHandler(StartValueParameter_ActualNameChanged);75 EndValueParameter.ActualNameChanged += new EventHandler(EndValueParameter_ActualNameChanged);76 IndexParameter.ActualNameChanged += new EventHandler(IndexParameter_ActualNameChanged);77 EndIndexParameter.ActualNameChanged += new EventHandler(EndIndexParameter_ActualNameChanged);78 StartIndexParameter.ActualNameChanged += new EventHandler(StartIndexParameter_ActualNameChanged);79 }80 #endregion81 82 #region Events83 private void ScaleParameter_ActualNameChanged(object sender, EventArgs e) {84 foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {85 modifier.ValueParameter.ActualName = ScaleParameter.ActualName;86 97 } 87 98 } 88 99 89 private void StartValueParameter_ActualNameChanged(object sender, EventArgs e) { 90 foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) { 91 modifier.StartValueParameter.ActualName = StartValueParameter.ActualName; 100 private void ParameterizeModifiers() { 101 foreach (IDiscreteDoubleValueModifier op in ScalingOperatorParameter.ValidValues) { 102 op.ValueParameter.ActualName = ScaleParameter.Name; 103 op.StartValueParameter.ActualName = StartValueParameter.Name; 104 op.EndValueParameter.ActualName = EndValueParameter.Name; 105 op.IndexParameter.ActualName = IndexParameter.Name; 106 op.StartIndexParameter.ActualName = StartIndexParameter.Name; 107 op.EndIndexParameter.ActualName = EndIndexParameter.Name; 92 108 } 93 109 } 94 95 private void EndValueParameter_ActualNameChanged(object sender, EventArgs e) {96 foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {97 modifier.EndValueParameter.ActualName = EndValueParameter.ActualName;98 }99 }100 101 private void IndexParameter_ActualNameChanged(object sender, EventArgs e) {102 foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {103 modifier.IndexParameter.ActualName = IndexParameter.ActualName;104 }105 }106 107 private void StartIndexParameter_ActualNameChanged(object sender, EventArgs e) {108 foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {109 modifier.StartIndexParameter.ActualName = StartIndexParameter.ActualName;110 }111 }112 113 private void EndIndexParameter_ActualNameChanged(object sender, EventArgs e) {114 foreach (IDiscreteDoubleValueModifier modifier in ScalingOperatorParameter.ValidValues) {115 modifier.EndIndexParameter.ActualName = EndIndexParameter.ActualName;116 }117 }118 #endregion119 110 120 111 public override IOperation Apply() { -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/VonNeumannTopologyInitializer.cs
r5316 r5435 24 24 using HeuristicLab.Encodings.IntegerVectorEncoding; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 27 28 28 [Item("Von Neumann Topology Initializer", "Every particle is connected with the two following and the two previous particles wrapping around at the beginning and the end of the population.")] 29 29 [StorableClass] 30 public class VonNeumannTopologyInitializer : TopologyInitializer {30 public sealed class VonNeumannTopologyInitializer : TopologyInitializer { 31 31 32 32 #region Construction & Cloning 33 public VonNeumannTopologyInitializer() { } 33 34 34 [StorableConstructor] 35 pr otectedVonNeumannTopologyInitializer(bool deserializing) : base(deserializing) { }36 pr otected VonNeumannTopologyInitializer(VonNeumannTopologyInitializer original, Cloner cloner)37 : base(original, cloner) {38 } 35 private VonNeumannTopologyInitializer(bool deserializing) : base(deserializing) { } 36 private VonNeumannTopologyInitializer(VonNeumannTopologyInitializer original, Cloner cloner) : base(original, cloner) { } 37 public VonNeumannTopologyInitializer() : base() { } 38 39 39 public override IDeepCloneable Clone(Cloner cloner) { 40 40 return new VonNeumannTopologyInitializer(this, cloner); 41 41 } 42 42 43 #endregion 43 44 44 45 public override IOperation Apply() { 45 46 ItemArray<IntegerVector> neighbors = new ItemArray<IntegerVector>(SwarmSize); 46 for (int i = 0; i <SwarmSize; i++) {47 for (int i = 0; i < SwarmSize; i++) { 47 48 neighbors[i] = new IntegerVector(new[] { 48 49 (SwarmSize + i-2) % SwarmSize, … … 55 56 return base.Apply(); 56 57 } 57 58 58 } 59 59 }
Note: See TracChangeset
for help on using the changeset viewer.