Changeset 13777
- Timestamp:
- 04/21/16 13:22:21 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs
r13723 r13777 366 366 #region parametrize 367 367 368 UpdateAnalyzers(); 368 369 ParameterizeAnalyzers(); 369 UpdateAnalyzers(); 370 370 371 ParameterizeSelectors(); 371 372 UpdateTerminators(); … … 432 433 #region events 433 434 435 protected override void RegisterProblemEvents() { 436 base.RegisterProblemEvents(); 437 var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter; 438 if (maximizationParameter != null) maximizationParameter.ValueChanged += MaximizationParameter_ValueChanged; 439 } 440 protected override void DeregisterProblemEvents() { 441 var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter; 442 if (maximizationParameter != null) maximizationParameter.ValueChanged -= MaximizationParameter_ValueChanged; 443 base.DeregisterProblemEvents(); 444 } 445 434 446 protected override void OnProblemChanged() { 435 447 base.OnProblemChanged(); … … 444 456 ParameterizeSelectors(); 445 457 ParameterizeAnalyzers(); 458 ParameterizeTerminators(); 446 459 ParameterizeIterationBasedOperators(); 460 461 Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged; 447 462 448 463 UpdateAnalyzers(); … … 454 469 protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) { 455 470 base.Problem_SolutionCreatorChanged(sender, e); 471 456 472 ParameterizeStochasticOperator(Problem.SolutionCreator); 473 ParameterizeStochasticOperatorForLayer(Problem.Evaluator); 474 475 Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged; 476 457 477 ParameterizeSolutionsCreator(); 458 }459 478 ParameterizeAnalyzers(); 479 } 460 480 protected override void Problem_EvaluatorChanged(object sender, EventArgs e) { 461 481 base.Problem_EvaluatorChanged(sender, e); … … 475 495 UpdateTerminators(); 476 496 } 477 478 497 protected override void Problem_OperatorsChanged(object sender, EventArgs e) { 479 498 base.Problem_OperatorsChanged(sender, e); 499 ParameterizeIterationBasedOperators(); 500 UpdateCrossovers(); 501 UpdateMutators(); 480 502 UpdateAnalyzers(); 481 503 UpdateTerminators(); 504 } 505 506 private void GroupAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 507 foreach (var analyzer in e.Items) { 508 IParameter resultParameter; 509 if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) { 510 var lookupParameter = resultParameter as ILookupParameter; 511 if (lookupParameter != null) 512 lookupParameter.ActualName = "GroupResults"; 513 } 514 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 515 parameter.Depth = 1; 516 } 517 } 518 } 519 private void IslandAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 520 foreach (var analyzer in e.Items) { 521 IParameter resultParameter; 522 if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) { 523 var lookupParameter = resultParameter as ILookupParameter; 524 if (lookupParameter != null) 525 lookupParameter.ActualName = "IslandResults"; 526 } 527 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 528 parameter.Depth = 2; 529 } 530 } 531 } 532 private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 533 foreach (var analyzer in e.Items) { 534 IParameter resultParameter; 535 if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) { 536 var lookupParameter = resultParameter as ILookupParameter; 537 if (lookupParameter != null) 538 lookupParameter.ActualName = "LayerResults"; 539 } 540 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 541 parameter.Depth = 1; 542 } 543 } 544 } 545 private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 546 foreach (var analyzer in e.Items) { 547 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 548 parameter.Depth = 3; 549 } 550 } 551 } 552 553 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 554 ParameterizeMainLoop(); 555 ParameterizeSelectors(); 556 ParameterizeAnalyzers(); 557 } 558 private void MaximizationParameter_ValueChanged(object sender, EventArgs e) { 559 ParameterizeTerminators(); 560 } 561 private void QualityAnalyzer_CurrentBestQualityParameter_NameChanged(object sender, EventArgs e) { 562 ParameterizeTerminators(); 563 } 564 private void ElitesParameter_ValueChanged(object sender, EventArgs e) { 565 ParameterizeSelectors(); 566 } 567 568 private void Elites_ValueChanged(object sender, EventArgs e) { 569 ParameterizeSelectors(); 570 } 571 572 private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) { 573 ParameterizeSelectors(); 574 } 575 576 private void PopulationSize_ValueChanged(object sender, EventArgs e) { 577 ParameterizeSelectors(); 578 } 579 580 private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) { 581 NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged; 582 ParameterizeAgeLimits(); 583 } 584 private void NumberOfLayers_ValueChanged(object sender, EventArgs e) { 585 ParameterizeAgeLimits(); 586 } 587 588 private void AgeGapParameter_ValueChanged(object sender, EventArgs e) { 589 AgeGap.ValueChanged += AgeGap_ValueChanged; 590 ParameterizeAgeLimits(); 591 } 592 593 private void AgeGap_ValueChanged(object sender, EventArgs e) { 594 ParameterizeAgeLimits(); 595 } 596 597 private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) { 598 AgingScheme.ValueChanged += AgingScheme_ValueChanged; 599 ParameterizeAgeLimits(); 600 } 601 private void AgingScheme_ValueChanged(object sender, EventArgs e) { 602 ParameterizeAgeLimits(); 603 } 604 605 private void MigrationRate_ValueChanged(object sender, EventArgs e) { 606 var migrationSize = (int)Math.Ceiling(MigrationRateParameter.Value.Value * PopulationSize.Value); 607 foreach (var selector in EmigrantsSelectorParameter.ValidValues) { 608 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize); 609 } 482 610 } 483 611 … … 593 721 NumberOfLayersParameter.ValueChanged += NumberOfLayersParameter_ValueChanged; 594 722 NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged; 595 } 596 597 private void MigrationRate_ValueChanged(object sender, EventArgs e) { 598 var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value*PopulationSize.Value); 599 foreach (var selector in EmigrantsSelectorParameter.ValidValues) { 600 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize); 601 } 602 } 603 604 private void GroupAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 605 foreach (var analyzer in e.Items) { 606 IParameter resultParameter; 607 if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) { 608 var lookupParameter = resultParameter as ILookupParameter; 609 if (lookupParameter != null) 610 lookupParameter.ActualName = "GroupResults"; 611 } 612 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 613 parameter.Depth = 1; 614 } 615 } 616 } 617 618 private void IslandAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 619 foreach (var analyzer in e.Items) { 620 IParameter resultParameter; 621 if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) { 622 var lookupParameter = resultParameter as ILookupParameter; 623 if (lookupParameter != null) 624 lookupParameter.ActualName = "IslandResults"; 625 } 626 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 627 parameter.Depth = 2; 628 } 629 } 630 } 631 632 private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 633 foreach (var analyzer in e.Items) { 634 IParameter resultParameter; 635 if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) { 636 var lookupParameter = resultParameter as ILookupParameter; 637 if (lookupParameter != null) 638 lookupParameter.ActualName = "LayerResults"; 639 } 640 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 641 parameter.Depth = 1; 642 } 643 } 644 } 645 646 private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 647 foreach (var analyzer in e.Items) { 648 foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) { 649 parameter.Depth = 3; 650 } 651 } 652 } 653 654 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 655 ParameterizeMainLoop(); 656 ParameterizeSelectors(); 657 ParameterizeAnalyzers(); 658 } 659 660 private void ElitesParameter_ValueChanged(object sender, EventArgs e) { 661 ParameterizeSelectors(); 662 } 663 664 private void Elites_ValueChanged(object sender, EventArgs e) { 665 ParameterizeSelectors(); 666 } 667 668 private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) { 669 ParameterizeSelectors(); 670 } 671 672 private void PopulationSize_ValueChanged(object sender, EventArgs e) { 673 ParameterizeSelectors(); 674 } 675 676 private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) { 677 NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged; 678 ParameterizeAgeLimits(); 679 } 680 681 private void NumberOfLayers_ValueChanged(object sender, EventArgs e) { 682 ParameterizeAgeLimits(); 683 } 684 685 private void AgeGapParameter_ValueChanged(object sender, EventArgs e) { 686 AgeGap.ValueChanged += AgeGap_ValueChanged; 687 ParameterizeAgeLimits(); 688 } 689 690 private void AgeGap_ValueChanged(object sender, EventArgs e) { 691 ParameterizeAgeLimits(); 692 } 693 694 private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) { 695 AgingScheme.ValueChanged += AgingScheme_ValueChanged; 696 ParameterizeAgeLimits(); 697 } 698 699 private void AgingScheme_ValueChanged(object sender, EventArgs e) { 700 ParameterizeAgeLimits(); 701 } 702 723 qualityAnalyzer.CurrentBestQualityParameter.NameChanged += QualityAnalyzer_CurrentBestQualityParameter_NameChanged; 724 725 } 703 726 private void ParameterizeAgeLimits() { 704 727 var scheme = AgingScheme.Value;
Note: See TracChangeset
for help on using the changeset viewer.