Changeset 5342 for branches/PSO
- Timestamp:
- 01/20/11 18:22:43 (14 years ago)
- Location:
- branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.csproj
r5339 r5342 111 111 <Compile Include="BestPointInitializer.cs" /> 112 112 <Compile Include="IDiscreteDoubleMatrixModifier.cs" /> 113 <Compile Include="IGlobalParticleUpdater.cs" /> 114 <Compile Include="ILocalParticleUpdater.cs" /> 113 115 <Compile Include="MultiPSOTopologyUpdater.cs" /> 114 116 <Compile Include="VelocityBoundsModifier.cs" /> -
branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/IParticleUpdater.cs
r5316 r5342 27 27 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { 28 28 29 public interface IParticleUpdater : I Item {29 public interface IParticleUpdater : INamedItem { 30 30 31 31 LookupParameter<RealVector> VelocityParameter { get; } -
branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/NeighborhoodParticleUpdater.cs
r5316 r5342 29 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")] 30 30 [StorableClass] 31 public class NeighborhoodParticleUpdater : ParticleUpdater {31 public class NeighborhoodParticleUpdater : ParticleUpdater, ILocalParticleUpdater { 32 32 33 33 #region Construction & Cloning -
branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs
r5339 r5342 115 115 [Storable] 116 116 private BestAverageWorstQualityAnalyzer qualityAnalyzer; 117 118 public ITopologyInitializer TopologyInitializer { 119 get { return TopologyInitializerParameter.Value; } 120 set { TopologyInitializerParameter.Value = value; } 121 } 122 123 public ITopologyUpdater TopologyUpdater { 124 get { return TopologyUpdaterParameter.Value; } 125 set { TopologyUpdaterParameter.Value = value; } 126 } 127 128 public IParticleUpdater ParticleUpdater { 129 get { return ParticleUpdaterParameter.Value; } 130 set { ParticleUpdaterParameter.Value = value; } 131 } 132 117 133 #endregion 118 134 119 135 [StorableConstructor] 120 protected ParticleSwarmOptimization(bool deserializing) : base(deserializing) { } 136 protected ParticleSwarmOptimization(bool deserializing) : base(deserializing) { 137 Initialize(); 138 } 121 139 protected ParticleSwarmOptimization(ParticleSwarmOptimization original, Cloner cloner) 122 140 : base(original, cloner) { 123 141 qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 142 Initialize(); 124 143 } 125 144 … … 255 274 UpdateOmegaUpdater(); 256 275 InitOmegaUpdater(); 276 Initialize(); 277 } 278 279 private void Initialize() { 280 TopologyInitializerParameter.ValueChanged += new EventHandler(TopologyInitializerParameter_ValueChanged); 281 ParticleUpdaterParameter.ValueChanged += new EventHandler(ParticleUpdaterParameter_ValueChanged); 282 TopologyUpdaterParameter.ValueChanged += new EventHandler(TopologyUpdaterParameter_ValueChanged); 283 } 284 285 void TopologyUpdaterParameter_ValueChanged(object sender, EventArgs e) { 286 if (TopologyInitializer is EmptyTopologyInitializer) { // no topology updater allowed 287 if (TopologyUpdater != null) { 288 TopologyUpdater = null; 289 } 290 } 291 } 292 293 void ParticleUpdaterParameter_ValueChanged(object sender, EventArgs e) { 294 if (TopologyInitializer is EmptyTopologyInitializer) { // only global particle updater allowed 295 if (!(ParticleUpdater is IGlobalParticleUpdater)) { 296 ParticleUpdater = ParticleUpdaterParameter.ValidValues.Where(x => x is IGlobalParticleUpdater).First(); 297 } 298 } else { // only local particle updater allowed 299 if (!(ParticleUpdater is ILocalParticleUpdater)) { 300 ParticleUpdater = ParticleUpdaterParameter.ValidValues.Where(x => x is ILocalParticleUpdater).First(); 301 } 302 } 303 } 304 305 void TopologyInitializerParameter_ValueChanged(object sender, EventArgs e) { 306 if (TopologyInitializer is EmptyTopologyInitializer) { // only allow global particle update and no topology update 307 if (ParticleUpdaterParameter.ValidValues.Count > 0) { 308 if (!(ParticleUpdater is IGlobalParticleUpdater)) { 309 ParticleUpdater = ParticleUpdaterParameter.ValidValues.Where(x => x is IGlobalParticleUpdater).First(); 310 } 311 } 312 if (TopologyUpdaterParameter.ValidValues.Count > 0) { 313 if (!(TopologyUpdater != null)) { 314 TopologyUpdater = null; 315 } 316 } 317 } else { // only allow local particle update; topology change possible 318 if (ParticleUpdaterParameter.ValidValues.Count > 0) { 319 if (!(ParticleUpdater is ILocalParticleUpdater)) { 320 ParticleUpdater = ParticleUpdaterParameter.ValidValues.Where(x => x is ILocalParticleUpdater).First(); 321 } 322 } 323 } 257 324 } 258 325 -
branches/PSO/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/TotallyConnectedParticleUpdater.cs
r5316 r5342 29 29 [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 30 [StorableClass] 31 public class TotallyConnectedParticleUpdater : ParticleUpdater {31 public class TotallyConnectedParticleUpdater : ParticleUpdater, IGlobalParticleUpdater { 32 32 33 33 #region Construction & Cloning
Note: See TracChangeset
for help on using the changeset viewer.