Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10156 for branches


Ignore:
Timestamp:
11/26/13 15:32:09 (11 years ago)
Author:
mkommend
Message:

#1997: Removed generic type parameter from SymbolicDataAnylsisIslandGAEvaluator and added wiring code for the reevaluation of immigrants.

Location:
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3
Files:
3 edited

Legend:

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

    r10152 r10156  
    3434namespace HeuristicLab.Algorithms.DataAnalysis.Symbolic {
    3535  [StorableClass]
    36   public sealed class SymbolicDataAnalysisIslandGAEvaluator<T> : SingleSuccessorOperator, IStochasticOperator, ISymbolicDataAnalysisIslandGAEvaluator
    37     where T : class,IDataAnalysisProblemData {
     36  public sealed class SymbolicDataAnalysisIslandGAEvaluator : SingleSuccessorOperator, IStochasticOperator, ISymbolicDataAnalysisIslandGAEvaluator {
    3837    private const string RandomParameterName = "Random";
    3938    private const string ProblemDataParameterName = "ProblemData";
     
    4847      get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; }
    4948    }
    50     public ILookupParameter<T> ProblemDataParameter {
    51       get { return (ILookupParameter<T>)Parameters[ProblemDataParameterName]; }
     49    public ILookupParameter<IDataAnalysisProblemData> ProblemDataParameter {
     50      get { return (ILookupParameter<IDataAnalysisProblemData>)Parameters[ProblemDataParameterName]; }
    5251    }
    53     public ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<T>> EvaluatorParameter {
    54       get { return (ILookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<T>>)Parameters[EvaluatorParameterName]; }
     52    public ILookupParameter<IOperator> EvaluatorParameter {
     53      get { return (ILookupParameter<IOperator>)Parameters[EvaluatorParameterName]; }
    5554    }
    5655    public ILookupParameter<DoubleValue> QualityParameter {
     
    6867    #endregion
    6968
    70 
    7169    [StorableConstructor]
    7270    private SymbolicDataAnalysisIslandGAEvaluator(bool deserializing) : base(deserializing) { }
    73     private SymbolicDataAnalysisIslandGAEvaluator(SymbolicDataAnalysisIslandGAEvaluator<T> original, Cloner cloner)
     71    private SymbolicDataAnalysisIslandGAEvaluator(SymbolicDataAnalysisIslandGAEvaluator original, Cloner cloner)
    7472      : base(original, cloner) {
    7573    }
    7674    public override IDeepCloneable Clone(Cloner cloner) {
    77       return new SymbolicDataAnalysisIslandGAEvaluator<T>(this, cloner);
     75      return new SymbolicDataAnalysisIslandGAEvaluator(this, cloner);
    7876    }
    7977
     
    8179      : base() {
    8280      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator to use."));
    83       Parameters.Add(new LookupParameter<T>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
    84       Parameters.Add(new LookupParameter<ISymbolicDataAnalysisSingleObjectiveEvaluator<T>>(EvaluatorParameterName, "The evaluator provided by the symbolic data analysis  problem."));
     81      Parameters.Add(new LookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
     82      Parameters.Add(new LookupParameter<IOperator>(EvaluatorParameterName, "The evaluator provided by the symbolic data analysis  problem."));
    8583      Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName, "The quality which is calculated by the encapsulated evaluator."));
    8684      Parameters.Add(new ValueLookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness"));
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs

    r10142 r10156  
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    32 using HeuristicLab.Problems.DataAnalysis;
    3332using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3433using HeuristicLab.Random;
     
    128127      NumberOfIslandsParameter.ValueChanged += NumberOfIslandsParameter_ValueChanged;
    129128      NumberOfIslandsParameter.Value.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions();
    130       FixedSamplesParameter.Value.ValueChanged += (o, e) => RecalculateFixedSamplesPartitions();
     129      FixedSamplesParameter.Value.ValueChanged += (o, e) => {
     130        RecalculateFixedSamplesPartitions();
     131        ReevaluateImmigrants = FixedSamples >= Problem.FitnessCalculationPartition.Size;
     132      };
    131133      RandomSamplesParameter.Value.ValueChanged += (o, e) => { ReevaluteElites = RandomSamples != 0; };
    132134      Analyzer.Operators.PropertyChanged += (o, e) => ParameterizeAnalyzers();
     135      EvaluatorParameter.ValueChanged += (o, e) => ParameterizeEvaluator();
    133136    }
    134137
     
    155158    }
    156159
     160    private void ParameterizeEvaluator() {
     161      var evaluator = EvaluatorParameter.Value;
     162      var islandGAEvaluator = evaluator as SymbolicDataAnalysisIslandGAEvaluator;
     163      if (islandGAEvaluator != null) {
     164        islandGAEvaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
     165      }
     166    }
     167
    157168    private void NumberOfIslandsParameter_ValueChanged(object sender, EventArgs e) {
    158169      NumberOfIslands.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions();
     
    162173    protected override void Problem_Reset(object sender, EventArgs e) {
    163174      FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    164       RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    165       RecalculateFixedSamplesPartitions();
    166175      base.Problem_Reset(sender, e);
    167176    }
     
    170179      Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset;
    171180      FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    172       RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    173 
    174       if (Problem is IRegressionProblem) {
    175         var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IRegressionProblemData>();
    176         evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
    177         EvaluatorParameter.Value = evaluator;
    178       } else if (Problem is IClassificationProblem) {
    179         var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IClassificationProblemData>();
    180         evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
    181         EvaluatorParameter.Value = evaluator;
    182       } else
     181
     182      if (Problem != null && EvaluatorParameter.Value == null) {
     183        EvaluatorParameter.Value = new SymbolicDataAnalysisIslandGAEvaluator();
     184      } else if (Problem == null)
    183185        EvaluatorParameter.Value = null;
    184186
    185       ParameterizeStochasticOperatorForIsland(EvaluatorParameter.Value);
    186 
     187      ParameterizeStochasticOperator(EvaluatorParameter.Value);
    187188      RecalculateFixedSamplesPartitions();
    188189      base.OnProblemChanged();
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandOffspringSelectionGeneticAlgorithm.cs

    r10152 r10156  
    3131using HeuristicLab.Parameters;
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    33 using HeuristicLab.Problems.DataAnalysis;
    3433using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3534
     
    128127      NumberOfIslandsParameter.ValueChanged += NumberOfIslandsParameter_ValueChanged;
    129128      NumberOfIslandsParameter.Value.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions();
    130       FixedSamplesParameter.Value.ValueChanged += (o, e) => RecalculateFixedSamplesPartitions();
     129      FixedSamplesParameter.Value.ValueChanged += (o, e) => {
     130        RecalculateFixedSamplesPartitions();
     131        ReevaluateImmigrants = FixedSamples >= Problem.FitnessCalculationPartition.Size;
     132      };
    131133      RandomSamplesParameter.Value.ValueChanged += (o, e) => { ReevaluteElites = RandomSamples != 0; };
    132134      Analyzer.Operators.PropertyChanged += (o, e) => ParameterizeAnalyzers();
     135      EvaluatorParameter.ValueChanged += (o, e) => ParameterizeEvaluator();
    133136    }
    134137
     
    155158    }
    156159
     160    private void ParameterizeEvaluator() {
     161      var evaluator = EvaluatorParameter.Value;
     162      var islandGAEvaluator = evaluator as SymbolicDataAnalysisIslandGAEvaluator;
     163      if (islandGAEvaluator != null) {
     164        islandGAEvaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
     165      }
     166    }
     167
    157168    private void NumberOfIslandsParameter_ValueChanged(object sender, EventArgs e) {
    158169      NumberOfIslands.ValueChanged += (o, ev) => RecalculateFixedSamplesPartitions();
     
    162173    protected override void Problem_Reset(object sender, EventArgs e) {
    163174      FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    164       RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    165       RecalculateFixedSamplesPartitions();
    166175      base.Problem_Reset(sender, e);
    167176    }
     
    170179      Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset;
    171180      FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    172       RandomSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    173 
    174       if (Problem is IRegressionProblem) {
    175         var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IRegressionProblemData>();
    176         evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
    177         EvaluatorParameter.Value = evaluator;
    178       } else if (Problem is IClassificationProblem) {
    179         var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IClassificationProblemData>();
    180         evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
    181         EvaluatorParameter.Value = evaluator;
    182       } else
     181
     182      if (Problem != null && EvaluatorParameter.Value == null) {
     183        EvaluatorParameter.Value = new SymbolicDataAnalysisIslandGAEvaluator();
     184      } else if (Problem == null)
    183185        EvaluatorParameter.Value = null;
    184186
Note: See TracChangeset for help on using the changeset viewer.