Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9182


Ignore:
Timestamp:
01/23/13 10:18:22 (12 years ago)
Author:
mkommend
Message:

#1997: Added reevaluation of elits to symbolic data analysis island ga and changed evaluator to combine the fixed and random samples.

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/HeuristicLab.Algorithms.DataAnalysis.Symbolic.csproj

    r9077 r9182  
    9999      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
    100100    </Reference>
     101    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     102      <SpecificVersion>False</SpecificVersion>
     103      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath>
     104    </Reference>
    101105    <Reference Include="System" />
    102106    <Reference Include="System.Core" />
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGAEvaluator.cs

    r9077 r9182  
    4444    private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
    4545    private const string FixedSamplesPartitionParameterName = "FixedSamplesPartition";
    46     private const string FixedSamplesParameterName = "FixedSamples";
    47     private const string FixedSamplesFitnessWeightParameterName = "FixedSamplesFitnessWeight";
    4846    private const string RandomSamplesParameterName = "RandomSamples";
    49     private const string RandomSamplesFitnessWeightParameterName = "RandomSamplesFitnessWeight";
    5047
    5148    #region parameter properties
     
    7168      get { return (ILookupParameter<IntRange>)Parameters[FixedSamplesPartitionParameterName]; }
    7269    }
    73     public ILookupParameter<IntValue> FixedSamplesParameter {
    74       get { return (ILookupParameter<IntValue>)Parameters[FixedSamplesParameterName]; }
    75     }
    76     public IFixedValueParameter<DoubleValue> FixedSamplesFitnessWeightParameter {
    77       get { return (IFixedValueParameter<DoubleValue>)Parameters[FixedSamplesFitnessWeightParameterName]; }
    78     }
    7970    public ILookupParameter<IntValue> RandomSamplesParameter {
    8071      get { return (ILookupParameter<IntValue>)Parameters[RandomSamplesParameterName]; }
    8172    }
    82     public IFixedValueParameter<DoubleValue> RandomSamplesFitnessWeightParameter {
    83       get { return (IFixedValueParameter<DoubleValue>)Parameters[RandomSamplesFitnessWeightParameterName]; }
    84     }
    8573    #endregion
    8674
    87     #region properties
    88     public double FixedSamplesFitnessWeight {
    89       get { return FixedSamplesFitnessWeightParameter.Value.Value; }
    90       set { FixedSamplesFitnessWeightParameter.Value.Value = value; }
    91     }
    92     public double RandomSamplesFitnessWeight {
    93       get { return RandomSamplesFitnessWeightParameter.Value.Value; }
    94       set { RandomSamplesFitnessWeightParameter.Value.Value = value; }
    95     }
    96     #endregion
    9775
    9876    [StorableConstructor]
     
    11492      Parameters.Add(new ValueLookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness"));
    11593      Parameters.Add(new LookupParameter<IntRange>(FixedSamplesPartitionParameterName, "The data partition which is used to calculate the fitness on the fixed samples."));
    116       Parameters.Add(new LookupParameter<IntValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island."));
    117       Parameters.Add(new FixedValueParameter<DoubleValue>(FixedSamplesFitnessWeightParameterName, "The weight of the fitness obtained on the fixed samples.", new DoubleValue(1)));
    11894      Parameters.Add(new LookupParameter<IntValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island."));
    119       Parameters.Add(new FixedValueParameter<DoubleValue>(RandomSamplesFitnessWeightParameterName, "The weight of the fitness obtained on the random samples.", new DoubleValue(1)));
    12095
    12196      EvaluatorParameter.Hidden = true;
     
    12499    public override IOperation Apply() {
    125100      var evaluator = EvaluatorParameter.ActualValue;
    126       //calculate fitness on fixed samples
    127       if (QualityParameter.ActualValue == null) {
    128         var operation = ExecutionContext.CreateOperation(evaluator, ExecutionContext.Scope);
    129         return new OperationCollection() { operation, ExecutionContext.CreateOperation(this) };
    130       }
    131       //calculate fitness on random samples;
     101      var tree = SymbolicExpressionTreeParameter.ActualValue;
     102      var problemData = ProblemDataParameter.ActualValue;
     103
    132104      var samplesStart = FitnessCalculationPartitionParameter.ActualValue.Start;
    133105      var samplesEnd = FitnessCalculationPartitionParameter.ActualValue.End;
     
    137109      var maxRandomSamples = samplesEnd - samplesStart - fixedSamplesEnd + fixedSamplesStart;
    138110
    139       var rows = Enumerable.Range(samplesStart, samplesEnd - samplesStart).Where(r => r < fixedSamplesStart || r >= fixedSamplesEnd);
    140       rows = rows.SampleRandomWithoutRepetition(RandomParameter.ActualValue, randomSamples, maxRandomSamples);
    141 
    142       var fixedSamplesFitness = QualityParameter.ActualValue.Value;
    143       var tree = SymbolicExpressionTreeParameter.ActualValue;
    144       var problemData = ProblemDataParameter.ActualValue;
     111      //create rows for evaluation
     112      var fixedRows = Enumerable.Range(fixedSamplesStart, fixedSamplesEnd - fixedSamplesStart);
     113      var randomRows = Enumerable.Range(samplesStart, samplesEnd - samplesStart).Where(r => r < fixedSamplesStart || r >= fixedSamplesEnd);
     114      randomRows = randomRows.SampleRandomWithoutRepetition(RandomParameter.ActualValue, randomSamples, maxRandomSamples);
     115      var rows = fixedRows.Concat(randomRows);
    145116
    146117      var executionContext = new ExecutionContext(ExecutionContext, evaluator, ExecutionContext.Scope);
    147       var randomSamplesFitness = evaluator.Evaluate(executionContext, tree, problemData, rows);
    148       QualityParameter.ActualValue.Value = fixedSamplesFitness * FixedSamplesFitnessWeight + randomSamplesFitness * RandomSamplesFitnessWeight;
     118      var fitness = evaluator.Evaluate(executionContext, tree, problemData, rows);
     119      QualityParameter.ActualValue = new DoubleValue(fitness);
    149120      return base.Apply();
    150121    }
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs

    r9172 r9182  
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Data;
     29using HeuristicLab.Operators;
    2930using HeuristicLab.Optimization;
    3031using HeuristicLab.Parameters;
     
    3334using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3435using HeuristicLab.Random;
     36using HeuristicLab.Selection;
    3537
    3638namespace HeuristicLab.Algorithms.DataAnalysis.Symbolic {
    3739  [Item("Symbolic DataAnalysis Island Genetic Algorithm", "A symbolic data analysis island genetic algorithm.")]
    38   [Creatable("Algorithms")]
     40  [Creatable("Data Analysis")]
    3941  [StorableClass]
    4042  public sealed class SymbolicDataAnalysisIslandGeneticAlgorithm : IslandGeneticAlgorithm {
     
    122124      insertionPoint.Successor = fixedSamplesPartitionCreator;
    123125
     126      //necessary to reevaluate elites
     127      var evaluatorPlaceHolder = new Placeholder();
     128      evaluatorPlaceHolder.OperatorParameter.ActualName = "Evaluator";
     129
     130      UniformSubScopesProcessor subScopesProcessor = new UniformSubScopesProcessor();
     131      subScopesProcessor.Name = "Reevaluate elites";
     132      subScopesProcessor.Parallel.Value = true;
     133      subScopesProcessor.Operator = evaluatorPlaceHolder;
     134      OperatorGraph.Iterate().OfType<RightReducer>().First().Successor = subScopesProcessor;
     135
    124136      RegisterParameterEvents();
    125137      RecalculateFixedSamplesPartitions();
     
    161173    }
    162174
    163    
     175
    164176    private void ParameterizeAnalyzers() {
    165177      foreach (var analyzer in Analyzer.Operators.OfType<ISymbolicDataAnalysisAnalyzer>()) {
     
    192204      if (Problem is IRegressionProblem) {
    193205        var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IRegressionProblemData>();
    194         evaluator.FixedSamplesParameter.ActualName = FixedSamplesParameterName;
    195206        evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
    196207        EvaluatorParameter.Value = evaluator;
    197208      } else if (Problem is IClassificationProblem) {
    198209        var evaluator = new SymbolicDataAnalysisIslandGAEvaluator<IClassificationProblemData>();
    199         evaluator.FixedSamplesParameter.ActualName = FixedSamplesParameterName;
    200210        evaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
    201211        EvaluatorParameter.Value = evaluator;
Note: See TracChangeset for help on using the changeset viewer.