- Timestamp:
- 04/01/15 17:06:17 (9 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12069-12070,12076,12085,12087,12102,12106,12113,12126,12129
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.RAPGA/3.3/ProgressiveOffspringPreserver.cs
r12009 r12280 38 38 [Item("ProgressiveOffspringPreserver", "An operator that progressively selects offspring by adding it to a scope list. The operator also performs duplication control.")] 39 39 [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 { 46 41 #region Parameter Properties 47 42 public ScopeParameter CurrentScopeParameter { … … 56 51 public ILookupParameter<IntValue> MaximumPopulationSizeParameter { 57 52 get { return (ILookupParameter<IntValue>)Parameters["MaximumPopulationSize"]; } 53 } 54 public IValueLookupParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { 55 get { return (IValueLookupParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 58 56 } 59 57 #endregion … … 76 74 [StorableConstructor] 77 75 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) { } 82 77 public ProgressiveOffspringPreserver() 83 78 : base() { 79 #region Create parameters 84 80 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope that contains the offspring.")); 85 81 Parameters.Add(new LookupParameter<ScopeList>("OffspringList", "The list that contains the offspring.")); 86 82 Parameters.Add(new LookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.")); 87 83 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 88 86 } 89 87 90 88 public override IDeepCloneable Clone(Cloner cloner) { 91 89 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 92 99 } 93 100 … … 98 105 var storedOffspringScope = new Scope(); 99 106 storedOffspringScope.SubScopes.AddRange(OffspringList); 100 var similarityMatrix = SimilarityCalculator .CalculateSolutionCrowdSimilarity(CurrentScope, storedOffspringScope);107 var similarityMatrix = SimilarityCalculatorParameter.ActualValue.CalculateSolutionCrowdSimilarity(CurrentScope, storedOffspringScope); 101 108 102 109 var createdOffspring = CurrentScope.SubScopes.ToArray();
Note: See TracChangeset
for help on using the changeset viewer.