Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13778


Ignore:
Timestamp:
04/21/16 13:40:48 (8 years ago)
Author:
pkuelzer
Message:

#2558 added wiring of island alps offspring selection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/IslandALPS/IslandALPS/3.3/Offspring Selection/IslandAlpsOffspringSelectionAlgorithm.cs

    r13734 r13778  
    372372
    373373      #region parametrize
    374 
     374      UpdateAnalyzers();
    375375      ParameterizeAnalyzers();
    376       UpdateAnalyzers();
    377376      ParameterizeSelectors();
    378377      UpdateTerminators();
     
    447446    #region events
    448447
     448    protected override void RegisterProblemEvents() {
     449      base.RegisterProblemEvents();
     450      var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
     451      if (maximizationParameter != null) maximizationParameter.ValueChanged += MaximizationParameter_ValueChanged;
     452    }
     453    protected override void DeregisterProblemEvents() {
     454      var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
     455      if (maximizationParameter != null) maximizationParameter.ValueChanged -= MaximizationParameter_ValueChanged;
     456      base.DeregisterProblemEvents();
     457    }
     458
    449459    protected override void OnProblemChanged() {
    450460      base.OnProblemChanged();
     
    459469      ParameterizeSelectors();
    460470      ParameterizeAnalyzers();
     471      ParameterizeTerminators();
    461472      ParameterizeIterationBasedOperators();
     473
     474      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
    462475
    463476      UpdateAnalyzers();
     
    470483      base.Problem_SolutionCreatorChanged(sender, e);
    471484      ParameterizeStochasticOperator(Problem.SolutionCreator);
     485      ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
     486
     487      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
     488
    472489      ParameterizeSolutionsCreator();
     490      ParameterizeAnalyzers();
    473491    }
    474492
     
    493511    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
    494512      base.Problem_OperatorsChanged(sender, e);
     513      ParameterizeIterationBasedOperators();
     514      UpdateCrossovers();
     515      UpdateMutators();
    495516      UpdateAnalyzers();
    496517      UpdateTerminators();
     518    }
     519
     520    private void InitializeEventHandler() {
     521      PopulationSizeParameter.ValueChanged += PopulationSizeParameter_ValueChanged;
     522      PopulationSize.ValueChanged += PopulationSize_ValueChanged;
     523      ElitesParameter.ValueChanged += ElitesParameter_ValueChanged;
     524      Elites.ValueChanged += Elites_ValueChanged;
     525      MigrationRateParameter.Value.ValueChanged += MigrationRate_ValueChanged;
     526      MigrationRateParameter.ValueChanged += MigrationRate_ValueChanged;
     527
     528      Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded;
     529      IslandAnalyzer.Operators.ItemsAdded += IslandAnalyzerOperators_ItemsAdded;
     530      LayerAnalyzer.Operators.ItemsAdded += LayerAnalyzerOperators_ItemsAdded;
     531      GroupAnalyzer.Operators.ItemsAdded += GroupAnalyzerOperators_ItemsAdded;
     532
     533      if (Problem != null) {
     534        Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
     535      }
     536
     537      AgeGapParameter.ValueChanged += AgeGapParameter_ValueChanged;
     538      AgeGap.ValueChanged += AgeGap_ValueChanged;
     539      AgingSchemeParameter.ValueChanged += AgingSchemeParameter_ValueChanged;
     540      AgingScheme.ValueChanged += AgingScheme_ValueChanged;
     541
     542      NumberOfLayersParameter.ValueChanged += NumberOfLayersParameter_ValueChanged;
     543      NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
     544      qualityAnalyzer.CurrentBestQualityParameter.NameChanged += QualityAnalyzer_CurrentBestQualityParameter_NameChanged;
     545    }
     546
     547    private void MigrationRate_ValueChanged(object sender, EventArgs e) {
     548      var migrationSize = (int)Math.Ceiling(MigrationRateParameter.Value.Value * PopulationSize.Value);
     549      foreach (var selector in EmigrantsSelectorParameter.ValidValues) {
     550        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize);
     551      }
     552    }
     553
     554    private void GroupAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
     555      foreach (var analyzer in e.Items) {
     556        IParameter resultParameter;
     557        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
     558          var lookupParameter = resultParameter as ILookupParameter;
     559          if (lookupParameter != null)
     560            lookupParameter.ActualName = "GroupResults";
     561        }
     562        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
     563          parameter.Depth = 1;
     564        }
     565      }
     566    }
     567    private void IslandAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
     568      foreach (var analyzer in e.Items) {
     569        IParameter resultParameter;
     570        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
     571          var lookupParameter = resultParameter as ILookupParameter;
     572          if (lookupParameter != null)
     573            lookupParameter.ActualName = "IslandResults";
     574        }
     575        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
     576          parameter.Depth = 2;
     577        }
     578      }
     579    }
     580    private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
     581      foreach (var analyzer in e.Items) {
     582        IParameter resultParameter;
     583        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
     584          var lookupParameter = resultParameter as ILookupParameter;
     585          if (lookupParameter != null)
     586            lookupParameter.ActualName = "LayerResults";
     587        }
     588        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
     589          parameter.Depth = 1;
     590        }
     591      }
     592    }
     593
     594    private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
     595      foreach (var analyzer in e.Items) {
     596        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
     597          parameter.Depth = 3;
     598        }
     599      }
     600    }
     601
     602    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
     603      ParameterizeMainLoop();
     604      ParameterizeSelectors();
     605      ParameterizeAnalyzers();
     606    }
     607
     608    private void MaximizationParameter_ValueChanged(object sender, EventArgs e) {
     609      ParameterizeTerminators();
     610    }
     611    private void QualityAnalyzer_CurrentBestQualityParameter_NameChanged(object sender, EventArgs e) {
     612      ParameterizeTerminators();
     613    }
     614    private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
     615      ParameterizeSelectors();
     616    }
     617
     618    private void Elites_ValueChanged(object sender, EventArgs e) {
     619      ParameterizeSelectors();
     620    }
     621
     622    private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
     623      ParameterizeSelectors();
     624    }
     625
     626    private void PopulationSize_ValueChanged(object sender, EventArgs e) {
     627      ParameterizeSelectors();
     628    }
     629
     630    private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) {
     631      NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
     632      ParameterizeAgeLimits();
     633    }
     634
     635    private void NumberOfLayers_ValueChanged(object sender, EventArgs e) {
     636      ParameterizeAgeLimits();
     637    }
     638
     639    private void AgeGapParameter_ValueChanged(object sender, EventArgs e) {
     640      AgeGap.ValueChanged += AgeGap_ValueChanged;
     641      ParameterizeAgeLimits();
     642    }
     643
     644    private void AgeGap_ValueChanged(object sender, EventArgs e) {
     645      ParameterizeAgeLimits();
     646    }
     647
     648    private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) {
     649      AgingScheme.ValueChanged += AgingScheme_ValueChanged;
     650      ParameterizeAgeLimits();
     651    }
     652
     653    private void AgingScheme_ValueChanged(object sender, EventArgs e) {
     654      ParameterizeAgeLimits();
    497655    }
    498656
     
    584742    }
    585743
    586     private void InitializeEventHandler() {
    587       PopulationSizeParameter.ValueChanged += PopulationSizeParameter_ValueChanged;
    588       PopulationSize.ValueChanged += PopulationSize_ValueChanged;
    589       ElitesParameter.ValueChanged += ElitesParameter_ValueChanged;
    590       Elites.ValueChanged += Elites_ValueChanged;
    591       MigrationRateParameter.Value.ValueChanged += MigrationRate_ValueChanged;
    592       MigrationRateParameter.ValueChanged += MigrationRate_ValueChanged;
    593 
    594       Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded;
    595       IslandAnalyzer.Operators.ItemsAdded += IslandAnalyzerOperators_ItemsAdded;
    596       LayerAnalyzer.Operators.ItemsAdded += LayerAnalyzerOperators_ItemsAdded;
    597       GroupAnalyzer.Operators.ItemsAdded += GroupAnalyzerOperators_ItemsAdded;
    598 
    599       if (Problem != null) {
    600         Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
    601       }
    602 
    603       AgeGapParameter.ValueChanged += AgeGapParameter_ValueChanged;
    604       AgeGap.ValueChanged += AgeGap_ValueChanged;
    605       AgingSchemeParameter.ValueChanged += AgingSchemeParameter_ValueChanged;
    606       AgingScheme.ValueChanged += AgingScheme_ValueChanged;
    607 
    608       NumberOfLayersParameter.ValueChanged += NumberOfLayersParameter_ValueChanged;
    609       NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
    610     }
    611 
    612     private void MigrationRate_ValueChanged(object sender, EventArgs e) {
    613       var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value*PopulationSize.Value);
    614       foreach (var selector in EmigrantsSelectorParameter.ValidValues) {
    615         selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize);
    616       }
    617     }
    618 
    619     private void GroupAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
    620       foreach (var analyzer in e.Items) {
    621         IParameter resultParameter;
    622         if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
    623           var lookupParameter = resultParameter as ILookupParameter;
    624           if (lookupParameter != null)
    625             lookupParameter.ActualName = "GroupResults";
    626         }
    627         foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
    628           parameter.Depth = 1;
    629         }
    630       }
    631     }
    632 
    633     private void IslandAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
    634       foreach (var analyzer in e.Items) {
    635         IParameter resultParameter;
    636         if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
    637           var lookupParameter = resultParameter as ILookupParameter;
    638           if (lookupParameter != null)
    639             lookupParameter.ActualName = "IslandResults";
    640         }
    641         foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
    642           parameter.Depth = 2;
    643         }
    644       }
    645     }
    646 
    647     private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
    648       foreach (var analyzer in e.Items) {
    649         IParameter resultParameter;
    650         if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
    651           var lookupParameter = resultParameter as ILookupParameter;
    652           if (lookupParameter != null)
    653             lookupParameter.ActualName = "LayerResults";
    654         }
    655         foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
    656           parameter.Depth = 1;
    657         }
    658       }
    659     }
    660 
    661     private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
    662       foreach (var analyzer in e.Items) {
    663         foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
    664           parameter.Depth = 3;
    665         }
    666       }
    667     }
    668 
    669     private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    670       ParameterizeMainLoop();
    671       ParameterizeSelectors();
    672       ParameterizeAnalyzers();
    673     }
    674 
    675     private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
    676       ParameterizeSelectors();
    677     }
    678 
    679     private void Elites_ValueChanged(object sender, EventArgs e) {
    680       ParameterizeSelectors();
    681     }
    682 
    683     private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
    684       ParameterizeSelectors();
    685     }
    686 
    687     private void PopulationSize_ValueChanged(object sender, EventArgs e) {
    688       ParameterizeSelectors();
    689     }
    690 
    691     private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) {
    692       NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
    693       ParameterizeAgeLimits();
    694     }
    695 
    696     private void NumberOfLayers_ValueChanged(object sender, EventArgs e) {
    697       ParameterizeAgeLimits();
    698     }
    699 
    700     private void AgeGapParameter_ValueChanged(object sender, EventArgs e) {
    701       AgeGap.ValueChanged += AgeGap_ValueChanged;
    702       ParameterizeAgeLimits();
    703     }
    704 
    705     private void AgeGap_ValueChanged(object sender, EventArgs e) {
    706       ParameterizeAgeLimits();
    707     }
    708 
    709     private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) {
    710       AgingScheme.ValueChanged += AgingScheme_ValueChanged;
    711       ParameterizeAgeLimits();
    712     }
    713 
    714     private void AgingScheme_ValueChanged(object sender, EventArgs e) {
    715       ParameterizeAgeLimits();
    716     }
    717 
    718744    private void ParameterizeAgeLimits() {
    719745      var scheme = AgingScheme.Value;
Note: See TracChangeset for help on using the changeset viewer.