Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/11 13:54:57 (13 years ago)
Author:
spimming
Message:

#1680:

  • merged changes from trunk into branch

' removed pre-build event for multiple app.configs

Location:
branches/HeuristicLab.Hive.Azure
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure

  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs

    r5911 r7215  
    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        ILookupParameter<DoubleValue> oldBestQualityParameter = Parameters["BestQuality"] as ILookupParameter<DoubleValue>;
     222        Parameters.Add(new LookupParameter<DoubleValue>("SwarmBestQuality", "Swarm's best quality."));
     223        if (oldBestQualityParameter.ActualName != oldBestQualityParameter.Name)
     224          SwarmBestQualityParameter.ActualName = oldBestQualityParameter.ActualName;
     225        Parameters.Remove("BestQuality");
     226      }
     227      RegisterEvents();
     228    }
     229
    219230    private void RegisterEvents() {
    220231      VelocityBoundsStartValueParameter.ValueChanged += new EventHandler(VelocityBoundsStartValueParameter_ValueChanged);
     
    273284
    274285    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();
     286      if (SwarmBestQuality == null)
     287        SwarmBestQuality = new DoubleValue();
     288      SwarmBestQuality.Value = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value);
     289      BestRealVector = (RealVector)RealVector[Quality.FindIndex(v => v.Value == SwarmBestQuality.Value)].Clone();
    279290    }
    280291
Note: See TracChangeset for help on using the changeset viewer.