Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7073 for trunk


Ignore:
Timestamp:
11/25/11 10:56:57 (13 years ago)
Author:
epitzer
Message:

#1690 rename ParticleSwarmUpdater's BestQuality to SwarmBestQuality to avoid a name clash with Analyzers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs

    r5911 r7073  
    6666      get { return (ILookupParameter<BoolValue>)Parameters["Maximization"]; }
    6767    }
    68     public ILookupParameter<DoubleValue> BestQualityParameter {
    69       get { return (ILookupParameter<DoubleValue>)Parameters["BestQuality"]; }
     68    public ILookupParameter<DoubleValue> SwarmBestQualityParameter {
     69      get { return (ILookupParameter<DoubleValue>)Parameters["SwarmBestQuality"]; }
    7070    }
    7171    public ILookupParameter<RealVector> BestRealVectorParameter {
     
    112112
    113113    #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; }
    117117    }
    118118    private RealVector BestRealVector {
     
    180180    public RealVectorSwarmUpdater()
    181181      : base() {
    182       Parameters.Add(new LookupParameter<DoubleValue>("BestQuality", "Overall best 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."));
    190190      Parameters.Add(new ScopeTreeLookupParameter<IntArray>("Neighbors", "The list of neighbors for each particle."));
    191191      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
     
    217217
    218218    [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
    219227    private void RegisterEvents() {
    220228      VelocityBoundsStartValueParameter.ValueChanged += new EventHandler(VelocityBoundsStartValueParameter_ValueChanged);
     
    273281
    274282    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();
    279287    }
    280288
Note: See TracChangeset for help on using the changeset viewer.