Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/13 10:51:01 (12 years ago)
Author:
mkommend
Message:

#1997: Improved wiring of SymbolicDataAnalysisIslandGA.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs

    r9077 r9172  
    111111      Parameters.Add(new LookupParameter<ISingleObjectiveEvaluator>(ProblemEvaluatorParameterName, "Internal parameter for name translation", "Evaluator"));
    112112
     113      Elites.Value = 0;
     114      ElitesParameter.Hidden = true;
     115
    113116      ScopeTreeAssigner<IntRange> fixedSamplesPartitionCreator = new ScopeTreeAssigner<IntRange>();
    114117      fixedSamplesPartitionCreator.LeftSideParameter.ActualName = FixedSamplesPartitionParameterName;
     
    121124      RegisterParameterEvents();
    122125      RecalculateFixedSamplesPartitions();
     126    }
     127
     128    private void RegisterParameterEvents() {
     129      if (Problem != null) Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset;
     130      NumberOfIslandsParameter.ValueChanged += NumberOfIslandsParameter_ValueChanged;
     131      NumberOfIslandsParameter.Value.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions();
     132      FixedSamplesParameter.Value.ValueChanged += (o, e) => RecalculateFixedSamplesPartitions();
     133      Analyzer.Operators.PropertyChanged += (o, e) => ParameterizeAnalyzers();
    123134    }
    124135
     
    150161    }
    151162
    152     private void RegisterParameterEvents() {
    153       NumberOfIslandsParameter.ValueChanged += NumberOfIslandsParameter_ValueChanged;
    154       NumberOfIslandsParameter.Value.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions();
    155       FixedSamplesParameter.Value.ValueChanged += (o, e) => RecalculateFixedSamplesPartitions();
     163   
     164    private void ParameterizeAnalyzers() {
     165      foreach (var analyzer in Analyzer.Operators.OfType<ISymbolicDataAnalysisAnalyzer>()) {
     166        IParameter evaluatorParameter;
     167        if (analyzer.Parameters.TryGetValue("Evaluator", out evaluatorParameter)) {
     168          ILookupParameter param = evaluatorParameter as ILookupParameter;
     169          if (evaluatorParameter != null) param.ActualName = ProblemEvaluatorParameterName;
     170        }
     171      }
    156172    }
    157173
     
    162178
    163179    protected override void Problem_Reset(object sender, EventArgs e) {
     180      FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
     181      RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    164182      RecalculateFixedSamplesPartitions();
    165183      ParameterizeProblemEvaluator();
     
    168186
    169187    protected override void OnProblemChanged() {
    170       Problem.FitnessCalculationPartition.ValueChanged += (o, e) => RecalculateFixedSamplesPartitions();
    171 
    172       ParameterizeProblemEvaluator();
     188      Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset;
     189      FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
     190      RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
     191
    173192      if (Problem is IRegressionProblem) {
    174193        var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IRegressionProblemData>();
     
    184203        EvaluatorParameter.Value = null;
    185204
     205      ParameterizeProblemEvaluator();
    186206      ParameterizeStochasticOperatorForIsland(EvaluatorParameter.Value);
    187207
Note: See TracChangeset for help on using the changeset viewer.