- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs
r3816 r4068 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Analysis; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; 28 29 using HeuristicLab.Encodings.RealVectorEncoding; 30 using HeuristicLab.Operators; 29 31 using HeuristicLab.Optimization; 30 using HeuristicLab.Operators;31 32 using HeuristicLab.Optimization.Operators; 32 33 using HeuristicLab.Parameters; 33 34 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 using HeuristicLab.PluginInfrastructure;35 35 using HeuristicLab.Random; 36 using HeuristicLab.Analysis;37 36 38 37 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { … … 57 56 set { AnalyzerParameter.Value = value; } 58 57 } 59 #endregion 58 #endregion 60 59 61 60 #region Parameter Properties … … 131 130 randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name; 132 131 randomCreator.SetSeedRandomlyParameter.Value = null; 133 132 134 133 solutionsCreator.NumberOfSolutionsParameter.ActualName = SwarmSizeParameter.Name; 135 134 136 135 encoder.OperatorParameter.ActualName = "Encoder"; 137 136 138 137 velocityVectorCreator.BoundsParameter.ActualName = "ZeroBounds"; 139 138 velocityVectorCreator.RealVectorParameter.ActualName = "Velocity"; … … 210 209 UpdateEncoders(); 211 210 UpdateAnalyzers(); 212 ParameterizeAnalyzers(); 211 ParameterizeAnalyzers(); 213 212 bestLocalQualityInitalizer.RightSideParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 214 213 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimizationMainLoop.cs
r3742 r4068 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 26 25 using HeuristicLab.Operators; 27 using HeuristicLab.Common; 28 using HeuristicLab.Core; 26 using HeuristicLab.Optimization; 27 using HeuristicLab.Optimization.Operators; 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Parameters;31 using HeuristicLab.Data;32 using HeuristicLab.Analysis;33 using HeuristicLab.Optimization.Operators;34 using HeuristicLab.Encodings.RealVectorEncoding;35 using HeuristicLab.Optimization;36 30 37 31 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { … … 70 64 71 65 [Storable] 72 private ParticleUpdater velocityUpdater; 66 private ParticleUpdater velocityUpdater; 73 67 74 68 [StorableConstructor] … … 98 92 IntCounter intCounter = new IntCounter(); 99 93 ConditionalBranch conditionalBranch = new ConditionalBranch(); 100 velocityUpdater = new ParticleUpdater(); 94 velocityUpdater = new ParticleUpdater(); 101 95 UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor(); 102 96 UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor(); 103 97 Placeholder encPlaceholder = new Placeholder(); 104 Placeholder decPlaceholder = new Placeholder(); 98 Placeholder decPlaceholder = new Placeholder(); 105 99 Placeholder evaluator = new Placeholder(); 106 100 Comparator comparator = new Comparator(); … … 134 128 135 129 encPlaceholder.OperatorParameter.ActualName = EncoderParameter.ActualName; 136 decPlaceholder.OperatorParameter.ActualName = DecoderParameter.ActualName; 130 decPlaceholder.OperatorParameter.ActualName = DecoderParameter.ActualName; 137 131 138 132 evaluator.Name = "Evaluator (placeholder)"; … … 159 153 swarmUpdater.Successor = null; 160 154 intCounter.Successor = resultsCollector1; 161 resultsCollector1.Successor = analyzer1; 155 resultsCollector1.Successor = analyzer1; 162 156 analyzer1.Successor = comparator; 163 157 #endregion -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleUpdater.cs
r3742 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 24 using HeuristicLab.Encodings.RealVectorEncoding; 26 25 using HeuristicLab.Operators; 27 26 using HeuristicLab.Parameters; 28 using HeuristicLab.Encodings.RealVectorEncoding;29 using HeuristicLab.Data;30 using HeuristicLab.Core;31 27 32 28 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { … … 72 68 double alpha = ((IRandom)RandomParameter.ActualValue).NextDouble(); 73 69 double beta = ((IRandom)RandomParameter.ActualValue).NextDouble(); 74 RealVector velocity = (RealVector) VelocityParameter.ActualValue;70 RealVector velocity = (RealVector)VelocityParameter.ActualValue; 75 71 for (int i = 0; i < velocity.Length; i++) { 76 72 velocity[i] = velocity[i] + alpha * (BestLocalParameter.ActualValue[i] - CurrentPositionParameter.ActualValue[i]) + beta * (BestGlobalParameter.ActualValue[i] - CurrentPositionParameter.ActualValue[i]); … … 79 75 for (int i = 0; i < CurrentPositionParameter.ActualValue.Length; i++) { 80 76 CurrentPositionParameter.ActualValue[i] = CurrentPositionParameter.ActualValue[i] + VelocityParameter.ActualValue[i]; 81 if (CurrentPositionParameter.ActualValue[i] < BoundsParameter.ActualValue[0, 0]) {82 CurrentPositionParameter.ActualValue[i] = BoundsParameter.ActualValue[0, 0]; 83 } else if (CurrentPositionParameter.ActualValue[i] > BoundsParameter.ActualValue[0, 1]) {84 CurrentPositionParameter.ActualValue[i] = BoundsParameter.ActualValue[0, 1]; 77 if (CurrentPositionParameter.ActualValue[i] < BoundsParameter.ActualValue[0, 0]) { 78 CurrentPositionParameter.ActualValue[i] = BoundsParameter.ActualValue[0, 0]; 79 } else if (CurrentPositionParameter.ActualValue[i] > BoundsParameter.ActualValue[0, 1]) { 80 CurrentPositionParameter.ActualValue[i] = BoundsParameter.ActualValue[0, 1]; 85 81 } 86 82 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/PermutationToRealVectorEncoder.cs
r3742 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 using HeuristicLab.Operators;27 using HeuristicLab.Common;28 22 using HeuristicLab.Core; 29 23 using HeuristicLab.Data; 30 using HeuristicLab.Parameters;31 24 using HeuristicLab.Encodings.PermutationEncoding; 32 25 using HeuristicLab.Encodings.RealVectorEncoding; 33 using HeuristicLab. Collections;26 using HeuristicLab.Operators; 34 27 using HeuristicLab.Optimization; 28 using HeuristicLab.Parameters; 35 29 36 30 namespace HeuristicLab.Algorithms.ParticleSwarmOptimization { … … 58 52 } 59 53 60 public PermutationToRealVectorEncoder() : base() { 54 public PermutationToRealVectorEncoder() 55 : base() { 61 56 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation to encode.")); 62 57 Parameters.Add(new LookupParameter<RealVector>("RealVector", "The resulting real vector.")); … … 72 67 for (int i = 0; i < permutation.Length; i++) { 73 68 realVector[permutation[i]] = max; 74 max = max - 1; 69 max = max - 1; 75 70 } 76 71 RealVectorParameter.ActualValue = realVector; 77 LengthParameter.ActualValue = new IntValue(realVector.Length); 72 LengthParameter.ActualValue = new IntValue(realVector.Length); 78 73 return base.Apply(); 79 74 } -
trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/SwarmUpdater.cs
r3742 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 using HeuristicLab.Operators;27 22 using HeuristicLab.Core; 28 23 using HeuristicLab.Data; 29 24 using HeuristicLab.Encodings.RealVectorEncoding; 25 using HeuristicLab.Operators; 30 26 using HeuristicLab.Parameters; 31 27 … … 78 74 if (CurrentQualityParameter.ActualValue.Value > LocalBestQualityParameter.ActualValue.Value) { 79 75 LocalBestQualityParameter.ActualValue.Value = CurrentQualityParameter.ActualValue.Value; 80 BestLocalParameter.ActualValue = (RealVector) 76 BestLocalParameter.ActualValue = (RealVector)CurrentPositionParameter.ActualValue.Clone(); 81 77 } 82 78 if (CurrentQualityParameter.ActualValue.Value > GlobalBestQualityParameter.ActualValue.Value) {
Note: See TracChangeset
for help on using the changeset viewer.