Changeset 8407 for branches/RAPGA
- Timestamp:
- 08/03/12 12:02:08 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RAPGA/HeuristicLab.Algorithms.RAPGA/3.3/RAPGA.cs
r8406 r8407 100 100 get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; } 101 101 } 102 public IConstrainedValueParameter<IS olutionSimilarityCalculator> SimilarityCalculatorParameter {103 get { return (IConstrainedValueParameter<IS olutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }102 public IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter { 103 get { return (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 104 104 } 105 105 #endregion … … 166 166 set { MaximumGenerationsParameter.Value = value; } 167 167 } 168 public IS olutionSimilarityCalculator SimilarityCalculator {168 public ISingleObjectiveSolutionSimilarityCalculator SimilarityCalculator { 169 169 get { return SimilarityCalculatorParameter.Value; } 170 170 set { SimilarityCalculatorParameter.Value = value; } … … 218 218 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 219 219 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); 220 Parameters.Add(new ConstrainedValueParameter<IS olutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));220 Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.")); 221 221 222 222 RandomCreator randomCreator = new RandomCreator(); … … 351 351 ParameterizeSelectors(); 352 352 ParameterizeAnalyzers(); 353 ParameterizeSimilarityCalculators(); 353 354 } 354 355 #endregion … … 431 432 } 432 433 } 434 private void ParameterizeSimilarityCalculators() { 435 foreach (ISingleObjectiveSolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) { 436 calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName; 437 } 438 } 433 439 private void UpdateCrossovers() { 434 440 ICrossover oldCrossover = CrossoverParameter.Value; … … 472 478 } 473 479 private void UpdateSimilarityCalculators() { 474 IS olutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value;480 ISingleObjectiveSolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value; 475 481 SimilarityCalculatorParameter.ValidValues.Clear(); 476 ISolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISolutionSimilarityCalculator>().FirstOrDefault(); 477 482 ISingleObjectiveSolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault(); 483 484 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 478 485 SimilarityCalculatorParameter.ValidValues.Add(new BlindSimilarityCalculator()); 479 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator()); 480 481 foreach (ISolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISolutionSimilarityCalculator>()) 486 487 foreach (ISingleObjectiveSolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>()) 482 488 SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator); 483 489 484 490 if (oldSimilarityCalculator != null) { 485 IS olutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType());491 ISingleObjectiveSolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType()); 486 492 if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator; 487 493 else oldSimilarityCalculator = null;
Note: See TracChangeset
for help on using the changeset viewer.