- Timestamp:
- 10/31/14 13:52:02 (10 years ago)
- Location:
- branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm-3.3.csproj
r11513 r11516 172 172 <Compile Include="VOffspringSelectionGeneticAlgorithmMainLoop.cs" /> 173 173 <Compile Include="VOffspringSelectionGeneticAlgorithmMainOperator.cs" /> 174 <Compile Include="WeightedParentsDiversityComparator.cs" /> 174 175 <Compile Include="WeightedParentsQualityComparator.cs" /> 175 176 </ItemGroup> -
branches/VOSGA/HeuristicLab.Algorithms.VOffspringSelectionGeneticAlgorithm/VOffspringSelectionGeneticAlgorithm.cs
r11513 r11516 121 121 get { return (ConstrainedValueParameter<ISubScopesQualityComparatorOperator>)Parameters["SubScopesQualityComparator"]; } 122 122 } 123 public IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter { 124 get { return (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 125 } 123 126 #endregion 124 127 … … 218 221 private SolutionsCreator SolutionsCreator { 219 222 get { return (SolutionsCreator)RandomCreator.Successor; } 223 } 224 public ISingleObjectiveSolutionSimilarityCalculator SimilarityCalculator { 225 get { return SimilarityCalculatorParameter.Value; } 226 set { SimilarityCalculatorParameter.Value = value; } 220 227 } 221 228 private VOffspringSelectionGeneticAlgorithmMainLoop MainLoop { … … 281 288 Parameters.Add(new ConstrainedValueParameter<IOffspringSelector>("OffspringSelector", "The operator used as selection criterea for deciding which individuals are successful and which should be disgarded.")); 282 289 Parameters.Add(new ConstrainedValueParameter<ISubScopesQualityComparatorOperator>("SubScopesQualityComparator", "The operator used to compare solution candidates with.")); 290 Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.")); 283 291 284 292 RandomCreator randomCreator = new RandomCreator(); … … 378 386 ParameterizeSubScopesQualityComparators(); 379 387 ParameterizeOffspringSelectors(); 388 UpdateSimilarityCalculators(); 380 389 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 381 390 base.OnProblemChanged(); … … 422 431 ParameterizeSelectors(); 423 432 ParameterizeAnalyzers(); 433 ParameterizeSimilarityCalculators(); 424 434 } 425 435 #endregion … … 434 444 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 435 445 } 446 SimilarityCalculatorParameter.ValueChanged += SimilarityCalculatorParameter_ValueChanged; 447 } 448 void SimilarityCalculatorParameter_ValueChanged(object sender, EventArgs e) { 449 foreach (ISimilarityBasedOperator op in SubScopesQualityComparatorParameter.ValidValues.OfType<ISimilarityBasedOperator>()) 450 op.SimilarityCalculator = SimilarityCalculator; 436 451 } 437 452 private void ParameterizeSolutionsCreator() { … … 560 575 Analyzer.Operators.Add(successfulOffspringAnalyzer, successfulOffspringAnalyzer.EnabledByDefault); 561 576 } 577 private void UpdateSimilarityCalculators() { 578 ISingleObjectiveSolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value; 579 SimilarityCalculatorParameter.ValidValues.Clear(); 580 ISingleObjectiveSolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault(); 581 582 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 583 SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator()); 584 585 foreach (ISingleObjectiveSolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>()) 586 SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator); 587 588 if (oldSimilarityCalculator != null) { 589 ISingleObjectiveSolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType()); 590 if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator; 591 else oldSimilarityCalculator = null; 592 } 593 if (oldSimilarityCalculator == null && defaultSimilarityCalculator != null) 594 SimilarityCalculatorParameter.Value = defaultSimilarityCalculator; 595 } 596 private void ParameterizeSimilarityCalculators() { 597 foreach (ISingleObjectiveSolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) { 598 calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName; 599 } 600 } 562 601 private VOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) { 563 602 IOperator mainLoop = start;
Note: See TracChangeset
for help on using the changeset viewer.