- Timestamp:
- 09/11/12 11:41:19 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearch.cs
r8380 r8628 88 88 get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 89 89 } 90 public IConstrainedValueParameter<IS olutionSimilarityCalculator> SimilarityCalculatorParameter {91 get { return (IConstrainedValueParameter<IS olutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }90 public IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter { 91 get { return (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 92 92 } 93 93 #endregion … … 138 138 set { SetSeedRandomlyParameter.Value = value; } 139 139 } 140 public IS olutionSimilarityCalculator SimilarityCalculator {140 public ISingleObjectiveSolutionSimilarityCalculator SimilarityCalculator { 141 141 get { return SimilarityCalculatorParameter.Value; } 142 142 set { SimilarityCalculatorParameter.Value = value; } … … 184 184 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 185 185 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 olutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));186 Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.")); 187 187 #endregion 188 188 … … 307 307 base.Problem_OperatorsChanged(sender, e); 308 308 } 309 private void SimilarityCalculatorParameter_ValueChanged(object sender, EventArgs e) { 310 ParameterizeMainLoop(); 311 } 309 312 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 310 313 ParameterizeMainLoop(); 311 314 ParameterizeAnalyzers(); 312 315 ParameterizeBestSelector(); 316 ParameterizeSimilarityCalculators(); 313 317 } 314 318 #endregion … … 316 320 #region Helpers 317 321 private void Initialize() { 322 SimilarityCalculatorParameter.ValueChanged += new EventHandler(SimilarityCalculatorParameter_ValueChanged); 318 323 if (Problem != null) 319 324 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); … … 379 384 } 380 385 private void UpdateSimilarityCalculators() { 381 IS olutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value;386 ISingleObjectiveSolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value; 382 387 SimilarityCalculatorParameter.ValidValues.Clear(); 383 ISolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISolutionSimilarityCalculator>().FirstOrDefault(); 384 385 foreach (ISolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISolutionSimilarityCalculator>()) 388 ISingleObjectiveSolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault(); 389 390 SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator { QualityVariableName = Problem.Evaluator.QualityParameter.ActualName }); 391 SimilarityCalculatorParameter.ValidValues.Add(new BlindSimilarityCalculator()); 392 393 foreach (ISingleObjectiveSolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISingleObjectiveSolutionSimilarityCalculator>()) 386 394 SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator); 387 395 388 396 if (oldSimilarityCalculator != null) { 389 IS olutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType());397 ISingleObjectiveSolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType()); 390 398 if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator; 391 399 else oldSimilarityCalculator = null; … … 434 442 } 435 443 } 444 private void ParameterizeSimilarityCalculators() { 445 foreach (ISingleObjectiveSolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) { 446 calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName; 447 } 448 } 436 449 private ScatterSearchMainLoop FindMainLoop(IOperator start) { 437 450 IOperator mainLoop = start;
Note: See TracChangeset
for help on using the changeset viewer.