Changeset 12280
- Timestamp:
- 04/01/15 17:06:17 (10 years ago)
- Location:
- stable
- Files:
-
- 5 deleted
- 37 edited
- 3 copied
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.LocalSearch/3.3/LocalSearchImprovementOperator.cs
r12009 r12280 251 251 foreach (IAnalyzer analyzer in problem.Operators.OfType<IAnalyzer>()) { 252 252 if (!IsSubclassOfGeneric(typeof(AlleleFrequencyAnalyzer<>), analyzer.GetType()) && 253 !(analyzer is SingleObjectivePopulationDiversityAnalyzer)) {253 !(analyzer is PopulationSimilarityAnalyzer)) { 254 254 IAnalyzer clone = analyzer.Clone() as IAnalyzer; 255 255 foreach (IScopeTreeLookupParameter param in clone.Parameters.OfType<IScopeTreeLookupParameter>()) -
stable/HeuristicLab.Algorithms.RAPGA/3.3/DuplicatesSelector.cs
r12009 r12280 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Optimization; 27 using HeuristicLab.Parameters; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 29 using HeuristicLab.Selection; … … 37 38 [Item("DuplicatesSelector", "A selection operator which considers a single solution representation and selects duplicates. The remaining scope then contains unique solutions and the selected scope their duplicates.")] 38 39 [StorableClass] 39 public sealed class DuplicatesSelector : SingleObjectiveSelector, ISimilarityBasedOperator { 40 #region ISimilarityBasedOperator Members 41 [Storable] 42 public ISolutionSimilarityCalculator SimilarityCalculator { get; set; } 43 #endregion 40 public sealed class DuplicatesSelector : SingleObjectiveSelector { 41 public IValueLookupParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { 42 get { return (IValueLookupParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 43 } 44 44 45 45 [StorableConstructor] 46 46 private DuplicatesSelector(bool deserializing) : base(deserializing) { } 47 private DuplicatesSelector(DuplicatesSelector original, Cloner cloner) 48 : base(original, cloner) { 49 this.SimilarityCalculator = cloner.Clone(original.SimilarityCalculator); 47 private DuplicatesSelector(DuplicatesSelector original, Cloner cloner) : base(original, cloner) { } 48 public DuplicatesSelector() 49 : base() { 50 Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The similarity calculator that should be used to calculate solution similarity.")); 50 51 } 51 public DuplicatesSelector() : base() { }52 52 53 53 public override IDeepCloneable Clone(Cloner cloner) { 54 54 return new DuplicatesSelector(this, cloner); 55 } 56 57 [StorableHook(HookType.AfterDeserialization)] 58 private void AfterDeserialization() { 59 // BackwardsCompatibility3.3 60 #region Backwards compatible code, remove with 3.4 61 if (!Parameters.ContainsKey("SimilarityCalculator")) 62 Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The similarity calculator that should be used to calculate solution similarity.")); 63 #endregion 55 64 } 56 65 … … 61 70 for (int i = 0; i < scopes.Count; i++) 62 71 for (int j = i + 1; j < scopes.Count; j++) 63 marks[j] = SimilarityCalculator .Equals(scopes[i], scopes[j]);72 marks[j] = SimilarityCalculatorParameter.ActualValue.Equals(scopes[i], scopes[j]); 64 73 65 74 -
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(); -
stable/HeuristicLab.Algorithms.RAPGA/3.3/RAPGA.cs
r12009 r12280 103 103 get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; } 104 104 } 105 public IConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {106 get { return (IConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }105 public IConstrainedValueParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { 106 get { return (IConstrainedValueParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 107 107 } 108 108 #endregion … … 173 173 set { MaximumGenerationsParameter.Value = value; } 174 174 } 175 public IS ingleObjectiveSolutionSimilarityCalculator SimilarityCalculator {175 public ISolutionSimilarityCalculator SimilarityCalculator { 176 176 get { return SimilarityCalculatorParameter.Value; } 177 177 set { SimilarityCalculatorParameter.Value = value; } … … 204 204 if (!Parameters.ContainsKey("ReevaluateElites")) { 205 205 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true }); 206 } 207 if (Parameters.ContainsKey("SimilarityCalculator")) { 208 #pragma warning disable 0618 209 var oldParameter = (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; 210 #pragma warning restore 0618 211 Parameters.Remove(oldParameter); 212 var newParameter = new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet<ISolutionSimilarityCalculator>(oldParameter.ValidValues)); 213 var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType()); 214 newParameter.Value = selectedSimilarityCalculator; 215 Parameters.Add(newParameter); 206 216 } 207 217 #endregion … … 234 244 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 235 245 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); 236 Parameters.Add(new ConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));246 Parameters.Add(new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.")); 237 247 238 248 RandomCreator randomCreator = new RandomCreator(); … … 394 404 RAPGAMainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 395 405 RAPGAMainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 396 foreach (ISimilarityBasedOperator op in RAPGAMainLoop.OperatorGraph.Operators.OfType<ISimilarityBasedOperator>())397 op.SimilarityCalculator = SimilarityCalculator;398 406 } 399 407 private void ParameterizeStochasticOperator(IOperator op) { … … 450 458 } 451 459 private void ParameterizeSimilarityCalculators() { 452 foreach (IS ingleObjectiveSolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) {460 foreach (ISolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) { 453 461 calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName; 454 462 } … … 495 503 } 496 504 private void UpdateSimilarityCalculators() { 497 IS ingleObjectiveSolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value;505 ISolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value; 498 506 SimilarityCalculatorParameter.ValidValues.Clear(); 499 ISingleObjectiveSolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault(); 500 501 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 502 SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator()); 503 504 foreach (ISingleObjectiveSolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>()) 507 ISolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISolutionSimilarityCalculator>().FirstOrDefault(); 508 509 foreach (ISolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISolutionSimilarityCalculator>()) 505 510 SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator); 506 511 512 if (!SimilarityCalculatorParameter.ValidValues.OfType<QualitySimilarityCalculator>().Any()) 513 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { 514 QualityVariableName = Problem.Evaluator.QualityParameter.ActualName 515 }); 516 if (!SimilarityCalculatorParameter.ValidValues.OfType<NoSimilarityCalculator>().Any()) 517 SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator()); 518 507 519 if (oldSimilarityCalculator != null) { 508 IS ingleObjectiveSolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType());520 ISolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType()); 509 521 if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator; 510 522 else oldSimilarityCalculator = null; -
stable/HeuristicLab.Algorithms.ScatterSearch/3.3/ReferenceSetUpdateMethod.cs
r12009 r12280 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(); -
stable/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearch.cs
r12009 r12280 88 88 get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 89 89 } 90 public IConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter {91 get { return (IConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }90 public IConstrainedValueParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { 91 get { return (IConstrainedValueParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 92 92 } 93 93 #endregion … … 138 138 set { SetSeedRandomlyParameter.Value = value; } 139 139 } 140 public IS ingleObjectiveSolutionSimilarityCalculator SimilarityCalculator {140 public ISolutionSimilarityCalculator SimilarityCalculator { 141 141 get { return SimilarityCalculatorParameter.Value; } 142 142 set { SimilarityCalculatorParameter.Value = value; } … … 160 160 [StorableHook(HookType.AfterDeserialization)] 161 161 private void AfterDeserialization() { 162 // BackwardsCompatibility3.3 163 #region Backwards compatible code, remove with 3.4 164 if (Parameters.ContainsKey("SimilarityCalculator")) { 165 #pragma warning disable 0618 166 var oldParameter = (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; 167 #pragma warning restore 0618 168 Parameters.Remove(oldParameter); 169 var newParameter = new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet<ISolutionSimilarityCalculator>(oldParameter.ValidValues)); 170 var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType()); 171 newParameter.Value = selectedSimilarityCalculator; 172 Parameters.Add(newParameter); 173 } 174 #endregion 162 175 Initialize(); 163 176 } … … 184 197 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 185 198 Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 186 Parameters.Add(new ConstrainedValueParameter<IS ingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));199 Parameters.Add(new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.")); 187 200 #endregion 188 201 … … 390 403 } 391 404 private void UpdateSimilarityCalculators() { 392 IS ingleObjectiveSolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value;405 ISolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value; 393 406 SimilarityCalculatorParameter.ValidValues.Clear(); 394 ISingleObjectiveSolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault(); 395 396 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 397 SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 398 399 foreach (ISingleObjectiveSolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>()) 407 ISolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISolutionSimilarityCalculator>().FirstOrDefault(); 408 409 foreach (ISolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISolutionSimilarityCalculator>()) 400 410 SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator); 401 411 412 if (!SimilarityCalculatorParameter.ValidValues.OfType<QualitySimilarityCalculator>().Any()) 413 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { 414 QualityVariableName = Problem.Evaluator.QualityParameter.ActualName 415 }); 416 if (!SimilarityCalculatorParameter.ValidValues.OfType<NoSimilarityCalculator>().Any()) 417 SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator()); 418 402 419 if (oldSimilarityCalculator != null) { 403 IS ingleObjectiveSolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType());420 ISolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType()); 404 421 if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator; 405 422 else oldSimilarityCalculator = null; … … 423 440 MainLoop.OperatorGraph.Operators.OfType<PopulationRebuildMethod>().Single().QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 424 441 MainLoop.OperatorGraph.Operators.OfType<SolutionPoolUpdateMethod>().Single().QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 425 foreach (ISimilarityBasedOperator op in MainLoop.OperatorGraph.Operators.OfType<ISimilarityBasedOperator>())426 op.SimilarityCalculator = SimilarityCalculator;427 442 } 428 443 } … … 449 464 } 450 465 private void ParameterizeSimilarityCalculators() { 451 foreach (IS ingleObjectiveSolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) {466 foreach (ISolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) { 452 467 calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName; 453 468 } -
stable/HeuristicLab.Algorithms.ScatterSearch/3.3/SolutionPoolUpdateMethod.cs
r12009 r12280 36 36 [Item("SolutionPoolUpdateMethod", "An operator that updates the solution pool.")] 37 37 [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 { 44 39 #region Parameter properties 45 40 public ScopeParameter CurrentScopeParameter { … … 57 52 public IValueLookupParameter<IntValue> ReferenceSetSizeParameter { 58 53 get { return (IValueLookupParameter<IntValue>)Parameters["ReferenceSetSize"]; } 54 } 55 public IValueLookupParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { 56 get { return (IValueLookupParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 59 57 } 60 58 #endregion … … 82 80 [StorableConstructor] 83 81 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() { 95 85 #region Create parameters 96 86 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope that is the reference set.")); … … 99 89 Parameters.Add(new ValueLookupParameter<IItem>("Quality", "This parameter is used for name translation only.")); 100 90 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.")); 101 105 #endregion 102 106 } … … 132 136 if (orderedOffspring.Any(hasBetterQuality)) { 133 137 // produce the set union 134 var union = orderedParents.Union(orderedOffspring.Where(hasBetterQuality), SimilarityCalculator );138 var union = orderedParents.Union(orderedOffspring.Where(hasBetterQuality), SimilarityCalculatorParameter.ActualValue); 135 139 if (union.Count() > orderedParents.Count()) { 136 140 var orderedUnion = Maximization.Value ? union.OrderByDescending(x => x.Variables[QualityParameter.ActualName].Value) : -
stable/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs
r12009 r12280 279 279 foreach (IAnalyzer analyzer in problem.Operators.OfType<IAnalyzer>()) { 280 280 if (!IsSubclassOfGeneric(typeof(AlleleFrequencyAnalyzer<>), analyzer.GetType()) && 281 !(analyzer is SingleObjectivePopulationDiversityAnalyzer)) {281 !(analyzer is PopulationSimilarityAnalyzer)) { 282 282 IAnalyzer clone = analyzer.Clone() as IAnalyzer; 283 283 foreach (IScopeTreeLookupParameter param in clone.Parameters.OfType<IScopeTreeLookupParameter>()) -
stable/HeuristicLab.Analysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Analysis merged: 12069,12076
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r12154 r12280 148 148 <Compile Include="MultiObjective\ParetoFrontAnalyzer.cs" /> 149 149 <Compile Include="Plugin.cs" /> 150 <Compile Include="PopulationDiversityAnalysis\PopulationDiversityAnalyzer.cs" /> 151 <Compile Include="PopulationDiversityAnalysis\SingleObjectivePopulationDiversityAnalyzer.cs" /> 150 <Compile Include="PopulationSimilarityAnalysis\PopulationDiversityAnalyzer.cs" /> 151 <Compile Include="PopulationSimilarityAnalysis\PopulationSimilarityAnalyzer.cs" /> 152 <Compile Include="PopulationSimilarityAnalysis\SingleObjectivePopulationDiversityAnalyzer.cs" /> 152 153 <Compile Include="QualityAnalysis\BestAverageWorstQualityAnalyzer.cs" /> 153 154 <Compile Include="QualityAnalysis\BestAverageWorstQualityCalculator.cs" /> -
stable/HeuristicLab.Analysis/3.3/PopulationSimilarityAnalysis/PopulationSimilarityAnalyzer.cs
r12069 r12280 125 125 updateCounter = new IntValue(updateInterval); 126 126 UpdateCounterParameter.ActualValue = updateCounter; 127 } else updateCounter.Value++; 128 127 } 129 128 //analyze solutions only every 'updateInterval' times 130 if (updateCounter.Value == updateInterval) { 131 updateCounter.Value = 0; 132 133 bool storeHistory = StoreHistoryParameter.Value.Value; 134 int count = CurrentScopeParameter.ActualValue.SubScopes.Count; 135 136 if (count > 1) { 137 var similarityCalculator = SimilarityCalculatorParameter.Value; 138 // calculate solution similarities 139 var similarityMatrix = similarityCalculator.CalculateSolutionCrowdSimilarity(CurrentScopeParameter.ActualValue); 140 double[,] similarities = new double[similarityMatrix.Length, similarityMatrix[0].Length]; 141 for (int i = 0; i < similarityMatrix.Length; i++) 142 for (int j = 0; j < similarityMatrix[0].Length; j++) 143 similarities[i, j] = similarityMatrix[i][j]; 144 145 // calculate minimum, average and maximum similarities 146 double similarity; 147 double[] minSimilarities = new double[count]; 148 double[] avgSimilarities = new double[count]; 149 double[] maxSimilarities = new double[count]; 150 for (int i = 0; i < count; i++) { 151 minSimilarities[i] = 1; 152 avgSimilarities[i] = 0; 153 maxSimilarities[i] = 0; 154 for (int j = 0; j < count; j++) { 155 if (i != j) { 156 similarity = similarities[i, j]; 157 158 if ((similarity < 0) || (similarity > 1)) 159 throw new InvalidOperationException("Solution similarities have to be in the interval [0;1]."); 160 161 if (minSimilarities[i] > similarity) minSimilarities[i] = similarity; 162 avgSimilarities[i] += similarity; 163 if (maxSimilarities[i] < similarity) maxSimilarities[i] = similarity; 164 } 165 } 166 avgSimilarities[i] = avgSimilarities[i] / (count - 1); 167 } 168 double avgMinSimilarity = minSimilarities.Average(); 169 double avgAvgSimilarity = avgSimilarities.Average(); 170 double avgMaxSimilarity = maxSimilarities.Average(); 171 172 // fetch results collection 173 ResultCollection results; 174 if (!ResultsParameter.ActualValue.ContainsKey(DiversityResultName)) { 175 results = new ResultCollection(); 176 ResultsParameter.ActualValue.Add(new Result(DiversityResultName, results)); 177 } else { 178 results = (ResultCollection)ResultsParameter.ActualValue[DiversityResultName].Value; 179 } 180 181 // store similarities 182 HeatMap similaritiesHeatMap = new HeatMap(similarities, "Solution Similarities", 0.0, 1.0); 183 if (!results.ContainsKey("Solution Similarities")) 184 results.Add(new Result("Solution Similarities", similaritiesHeatMap)); 185 else 186 results["Solution Similarities"].Value = similaritiesHeatMap; 187 188 // store similarities history 189 if (storeHistory) { 190 if (!results.ContainsKey("Solution Similarities History")) { 191 HeatMapHistory history = new HeatMapHistory(); 192 history.Add(similaritiesHeatMap); 193 results.Add(new Result("Solution Similarities History", history)); 194 } else { 195 ((HeatMapHistory)results["Solution Similarities History"].Value).Add(similaritiesHeatMap); 129 if (updateCounter.Value != updateInterval) { 130 updateCounter.Value++; 131 return base.Apply(); 132 } 133 updateCounter.Value = 1; 134 135 bool storeHistory = StoreHistoryParameter.Value.Value; 136 int count = CurrentScopeParameter.ActualValue.SubScopes.Count; 137 138 if (count > 1) { 139 var similarityCalculator = SimilarityCalculatorParameter.Value; 140 // calculate solution similarities 141 var similarityMatrix = similarityCalculator.CalculateSolutionCrowdSimilarity(CurrentScopeParameter.ActualValue); 142 double[,] similarities = new double[similarityMatrix.Length, similarityMatrix[0].Length]; 143 for (int i = 0; i < similarityMatrix.Length; i++) 144 for (int j = 0; j < similarityMatrix[0].Length; j++) 145 similarities[i, j] = similarityMatrix[i][j]; 146 147 // calculate minimum, average and maximum similarities 148 double similarity; 149 double[] minSimilarities = new double[count]; 150 double[] avgSimilarities = new double[count]; 151 double[] maxSimilarities = new double[count]; 152 for (int i = 0; i < count; i++) { 153 minSimilarities[i] = 1; 154 avgSimilarities[i] = 0; 155 maxSimilarities[i] = 0; 156 for (int j = 0; j < count; j++) { 157 if (i != j) { 158 similarity = similarities[i, j]; 159 160 if ((similarity < 0) || (similarity > 1)) 161 throw new InvalidOperationException("Solution similarities have to be in the interval [0;1]."); 162 163 if (minSimilarities[i] > similarity) minSimilarities[i] = similarity; 164 avgSimilarities[i] += similarity; 165 if (maxSimilarities[i] < similarity) maxSimilarities[i] = similarity; 196 166 } 197 167 } 198 199 // store average minimum, average and maximum similarity 200 if (!results.ContainsKey("Average Minimum Solution Similarity")) 201 results.Add(new Result("Average Minimum Solution Similarity", new DoubleValue(avgMinSimilarity))); 202 else 203 ((DoubleValue)results["Average Minimum Solution Similarity"].Value).Value = avgMinSimilarity; 204 205 if (!results.ContainsKey("Average Average Solution Similarity")) 206 results.Add(new Result("Average Average Solution Similarity", new DoubleValue(avgAvgSimilarity))); 207 else 208 ((DoubleValue)results["Average Average Solution Similarity"].Value).Value = avgAvgSimilarity; 209 210 if (!results.ContainsKey("Average Maximum Solution Similarity")) 211 results.Add(new Result("Average Maximum Solution Similarity", new DoubleValue(avgMaxSimilarity))); 212 else 213 ((DoubleValue)results["Average Maximum Solution Similarity"].Value).Value = avgMaxSimilarity; 214 215 // store average minimum, average and maximum solution similarity data table 216 DataTable minAvgMaxSimilarityDataTable; 217 if (!results.ContainsKey("Average Minimum/Average/Maximum Solution Similarity")) { 218 minAvgMaxSimilarityDataTable = new DataTable("Average Minimum/Average/Maximum Solution Similarity"); 219 minAvgMaxSimilarityDataTable.VisualProperties.XAxisTitle = "Iteration"; 220 minAvgMaxSimilarityDataTable.VisualProperties.YAxisTitle = "Solution Similarity"; 221 minAvgMaxSimilarityDataTable.Rows.Add(new DataRow("Average Minimum Solution Similarity", null)); 222 minAvgMaxSimilarityDataTable.Rows["Average Minimum Solution Similarity"].VisualProperties.StartIndexZero = true; 223 minAvgMaxSimilarityDataTable.Rows.Add(new DataRow("Average Average Solution Similarity", null)); 224 minAvgMaxSimilarityDataTable.Rows["Average Average Solution Similarity"].VisualProperties.StartIndexZero = true; 225 minAvgMaxSimilarityDataTable.Rows.Add(new DataRow("Average Maximum Solution Similarity", null)); 226 minAvgMaxSimilarityDataTable.Rows["Average Maximum Solution Similarity"].VisualProperties.StartIndexZero = true; 227 results.Add(new Result("Average Minimum/Average/Maximum Solution Similarity", minAvgMaxSimilarityDataTable)); 168 avgSimilarities[i] = avgSimilarities[i] / (count - 1); 169 } 170 double avgMinSimilarity = minSimilarities.Average(); 171 double avgAvgSimilarity = avgSimilarities.Average(); 172 double avgMaxSimilarity = maxSimilarities.Average(); 173 174 // fetch results collection 175 ResultCollection results; 176 if (!ResultsParameter.ActualValue.ContainsKey(DiversityResultName)) { 177 results = new ResultCollection(); 178 ResultsParameter.ActualValue.Add(new Result(DiversityResultName, results)); 179 } else { 180 results = (ResultCollection)ResultsParameter.ActualValue[DiversityResultName].Value; 181 } 182 183 // store similarities 184 HeatMap similaritiesHeatMap = new HeatMap(similarities, "Solution Similarities", 0.0, 1.0); 185 if (!results.ContainsKey("Solution Similarities")) 186 results.Add(new Result("Solution Similarities", similaritiesHeatMap)); 187 else 188 results["Solution Similarities"].Value = similaritiesHeatMap; 189 190 // store similarities history 191 if (storeHistory) { 192 if (!results.ContainsKey("Solution Similarities History")) { 193 HeatMapHistory history = new HeatMapHistory(); 194 history.Add(similaritiesHeatMap); 195 results.Add(new Result("Solution Similarities History", history)); 228 196 } else { 229 minAvgMaxSimilarityDataTable = (DataTable)results["Average Minimum/Average/Maximum Solution Similarity"].Value;197 ((HeatMapHistory)results["Solution Similarities History"].Value).Add(similaritiesHeatMap); 230 198 } 231 minAvgMaxSimilarityDataTable.Rows["Average Minimum Solution Similarity"].Values.Add(avgMinSimilarity); 232 minAvgMaxSimilarityDataTable.Rows["Average Average Solution Similarity"].Values.Add(avgAvgSimilarity); 233 minAvgMaxSimilarityDataTable.Rows["Average Maximum Solution Similarity"].Values.Add(avgMaxSimilarity); 234 235 // store minimum, average, maximum similarities data table 236 DataTable minAvgMaxSimilaritiesDataTable = new DataTable("Minimum/Average/Maximum Solution Similarities"); 237 minAvgMaxSimilaritiesDataTable.VisualProperties.XAxisTitle = "Solution Index"; 238 minAvgMaxSimilaritiesDataTable.VisualProperties.YAxisTitle = "Solution Similarity"; 239 minAvgMaxSimilaritiesDataTable.Rows.Add(new DataRow("Minimum Solution Similarity", null, minSimilarities)); 240 minAvgMaxSimilaritiesDataTable.Rows["Minimum Solution Similarity"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 241 minAvgMaxSimilaritiesDataTable.Rows.Add(new DataRow("Average Solution Similarity", null, avgSimilarities)); 242 minAvgMaxSimilaritiesDataTable.Rows["Average Solution Similarity"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 243 minAvgMaxSimilaritiesDataTable.Rows.Add(new DataRow("Maximum Solution Similarity", null, maxSimilarities)); 244 minAvgMaxSimilaritiesDataTable.Rows["Maximum Solution Similarity"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 245 if (!results.ContainsKey("Minimum/Average/Maximum Solution Similarities")) { 246 results.Add(new Result("Minimum/Average/Maximum Solution Similarities", minAvgMaxSimilaritiesDataTable)); 199 } 200 201 // store average minimum, average and maximum similarity 202 if (!results.ContainsKey("Average Minimum Solution Similarity")) 203 results.Add(new Result("Average Minimum Solution Similarity", new DoubleValue(avgMinSimilarity))); 204 else 205 ((DoubleValue)results["Average Minimum Solution Similarity"].Value).Value = avgMinSimilarity; 206 207 if (!results.ContainsKey("Average Average Solution Similarity")) 208 results.Add(new Result("Average Average Solution Similarity", new DoubleValue(avgAvgSimilarity))); 209 else 210 ((DoubleValue)results["Average Average Solution Similarity"].Value).Value = avgAvgSimilarity; 211 212 if (!results.ContainsKey("Average Maximum Solution Similarity")) 213 results.Add(new Result("Average Maximum Solution Similarity", new DoubleValue(avgMaxSimilarity))); 214 else 215 ((DoubleValue)results["Average Maximum Solution Similarity"].Value).Value = avgMaxSimilarity; 216 217 // store average minimum, average and maximum solution similarity data table 218 DataTable minAvgMaxSimilarityDataTable; 219 if (!results.ContainsKey("Average Minimum/Average/Maximum Solution Similarity")) { 220 minAvgMaxSimilarityDataTable = new DataTable("Average Minimum/Average/Maximum Solution Similarity"); 221 minAvgMaxSimilarityDataTable.VisualProperties.XAxisTitle = "Iteration"; 222 minAvgMaxSimilarityDataTable.VisualProperties.YAxisTitle = "Solution Similarity"; 223 minAvgMaxSimilarityDataTable.Rows.Add(new DataRow("Average Minimum Solution Similarity", null)); 224 minAvgMaxSimilarityDataTable.Rows["Average Minimum Solution Similarity"].VisualProperties.StartIndexZero = true; 225 minAvgMaxSimilarityDataTable.Rows.Add(new DataRow("Average Average Solution Similarity", null)); 226 minAvgMaxSimilarityDataTable.Rows["Average Average Solution Similarity"].VisualProperties.StartIndexZero = true; 227 minAvgMaxSimilarityDataTable.Rows.Add(new DataRow("Average Maximum Solution Similarity", null)); 228 minAvgMaxSimilarityDataTable.Rows["Average Maximum Solution Similarity"].VisualProperties.StartIndexZero = true; 229 results.Add(new Result("Average Minimum/Average/Maximum Solution Similarity", minAvgMaxSimilarityDataTable)); 230 } else { 231 minAvgMaxSimilarityDataTable = (DataTable)results["Average Minimum/Average/Maximum Solution Similarity"].Value; 232 } 233 minAvgMaxSimilarityDataTable.Rows["Average Minimum Solution Similarity"].Values.Add(avgMinSimilarity); 234 minAvgMaxSimilarityDataTable.Rows["Average Average Solution Similarity"].Values.Add(avgAvgSimilarity); 235 minAvgMaxSimilarityDataTable.Rows["Average Maximum Solution Similarity"].Values.Add(avgMaxSimilarity); 236 237 // store minimum, average, maximum similarities data table 238 DataTable minAvgMaxSimilaritiesDataTable = new DataTable("Minimum/Average/Maximum Solution Similarities"); 239 minAvgMaxSimilaritiesDataTable.VisualProperties.XAxisTitle = "Solution Index"; 240 minAvgMaxSimilaritiesDataTable.VisualProperties.YAxisTitle = "Solution Similarity"; 241 minAvgMaxSimilaritiesDataTable.Rows.Add(new DataRow("Minimum Solution Similarity", null, minSimilarities)); 242 minAvgMaxSimilaritiesDataTable.Rows["Minimum Solution Similarity"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 243 minAvgMaxSimilaritiesDataTable.Rows.Add(new DataRow("Average Solution Similarity", null, avgSimilarities)); 244 minAvgMaxSimilaritiesDataTable.Rows["Average Solution Similarity"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 245 minAvgMaxSimilaritiesDataTable.Rows.Add(new DataRow("Maximum Solution Similarity", null, maxSimilarities)); 246 minAvgMaxSimilaritiesDataTable.Rows["Maximum Solution Similarity"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 247 if (!results.ContainsKey("Minimum/Average/Maximum Solution Similarities")) { 248 results.Add(new Result("Minimum/Average/Maximum Solution Similarities", minAvgMaxSimilaritiesDataTable)); 249 } else { 250 results["Minimum/Average/Maximum Solution Similarities"].Value = minAvgMaxSimilaritiesDataTable; 251 } 252 253 // store minimum, average, maximum similarities history 254 if (storeHistory) { 255 if (!results.ContainsKey("Minimum/Average/Maximum Solution Similarities History")) { 256 DataTableHistory history = new DataTableHistory(); 257 history.Add(minAvgMaxSimilaritiesDataTable); 258 results.Add(new Result("Minimum/Average/Maximum Solution Similarities History", history)); 247 259 } else { 248 results["Minimum/Average/Maximum Solution Similarities"].Value = minAvgMaxSimilaritiesDataTable; 249 } 250 251 // store minimum, average, maximum similarities history 252 if (storeHistory) { 253 if (!results.ContainsKey("Minimum/Average/Maximum Solution Similarities History")) { 254 DataTableHistory history = new DataTableHistory(); 255 history.Add(minAvgMaxSimilaritiesDataTable); 256 results.Add(new Result("Minimum/Average/Maximum Solution Similarities History", history)); 257 } else { 258 ((DataTableHistory)results["Minimum/Average/Maximum Solution Similarities History"].Value).Add(minAvgMaxSimilaritiesDataTable); 259 } 260 ((DataTableHistory)results["Minimum/Average/Maximum Solution Similarities History"].Value).Add(minAvgMaxSimilaritiesDataTable); 260 261 } 261 262 } -
stable/HeuristicLab.Optimization
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Optimization merged: 12069,12085,12102
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization.Operators/3.3/NoSimilarityCalculator.cs
r12009 r12280 32 32 [Item("NoSimilarityCalculator", "An item that performs similarity calculation between two solutions. The item always considers two solutions to be distinct.")] 33 33 public sealed class NoSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 34 protected override bool IsCommutative { get { return true; } } 35 34 36 private NoSimilarityCalculator(bool deserializing) : base(deserializing) { } 35 37 private NoSimilarityCalculator(NoSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } -
stable/HeuristicLab.Optimization.Operators/3.3/QualitySimilarityCalculator.cs
r12009 r12280 34 34 [Item("QualitySimilarityCalculator", "An item that performs similarity calculation between two solutions. The item only considers the qualities of the two solutions.")] 35 35 public sealed class QualitySimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 36 protected override bool IsCommutative { get { return true; } } 37 36 38 private QualitySimilarityCalculator(bool deserializing) : base(deserializing) { } 37 39 private QualitySimilarityCalculator(QualitySimilarityCalculator original, Cloner cloner) : base(original, cloner) { } -
stable/HeuristicLab.Optimization.Operators/3.3/SingleObjectiveSolutionSimilarityCalculator.cs
r12009 r12280 31 31 [Item("SimilarityCalculator", "A base class for items that perform similarity calculation between two solutions.")] 32 32 [StorableClass] 33 #pragma warning disable 0618 33 34 public abstract class SingleObjectiveSolutionSimilarityCalculator : SolutionSimilarityCalculator, ISingleObjectiveSolutionSimilarityCalculator { 34 #region Properties 35 [Storable] 36 public string SolutionVariableName { get; set; } 37 [Storable] 38 public string QualityVariableName { get; set; } 39 #endregion 40 35 #pragma warning restore 0618 41 36 [StorableConstructor] 42 37 protected SingleObjectiveSolutionSimilarityCalculator(bool deserializing) : base(deserializing) { } 43 38 protected SingleObjectiveSolutionSimilarityCalculator(SingleObjectiveSolutionSimilarityCalculator original, Cloner cloner) 44 39 : base(original, cloner) { 45 this.SolutionVariableName = original.SolutionVariableName; 46 this.QualityVariableName = original.QualityVariableName; 40 47 41 } 48 42 protected SingleObjectiveSolutionSimilarityCalculator() : base() { } -
stable/HeuristicLab.Optimization.Operators/3.3/SolutionSimilarityCalculator.cs
r12009 r12280 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 … … 33 34 [StorableClass] 34 35 public abstract class SolutionSimilarityCalculator : Item, ISolutionSimilarityCalculator { 36 protected abstract bool IsCommutative { get; } 37 38 #region Properties 39 [Storable] 40 public string SolutionVariableName { get; set; } 41 [Storable] 42 public string QualityVariableName { get; set; } 43 #endregion 44 35 45 [StorableConstructor] 36 46 protected SolutionSimilarityCalculator(bool deserializing) : base(deserializing) { } 37 protected SolutionSimilarityCalculator(SolutionSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } 47 48 protected SolutionSimilarityCalculator(SolutionSimilarityCalculator original, Cloner cloner) 49 : base(original, cloner) { 50 this.SolutionVariableName = original.SolutionVariableName; 51 this.QualityVariableName = original.QualityVariableName; 52 } 38 53 protected SolutionSimilarityCalculator() : base() { } 39 54 … … 71 86 for (int i = 0; i < individuals.Count; i++) similarityMatrix[i] = new double[individuals.Count]; 72 87 73 for (int i = 0; i < individuals.Count; i++) { 74 for (int j = i; j < individuals.Count; j++) { 75 similarityMatrix[i][j] = similarityMatrix[j][i] = CalculateSolutionSimilarity(individuals[i], individuals[j]); 88 if (IsCommutative) { 89 for (int i = 0; i < individuals.Count; i++) { 90 for (int j = i; j < individuals.Count; j++) { 91 similarityMatrix[i][j] = similarityMatrix[j][i] = CalculateSolutionSimilarity(individuals[i], individuals[j]); 92 } 93 } 94 } else { 95 for (int i = 0; i < individuals.Count; i++) { 96 for (int j = i; j < individuals.Count; j++) { 97 similarityMatrix[i][j] = CalculateSolutionSimilarity(individuals[i], individuals[j]); 98 if (i == j) continue; 99 similarityMatrix[j][i] = CalculateSolutionSimilarity(individuals[j], individuals[i]); 100 } 76 101 } 77 102 } … … 81 106 82 107 public abstract double CalculateSolutionSimilarity(IScope leftSolution, IScope rightSolution); 83 public abstract bool Equals(IScope x, IScope y); 84 public abstract int GetHashCode(IScope obj); 108 109 public virtual bool Equals(IScope x, IScope y) { 110 if (ReferenceEquals(x, y)) return true; 111 if (x == null || y == null) return false; 112 113 var q1 = x.Variables[QualityVariableName].Value; 114 var q2 = y.Variables[QualityVariableName].Value; 115 116 return CheckQualityEquality(q1, q2) && CalculateSolutionSimilarity(x, y).IsAlmost(1.0); 117 } 118 119 public virtual int GetHashCode(IScope scope) { 120 var quality = scope.Variables[QualityVariableName].Value; 121 var dv = quality as DoubleValue; 122 if (dv != null) 123 return dv.Value.GetHashCode(); 124 125 var da = quality as DoubleArray; 126 if (da != null) { 127 int hash = 17; 128 unchecked { 129 for (int i = 0; i < da.Length; ++i) { 130 hash += hash * 23 + da[i].GetHashCode(); 131 } 132 return hash; 133 } 134 } 135 return 0; 136 } 137 138 private static bool CheckQualityEquality(IItem q1, IItem q2) { 139 var d1 = q1 as DoubleValue; 140 var d2 = q2 as DoubleValue; 141 142 if (d1 != null && d2 != null) 143 return d1.Value.IsAlmost(d2.Value); 144 145 var da1 = q1 as DoubleArray; 146 var da2 = q2 as DoubleArray; 147 148 if (da1 != null && da2 != null) { 149 if (da1.Length != da2.Length) 150 throw new ArgumentException("The quality arrays must have the same length."); 151 152 for (int i = 0; i < da1.Length; ++i) { 153 if (!da1[i].IsAlmost(da2[i])) 154 return false; 155 } 156 157 return true; 158 } 159 160 throw new ArgumentException("Could not determine quality equality."); 161 } 85 162 } 86 163 } -
stable/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r12005 r12280 148 148 <DependentUpon>CreateNewSingleEncodingDialog.cs</DependentUpon> 149 149 </Compile> 150 <Compile Include="IS ingleObjectiveSolutionSimilarityCalculatorView.cs">151 <SubType>UserControl</SubType> 152 </Compile> 153 <Compile Include="IS ingleObjectiveSolutionSimilarityCalculatorView.Designer.cs">154 <DependentUpon>IS ingleObjectiveSolutionSimilarityCalculatorView.cs</DependentUpon>150 <Compile Include="ISolutionSimilarityCalculatorView.cs"> 151 <SubType>UserControl</SubType> 152 </Compile> 153 <Compile Include="ISolutionSimilarityCalculatorView.Designer.cs"> 154 <DependentUpon>ISolutionSimilarityCalculatorView.cs</DependentUpon> 155 155 </Compile> 156 156 <Compile Include="ExperimentListView.cs"> … … 159 159 <Compile Include="ExperimentListView.Designer.cs"> 160 160 <DependentUpon>ExperimentListView.cs</DependentUpon> 161 </Compile>162 <Compile Include="ISimilarityCalculatorView.cs">163 <SubType>UserControl</SubType>164 </Compile>165 <Compile Include="ISimilarityCalculatorView.Designer.cs">166 <DependentUpon>ISimilarityCalculatorView.cs</DependentUpon>167 161 </Compile> 168 162 <Compile Include="MultiEncodingView.cs"> -
stable/HeuristicLab.Optimization/3.3/Interfaces/ISimilarityBasedOperator.cs
r12009 r12280 24 24 namespace HeuristicLab.Optimization { 25 25 public interface ISimilarityBasedOperator : IOperator { 26 I SolutionSimilarityCalculator SimilarityCalculator { get; set; }26 IConstrainedValueParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter { get; } 27 27 } 28 28 } -
stable/HeuristicLab.Optimization/3.3/Interfaces/ISingleObjectiveSolutionSimilarityCalculator.cs
r12009 r12280 20 20 #endregion 21 21 22 using System; 23 22 24 namespace HeuristicLab.Optimization { 25 // use HeuristicLab.Optimization.ISolutionSimilarityCalculator instead 26 // BackwardsCompatibility3.3 27 #region Backwards compatible code, remove with 3.4 23 28 /// <summary> 24 29 /// An interface which represents an operator for similarity calculation between single objective solutions. 25 30 /// </summary> 31 [Obsolete("use HeuristicLab.Optimization.ISolutionSimilarityCalculator instead")] 26 32 public interface ISingleObjectiveSolutionSimilarityCalculator : ISolutionSimilarityCalculator, ISingleObjectiveOperator { 27 string SolutionVariableName { get; set; } 28 string QualityVariableName { get; set; } 33 29 34 } 35 #endregion 30 36 } -
stable/HeuristicLab.Optimization/3.3/Interfaces/ISolutionSimilarityCalculator.cs
r12009 r12280 28 28 /// </summary> 29 29 public interface ISolutionSimilarityCalculator : IItem, IEqualityComparer<IScope> { 30 string SolutionVariableName { get; set; } 31 string QualityVariableName { get; set; } 32 30 33 /// <summary> 31 34 /// Calculates the similarity of two solutions. -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 12069-12070
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r12009 r12280 233 233 Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer()); 234 234 Operators.Add(new SymbolicExpressionTreeLengthAnalyzer()); 235 Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());235 Operators.Add(new PopulationSimilarityAnalyzer(new[] { new SymbolicExpressionTreeBottomUpSimilarityCalculator() })); 236 236 ParameterizeOperators(); 237 237 } … … 357 357 op.SolutionVariableName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 358 358 } 359 foreach (var op in operators.OfType<SingleObjectivePopulationDiversityAnalyzer>()) {360 op.SimilarityCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator();361 }362 359 } 363 360 -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs
r11986 r12280 36 36 public class SymbolicExpressionTreeBottomUpSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 37 37 private readonly HashSet<string> commutativeSymbols = new HashSet<string> { "Addition", "Multiplication", "Average", "And", "Or", "Xor" }; 38 39 protected override bool IsCommutative { get { return true; } } 40 38 41 public SymbolicExpressionTreeBottomUpSimilarityCalculator() { } 39 42 -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator.cs
r12009 r12280 31 31 [Item("SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator", "A similarity calculator based on the size of the maximum common subtree between two trees")] 32 32 public class SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 33 protected override bool IsCommutative { get { return true; } } 34 33 35 [Storable] 34 36 private readonly SymbolicExpressionTreeNodeEqualityComparer comparer; -
stable/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
r12009 r12280 29 29 using HeuristicLab.Encodings.BinaryVectorEncoding; 30 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 31 32 using HeuristicLab.Parameters; 32 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 81 82 private BestKnapsackSolutionAnalyzer BestKnapsackSolutionAnalyzer { 82 83 get { return Operators.OfType<BestKnapsackSolutionAnalyzer>().FirstOrDefault(); } 83 }84 private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {85 get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }86 84 } 87 85 #endregion … … 248 246 BestKnapsackSolutionAnalyzer.ValuesParameter.Hidden = true; 249 247 } 250 251 if (SingleObjectivePopulationDiversityAnalyzer != null) {252 SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;253 SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;254 SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";255 SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<KnapsackSimilarityCalculator>().SingleOrDefault();256 }257 248 } 258 249 private void InitializeOperators() { … … 261 252 Operators.Add(new KnapsackSimultaneousPathRelinker()); 262 253 Operators.Add(new KnapsackSimilarityCalculator()); 254 Operators.Add(new QualitySimilarityCalculator()); 255 Operators.Add(new NoSimilarityCalculator()); 263 256 264 257 Operators.Add(new BestKnapsackSolutionAnalyzer()); 265 Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());258 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 266 259 ParameterizeAnalyzer(); 267 260 foreach (IBinaryVectorOperator op in ApplicationManager.Manager.GetInstances<IBinaryVectorOperator>()) { … … 317 310 op.ParentsParameter.Hidden = true; 318 311 } 319 foreach ( KnapsackSimilarityCalculator op in Operators.OfType<KnapsackSimilarityCalculator>()) {312 foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) { 320 313 op.SolutionVariableName = SolutionCreator.BinaryVectorParameter.ActualName; 321 314 op.QualityVariableName = Evaluator.QualityParameter.ActualName; -
stable/HeuristicLab.Problems.Knapsack/3.3/SimilarityCalculators/KnapsackSimilarityCalculator.cs
r12009 r12280 35 35 [Item("KnapsackSimilarityCalculator", "An operator that performs similarity calculation between two knapsack solutions. The operator calculates the similarity based on the number of elements the two solutions have in common.")] 36 36 public sealed class KnapsackSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 37 protected override bool IsCommutative { get { return true; } } 38 37 39 private KnapsackSimilarityCalculator(bool deserializing) : base(deserializing) { } 38 40 private KnapsackSimilarityCalculator(KnapsackSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } -
stable/HeuristicLab.Problems.QuadraticAssignment
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.QuadraticAssignment merged: 12070
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPSimilarityCalculator.cs
r12009 r12280 35 35 [Item("QAPSimilarityCalculator", "An operator that performs similarity calculation between two quadratic assignment solutions. The operator calculates the similarity based on the number of edges the two solutions have in common.")] 36 36 public sealed class QAPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 37 protected override bool IsCommutative { get { return true; } } 38 37 39 private QAPSimilarityCalculator(bool deserializing) : base(deserializing) { } 38 40 private QAPSimilarityCalculator(QAPSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } -
stable/HeuristicLab.Problems.TestFunctions
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.TestFunctions merged: 12069-12070,12087,12102,12126
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.TestFunctions/3.3/SimilarityCalculators/SingleObjectiveTestFunctionSimilarityCalculator.cs
r12009 r12280 38 38 [StorableClass] 39 39 public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 40 #region Properties 40 protected override bool IsCommutative { get { return true; } } 41 41 42 [Storable] 42 43 public DoubleMatrix Bounds { get; set; } 43 #endregion44 44 45 45 [StorableConstructor] -
stable/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r12009 r12280 29 29 using HeuristicLab.Encodings.RealVectorEncoding; 30 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 31 32 using HeuristicLab.Parameters; 32 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 71 72 private BestSingleObjectiveTestFunctionSolutionAnalyzer BestSingleObjectiveTestFunctionSolutionAnalyzer { 72 73 get { return Operators.OfType<BestSingleObjectiveTestFunctionSolutionAnalyzer>().FirstOrDefault(); } 73 }74 private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {75 get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }76 74 } 77 75 #endregion … … 258 256 BestSingleObjectiveTestFunctionSolutionAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name; 259 257 } 260 261 if (SingleObjectivePopulationDiversityAnalyzer != null) {262 SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;263 SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;264 SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";265 SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<SingleObjectiveTestFunctionSimilarityCalculator>().SingleOrDefault();266 }267 258 } 268 259 private void InitializeOperators() { … … 270 261 Operators.Add(new SingleObjectiveTestFunctionPathRelinker()); 271 262 Operators.Add(new SingleObjectiveTestFunctionSimilarityCalculator()); 263 Operators.Add(new QualitySimilarityCalculator()); 264 Operators.Add(new NoSimilarityCalculator()); 272 265 273 266 Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer()); 274 Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());267 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 275 268 ParameterizeAnalyzers(); 276 269 Operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>()); … … 325 318 try { 326 319 BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value); 327 } catch (ArgumentException e) { 320 } 321 catch (ArgumentException e) { 328 322 ErrorHandling.ShowErrorDialog(e); 329 323 ProblemSize.Value = Evaluator.MinimumProblemSize; … … 391 385 op.ParentsParameter.Hidden = true; 392 386 } 393 foreach (var op in Operators.OfType< SingleObjectiveTestFunctionSimilarityCalculator>()) {387 foreach (var op in Operators.OfType<ISolutionSimilarityCalculator>()) { 394 388 op.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName; 395 389 op.QualityVariableName = Evaluator.QualityParameter.ActualName; 396 op.Bounds = Bounds; 390 var calc = op as SingleObjectiveTestFunctionSimilarityCalculator; 391 if (calc != null) calc.Bounds = Bounds; 397 392 } 398 393 } -
stable/HeuristicLab.Problems.TravelingSalesman/3.3/SimilarityCalculators/TSPSimilarityCalculator.cs
r12009 r12280 35 35 [Item("TSPSimilarityCalculator", "An operator that performs similarity calculation between two traveling salesman solutions. The operator calculates the similarity based on the number of edges the two solutions have in common.")] 36 36 public sealed class TSPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 37 protected override bool IsCommutative { get { return true; } } 38 37 39 private TSPSimilarityCalculator(bool deserializing) : base(deserializing) { } 38 40 private TSPSimilarityCalculator(TSPSimilarityCalculator original, Cloner cloner) : base(original, cloner) { } -
stable/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r12009 r12280 30 30 using HeuristicLab.Encodings.PermutationEncoding; 31 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Optimization.Operators; 32 33 using HeuristicLab.Parameters; 33 34 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 81 82 private TSPAlleleFrequencyAnalyzer TSPAlleleFrequencyAnalyzer { 82 83 get { return Operators.OfType<TSPAlleleFrequencyAnalyzer>().FirstOrDefault(); } 83 }84 private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {85 get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }86 84 } 87 85 #endregion … … 236 234 Operators.Add(new TSPSimultaneousPathRelinker()); 237 235 Operators.Add(new TSPSimilarityCalculator()); 236 Operators.Add(new QualitySimilarityCalculator()); 237 Operators.Add(new NoSimilarityCalculator()); 238 238 239 239 Operators.Add(new BestTSPSolutionAnalyzer()); 240 240 Operators.Add(new TSPAlleleFrequencyAnalyzer()); 241 Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());241 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 242 242 ParameterizeAnalyzers(); 243 243 var operators = new HashSet<IPermutationOperator>(new IPermutationOperator[] { … … 319 319 TSPAlleleFrequencyAnalyzer.ResultsParameter.ActualName = "Results"; 320 320 } 321 322 if (SingleObjectivePopulationDiversityAnalyzer != null) {323 SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;324 SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;325 SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";326 SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<TSPSimilarityCalculator>().SingleOrDefault();327 }328 321 } 329 322 private void ParameterizeOperators() { … … 366 359 op.ParentsParameter.Hidden = true; 367 360 } 368 foreach ( TSPSimilarityCalculator op in Operators.OfType<TSPSimilarityCalculator>()) {361 foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) { 369 362 op.SolutionVariableName = SolutionCreator.PermutationParameter.ActualName; 370 363 op.QualityVariableName = Evaluator.QualityParameter.ActualName; -
stable/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.VehicleRouting merged: 12069-12070,12087,12102
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.VehicleRouting/3.4/SimilarityCalculators/VRPSimilarityCalculator.cs
r12009 r12280 40 40 [StorableClass] 41 41 public sealed class VRPSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator { 42 #region Properties 42 protected override bool IsCommutative { get { return true; } } 43 43 44 [Storable] 44 45 public IVRPProblemInstance ProblemInstance { get; set; } 45 #endregion46 46 47 47 private VRPSimilarityCalculator(bool deserializing) : base(deserializing) { } -
stable/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r12009 r12280 29 29 using HeuristicLab.Data; 30 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 31 32 using HeuristicLab.Parameters; 32 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 114 115 set { SolutionCreatorParameter.Value = value; } 115 116 } 116 private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {117 get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }118 }119 117 #endregion 120 118 … … 256 254 ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name)); 257 255 Operators.Add(new VRPSimilarityCalculator()); 258 Operators.Add(new SingleObjectivePopulationDiversityAnalyzer()); 256 Operators.Add(new QualitySimilarityCalculator()); 257 Operators.Add(new NoSimilarityCalculator()); 258 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 259 259 260 260 IVRPCreator defaultCreator = null; … … 287 287 op.ParentsParameter.Hidden = true; 288 288 } 289 foreach ( VRPSimilarityCalculator op in Operators.OfType<VRPSimilarityCalculator>()) {289 foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) { 290 290 op.SolutionVariableName = SolutionCreator.VRPToursParameter.ActualName; 291 291 op.QualityVariableName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName; 292 op.ProblemInstance = ProblemInstance; 293 } 294 if (SingleObjectivePopulationDiversityAnalyzer != null) { 295 SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name; 296 SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName; 297 SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results"; 298 SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<VRPSimilarityCalculator>().SingleOrDefault(); 292 var calc = op as VRPSimilarityCalculator; 293 if (calc != null) calc.ProblemInstance = ProblemInstance; 299 294 } 300 295 }
Note: See TracChangeset
for help on using the changeset viewer.