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.ScatterSearch/3.3/SolutionPoolUpdateMethod.cs

    r12009 r12280  
    3636  [Item("SolutionPoolUpdateMethod", "An operator that updates the solution pool.")]
    3737  [StorableClass]
    38   public sealed class SolutionPoolUpdateMethod : SingleSuccessorOperator, ISimilarityBasedOperator, ISingleObjectiveOperator {
    39     #region ISimilarityBasedOperator Members
    40     [Storable]
    41     public ISolutionSimilarityCalculator SimilarityCalculator { get; set; }
    42     #endregion
    43 
     38  public sealed class SolutionPoolUpdateMethod : SingleSuccessorOperator, ISingleObjectiveOperator {
    4439    #region Parameter properties
    4540    public ScopeParameter CurrentScopeParameter {
     
    5752    public IValueLookupParameter<IntValue> ReferenceSetSizeParameter {
    5853      get { return (IValueLookupParameter<IntValue>)Parameters["ReferenceSetSize"]; }
     54    }
     55    public IValueLookupParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter {
     56      get { return (IValueLookupParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
    5957    }
    6058    #endregion
     
    8280    [StorableConstructor]
    8381    private SolutionPoolUpdateMethod(bool deserializing) : base(deserializing) { }
    84     private SolutionPoolUpdateMethod(SolutionPoolUpdateMethod original, Cloner cloner)
    85       : base(original, cloner) {
    86       this.SimilarityCalculator = cloner.Clone(original.SimilarityCalculator);
    87     }
    88     public SolutionPoolUpdateMethod() : base() { Initialize(); }
    89 
    90     public override IDeepCloneable Clone(Cloner cloner) {
    91       return new SolutionPoolUpdateMethod(this, cloner);
    92     }
    93 
    94     private void Initialize() {
     82    private SolutionPoolUpdateMethod(SolutionPoolUpdateMethod original, Cloner cloner) : base(original, cloner) { }
     83    public SolutionPoolUpdateMethod()
     84      : base() {
    9585      #region Create parameters
    9686      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope that is the reference set."));
     
    9989      Parameters.Add(new ValueLookupParameter<IItem>("Quality", "This parameter is used for name translation only."));
    10090      Parameters.Add(new ValueLookupParameter<IntValue>("ReferenceSetSize", "The size of the reference set."));
     91      Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The similarity calculator that should be used to calculate solution similarity."));
     92      #endregion
     93    }
     94
     95    public override IDeepCloneable Clone(Cloner cloner) {
     96      return new SolutionPoolUpdateMethod(this, cloner);
     97    }
     98
     99    [StorableHook(HookType.AfterDeserialization)]
     100    private void AfterDeserialization() {
     101      // BackwardsCompatibility3.3
     102      #region Backwards compatible code, remove with 3.4
     103      if (!Parameters.ContainsKey("SimilarityCalculator"))
     104        Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The similarity calculator that should be used to calculate solution similarity."));
    101105      #endregion
    102106    }
     
    132136      if (orderedOffspring.Any(hasBetterQuality)) {
    133137        // produce the set union
    134         var union = orderedParents.Union(orderedOffspring.Where(hasBetterQuality), SimilarityCalculator);
     138        var union = orderedParents.Union(orderedOffspring.Where(hasBetterQuality), SimilarityCalculatorParameter.ActualValue);
    135139        if (union.Count() > orderedParents.Count()) {
    136140          var orderedUnion = Maximization.Value ? union.OrderByDescending(x => x.Variables[QualityParameter.ActualName].Value) :
Note: See TracChangeset for help on using the changeset viewer.