Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/01/15 17:06:17 (9 years ago)
Author:
mkommend
Message:

#2332: Merged all changes from this ticket into stable.

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.RAPGA/3.3/ProgressiveOffspringPreserver.cs

    r12009 r12280  
    3838  [Item("ProgressiveOffspringPreserver", "An operator that progressively selects offspring by adding it to a scope list. The operator also performs duplication control.")]
    3939  [StorableClass]
    40   public sealed class ProgressiveOffspringPreserver : SingleSuccessorOperator, ISimilarityBasedOperator {
    41     #region ISimilarityBasedOperator Members
    42     [Storable]
    43     public ISolutionSimilarityCalculator SimilarityCalculator { get; set; }
    44     #endregion
    45 
     40  public sealed class ProgressiveOffspringPreserver : SingleSuccessorOperator {
    4641    #region Parameter Properties
    4742    public ScopeParameter CurrentScopeParameter {
     
    5651    public ILookupParameter<IntValue> MaximumPopulationSizeParameter {
    5752      get { return (ILookupParameter<IntValue>)Parameters["MaximumPopulationSize"]; }
     53    }
     54    public IValueLookupParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter {
     55      get { return (IValueLookupParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
    5856    }
    5957    #endregion
     
    7674    [StorableConstructor]
    7775    private ProgressiveOffspringPreserver(bool deserializing) : base(deserializing) { }
    78     private ProgressiveOffspringPreserver(ProgressiveOffspringPreserver original, Cloner cloner)
    79       : base(original, cloner) {
    80       this.SimilarityCalculator = cloner.Clone(original.SimilarityCalculator);
    81     }
     76    private ProgressiveOffspringPreserver(ProgressiveOffspringPreserver original, Cloner cloner) : base(original, cloner) { }
    8277    public ProgressiveOffspringPreserver()
    8378      : base() {
     79      #region Create parameters
    8480      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope that contains the offspring."));
    8581      Parameters.Add(new LookupParameter<ScopeList>("OffspringList", "The list that contains the offspring."));
    8682      Parameters.Add(new LookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
    8783      Parameters.Add(new LookupParameter<IntValue>("MaximumPopulationSize", "The maximum size of the population of solutions."));
     84      Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The similarity calculator that should be used to calculate solution similarity."));
     85      #endregion
    8886    }
    8987
    9088    public override IDeepCloneable Clone(Cloner cloner) {
    9189      return new ProgressiveOffspringPreserver(this, cloner);
     90    }
     91
     92    [StorableHook(HookType.AfterDeserialization)]
     93    private void AfterDeserialization() {
     94      // BackwardsCompatibility3.3
     95      #region Backwards compatible code, remove with 3.4
     96      if (!Parameters.ContainsKey("SimilarityCalculator"))
     97        Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The similarity calculator that should be used to calculate solution similarity."));
     98      #endregion
    9299    }
    93100
     
    98105          var storedOffspringScope = new Scope();
    99106          storedOffspringScope.SubScopes.AddRange(OffspringList);
    100           var similarityMatrix = SimilarityCalculator.CalculateSolutionCrowdSimilarity(CurrentScope, storedOffspringScope);
     107          var similarityMatrix = SimilarityCalculatorParameter.ActualValue.CalculateSolutionCrowdSimilarity(CurrentScope, storedOffspringScope);
    101108
    102109          var createdOffspring = CurrentScope.SubScopes.ToArray();
Note: See TracChangeset for help on using the changeset viewer.