Changeset 7073 for trunk/sources/HeuristicLab.Encodings.RealVectorEncoding
- Timestamp:
- 11/25/11 10:56:57 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs
r5911 r7073 66 66 get { return (ILookupParameter<BoolValue>)Parameters["Maximization"]; } 67 67 } 68 public ILookupParameter<DoubleValue> BestQualityParameter {69 get { return (ILookupParameter<DoubleValue>)Parameters[" BestQuality"]; }68 public ILookupParameter<DoubleValue> SwarmBestQualityParameter { 69 get { return (ILookupParameter<DoubleValue>)Parameters["SwarmBestQuality"]; } 70 70 } 71 71 public ILookupParameter<RealVector> BestRealVectorParameter { … … 112 112 113 113 #region Parameter values 114 private DoubleValue BestQuality {115 get { return BestQualityParameter.ActualValue; }116 set { BestQualityParameter.ActualValue = value; }114 private DoubleValue SwarmBestQuality { 115 get { return SwarmBestQualityParameter.ActualValue; } 116 set { SwarmBestQualityParameter.ActualValue = value; } 117 117 } 118 118 private RealVector BestRealVector { … … 180 180 public RealVectorSwarmUpdater() 181 181 : base() { 182 Parameters.Add(new LookupParameter<DoubleValue>(" BestQuality", "Overallbest quality."));183 Parameters.Add(new LookupParameter<RealVector>("BestRealVector", "Global best particle position "));184 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "Particle 's quality"));185 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("PersonalBestQuality", "Particle 's personal best quality"));186 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("NeighborBestQuality", " Global best particle quality"));187 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVector", "Particle 's position"));188 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("PersonalBest", "Particle 's personal best position"));189 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("NeighborBest", "Neighborhood (or global in case of totally connected neighborhood) best particle position "));182 Parameters.Add(new LookupParameter<DoubleValue>("SwarmBestQuality", "Swarm's best quality.")); 183 Parameters.Add(new LookupParameter<RealVector>("BestRealVector", "Global best particle position.")); 184 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "Particles' qualities.")); 185 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("PersonalBestQuality", "Particles' personal best qualities.")); 186 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("NeighborBestQuality", "Best neighbor particles' qualities.")); 187 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVector", "Particles' positions.")); 188 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("PersonalBest", "Particles' personal best positions.")); 189 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("NeighborBest", "Neighborhood (or global in case of totally connected neighborhood) best particle positions.")); 190 190 Parameters.Add(new ScopeTreeLookupParameter<IntArray>("Neighbors", "The list of neighbors for each particle.")); 191 191 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false.")); … … 217 217 218 218 [StorableHook(HookType.AfterDeserialization)] 219 private void AfterDeserialization() { 220 if (!Parameters.ContainsKey("SwarmBestQuality")) { 221 Parameters.Add(new LookupParameter<DoubleValue>("SwarmBestQuality", "Swarm's best quality.")); 222 Parameters.Remove("BestQuality"); 223 } 224 RegisterEvents(); 225 } 226 219 227 private void RegisterEvents() { 220 228 VelocityBoundsStartValueParameter.ValueChanged += new EventHandler(VelocityBoundsStartValueParameter_ValueChanged); … … 273 281 274 282 private void UpdateGlobalBest() { 275 if ( BestQuality == null)276 BestQuality = new DoubleValue();277 BestQuality.Value = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value);278 BestRealVector = (RealVector)RealVector[Quality.FindIndex(v => v.Value == BestQuality.Value)].Clone();283 if (SwarmBestQuality == null) 284 SwarmBestQuality = new DoubleValue(); 285 SwarmBestQuality.Value = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value); 286 BestRealVector = (RealVector)RealVector[Quality.FindIndex(v => v.Value == SwarmBestQuality.Value)].Clone(); 279 287 } 280 288
Note: See TracChangeset
for help on using the changeset viewer.