- Timestamp:
- 05/27/15 10:54:06 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/TerminationCriteria/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r12402 r12403 387 387 } 388 388 389 protected override void RegisterProblemEvents() { 390 base.RegisterProblemEvents(); 391 var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter; 392 if (maximizationParameter != null) maximizationParameter.ValueChanged += new EventHandler(MaximizationParameter_ValueChanged); 393 } 394 protected override void DeregisterProblemEvents() { 395 var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter; 396 if (maximizationParameter != null) maximizationParameter.ValueChanged -= new EventHandler(MaximizationParameter_ValueChanged); 397 base.DeregisterProblemEvents(); 398 } 399 389 400 protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) { 390 401 ParameterizeStochasticOperator(Problem.SolutionCreator); … … 429 440 ParameterizeAnalyzers(); 430 441 } 442 private void MaximizationParameter_ValueChanged(object sender, EventArgs e) { 443 ParameterizeTerminators(); 444 } 445 private void QualityAnalyzer_CurrentBestQualityParameter_NameChanged(object sender, EventArgs e) { 446 ParameterizeTerminators(); 447 } 431 448 #endregion 432 449 … … 437 454 ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged); 438 455 Elites.ValueChanged += new EventHandler(Elites_ValueChanged); 456 qualityAnalyzer.CurrentBestQualityParameter.NameChanged += new EventHandler(QualityAnalyzer_CurrentBestQualityParameter_NameChanged); 439 457 if (Problem != null) { 440 458 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); … … 487 505 private void ParameterizeTerminators() { 488 506 if (Problem != null) { 489 bool maximization = ((BoolValue)Problem.MaximizationParameter.ActualValue).Value; 490 qualityTerminator.Comparison = new Comparison(maximization ? ComparisonType.GreaterOrEqual : ComparisonType.LessOrEqual); 491 qualityTerminator.ValueParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name; 492 qualityTerminator.ThresholdParameter.Value = new DoubleValue(maximization ? double.MaxValue : double.MinValue); 493 } 507 var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter; 508 if (maximizationParameter != null) { 509 bool maximization = maximizationParameter.Value.Value; 510 qualityTerminator.Comparison = new Comparison(maximization ? ComparisonType.GreaterOrEqual : ComparisonType.LessOrEqual); 511 qualityTerminator.ThresholdParameter.Value = new DoubleValue(maximization ? double.MaxValue : double.MinValue); 512 } 513 } 514 qualityTerminator.ValueParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name; 494 515 } 495 516 private void ParameterizeComparisonFactorModifiers() {
Note: See TracChangeset
for help on using the changeset viewer.