Changeset 12694 for branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.ScatterSearch/3.3/ReferenceSetUpdateMethod.cs
- Timestamp:
- 07/09/15 13:07:30 (9 years ago)
- Location:
- branches/HeuristicLab.Problems.Orienteering
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.ScatterSearch/3.3/ReferenceSetUpdateMethod.cs
r11185 r12694 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 36 36 [Item("ReferenceSetUpdateMethod", "An operator that updates the reference set.")] 37 37 [StorableClass] 38 public sealed class ReferenceSetUpdateMethod : SingleSuccessorOperator, ISimilarityBasedOperator { 39 #region ISimilarityBasedOperator Members 40 [Storable] 41 public ISolutionSimilarityCalculator SimilarityCalculator { get; set; } 42 #endregion 43 38 public sealed class ReferenceSetUpdateMethod : SingleSuccessorOperator { 44 39 #region Parameter properties 45 40 public ScopeParameter CurrentScopeParameter { … … 48 43 public IValueLookupParameter<IntValue> ReferenceSetSizeParameter { 49 44 get { return (IValueLookupParameter<IntValue>)Parameters["ReferenceSetSize"]; } 45 } 46 public IValueLookupParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { 47 get { return (IValueLookupParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 50 48 } 51 49 #endregion … … 62 60 [StorableConstructor] 63 61 private ReferenceSetUpdateMethod(bool deserializing) : base(deserializing) { } 64 private ReferenceSetUpdateMethod(ReferenceSetUpdateMethod original, Cloner cloner) 65 : base(original, cloner) { 66 this.SimilarityCalculator = cloner.Clone(original.SimilarityCalculator); 67 } 62 private ReferenceSetUpdateMethod(ReferenceSetUpdateMethod original, Cloner cloner) : base(original, cloner) { } 68 63 public ReferenceSetUpdateMethod() 69 64 : base() { … … 71 66 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope that contains the population and the reference set.")); 72 67 Parameters.Add(new ValueLookupParameter<IntValue>("ReferenceSetSize", "The size of the reference set.")); 68 Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The similarity calculator that should be used to calculate solution similarity.")); 73 69 #endregion 74 70 } … … 78 74 } 79 75 76 [StorableHook(HookType.AfterDeserialization)] 77 private void AfterDeserialization() { 78 // BackwardsCompatibility3.3 79 #region Backwards compatible code, remove with 3.4 80 if (!Parameters.ContainsKey("SimilarityCalculator")) 81 Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The similarity calculator that should be used to calculate solution similarity.")); 82 #endregion 83 } 84 80 85 public override IOperation Apply() { 81 86 var populationSimilarity = new Dictionary<IScope, double>(); 82 87 var populationScope = CurrentScope.SubScopes[0]; 83 88 var refSetScope = CurrentScope.SubScopes[1]; 84 var similarityMatrix = SimilarityCalculator .CalculateSolutionCrowdSimilarity(populationScope, refSetScope);89 var similarityMatrix = SimilarityCalculatorParameter.ActualValue.CalculateSolutionCrowdSimilarity(populationScope, refSetScope); 85 90 for (int i = 0; i < populationScope.SubScopes.Count; i++) { 86 91 populationSimilarity[populationScope.SubScopes[i]] = similarityMatrix[i].Sum();
Note: See TracChangeset
for help on using the changeset viewer.