Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/11 02:22:45 (14 years ago)
Author:
mkommend
Message:

#1418:

  • Worked on IntRange and DoubleRange
  • Updated evaluators, analyzers, problems and problem data to use IntRanges
  • Removed properties to access the value of LookupParameter
  • Corrected files.txt
Location:
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationAnalyzer.cs

    r5747 r5759  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    23 using System.Linq;
    2422using HeuristicLab.Common;
    2523using HeuristicLab.Core;
    2624using HeuristicLab.Data;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    2925using HeuristicLab.Parameters;
    3026using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Optimization;
    3227
    3328namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    4338    private const string EvaluatorParameterName = "Evaluator";
    4439    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
    45     private const string ValidationSamplesStartParameterName = "ValidationSamplesStart";
    46     private const string ValidationSamplesEndParameterName = "ValidationSamplesEnd";
     40    private const string ValidationPartitionParameterName = "ValidationPartition";
     41    private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples";
    4742
    4843    #region parameter properties
     
    5651      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
    5752    }
    58     public IValueLookupParameter<IntValue> ValidationSamplesStartParameter {
    59       get { return (IValueLookupParameter<IntValue>)Parameters[ValidationSamplesStartParameterName]; }
     53    public IValueLookupParameter<IntRange> ValidationPartitionParameter {
     54      get { return (IValueLookupParameter<IntRange>)Parameters[ValidationPartitionParameterName]; }
    6055    }
    61     public IValueLookupParameter<IntValue> ValidationSamplesEndParameter {
    62       get { return (IValueLookupParameter<IntValue>)Parameters[ValidationSamplesEndParameterName]; }
     56    public IValueLookupParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter {
     57      get { return (IValueLookupParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; }
    6358    }
    64     #endregion
    65 
    66     #region properties
    67     public U ProblemData { get { return ProblemDataParameter.ActualValue; } }
    68     public T Evaluator { get { return EvaluatorParameter.ActualValue; } }
    69     public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter { get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; } }
    70     public IntValue ValidationSamplesStart { get { return ValidationSamplesStartParameter.ActualValue; } }
    71     public IntValue ValidationSamplesEnd { get { return ValidationSamplesEndParameter.ActualValue; } }
    7259    #endregion
    7360
     
    8269      Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition."));
    8370      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees."));
    84       Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesStartParameterName, "The start index of the validation partition."));
    85       Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesEndParameterName, "The end index of the validation partition."));
     71      Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "Thes validation partition."));
     72      Parameters.Add(new ValueLookupParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation between the start and end index."));
    8673    }
    8774  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs

    r5747 r5759  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    2929using HeuristicLab.Optimization;
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    32 using System;
     32using HeuristicLab.Random;
    3333
    3434namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    7575
    7676    public override IOperation Apply() {
     77      int start = ValidationPartitionParameter.ActualValue.Start;
     78      int end = ValidationPartitionParameter.ActualValue.End;
     79      int count = (int)((end - start) * RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value);
     80      if (count <= 0) return base.Apply();
     81
    7782      var results = ResultCollection;
    7883      // create empty parameter and result values
     
    9499      bool[] maximization = Maximization.ToArray();
    95100      List<double[]> newNonDominatedQualities = new List<double[]>();
    96       var evaluator = Evaluator;
    97       int start = ValidationSamplesStart.Value;
    98       int end = ValidationSamplesEnd.Value;
    99       IEnumerable<int> rows = Enumerable.Range(start, end - start);
     101      var evaluator = EvaluatorParameter.ActualValue;
     102      IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(start, end, count);
    100103      IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator);
    101104      for (int i = 0; i < tree.Length; i++) {
    102         qualities.Add(evaluator.Evaluate(childContext, tree[i], ProblemData, rows)); // qualities[i] = ...
     105        qualities.Add(evaluator.Evaluate(childContext, tree[i], ProblemDataParameter.ActualValue, rows)); // qualities[i] = ...
    103106        if (IsNonDominated(qualities[i], trainingBestQualities, maximization) &&
    104107          IsNonDominated(qualities[i], qualities, maximization)) {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs

    r5747 r5759  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    23 using System.Linq;
    2422using HeuristicLab.Common;
    2523using HeuristicLab.Core;
    2624using HeuristicLab.Data;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    2925using HeuristicLab.Parameters;
    3026using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Optimization;
    3227
    3328namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    4338    private const string EvaluatorParameterName = "Evaluator";
    4439    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
    45     private const string ValidationSamplesStartParameterName = "ValidationSamplesStart";
    46     private const string ValidationSamplesEndParameterName = "ValidationSamplesEnd";
     40    private const string ValidationPartitionParameterName = "ValidationPartition";
     41    private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples";
    4742
    4843    #region parameter properties
     
    5651      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
    5752    }
    58     public IValueLookupParameter<IntValue> ValidationSamplesStartParameter {
    59       get { return (IValueLookupParameter<IntValue>)Parameters[ValidationSamplesStartParameterName]; }
     53    public IValueLookupParameter<IntRange> ValidationPartitionParameter {
     54      get { return (IValueLookupParameter<IntRange>)Parameters[ValidationPartitionParameterName]; }
    6055    }
    61     public IValueLookupParameter<IntValue> ValidationSamplesEndParameter {
    62       get { return (IValueLookupParameter<IntValue>)Parameters[ValidationSamplesEndParameterName]; }
     56    public IValueLookupParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter {
     57      get { return (IValueLookupParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; }
    6358    }
    64     #endregion
    65 
    66     #region properties
    67     public U ProblemData { get { return ProblemDataParameter.ActualValue; } }
    68     public T Evaluator { get { return EvaluatorParameter.ActualValue; } }
    69     public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter { get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; } }
    70     public IntValue ValidationSamplesStart { get { return ValidationSamplesStartParameter.ActualValue; } }
    71     public IntValue ValidationSamplesEnd { get { return ValidationSamplesEndParameter.ActualValue; } }
    7259    #endregion
    7360
     
    8269      Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition."));
    8370      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees."));
    84       Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesStartParameterName, "The start index of the validation partition."));
    85       Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesEndParameterName, "The end index of the validation partition."));
     71      Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "Thes validation partition."));
     72      Parameters.Add(new ValueLookupParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation between the start and end index."));
    8673    }
    8774  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs

    r5747 r5759  
    2626using HeuristicLab.Data;
    2727using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HeuristicLab.Operators;
    2928using HeuristicLab.Optimization;
    3029using HeuristicLab.Parameters;
    3130using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Random;
    3232
    3333namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    7878      ISymbolicExpressionTree[] tree = SymbolicExpressionTrees.ToArray();
    7979      double[] quality = new double[tree.Length];
    80       var evaluator = Evaluator;
    81       int start = ValidationSamplesStart.Value;
    82       int end = ValidationSamplesEnd.Value;
    83       IEnumerable<int> rows = Enumerable.Range(start, end - start);
     80      var evaluator = EvaluatorParameter.ActualValue;
     81      int start = ValidationPartitionParameter.ActualValue.Start;
     82      int end = ValidationPartitionParameter.ActualValue.End;
     83      int count = (int)((end - start) * RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value);
     84      if (count <= 0) return base.Apply();
     85
     86      IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(start, end, count);
    8487      IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator);
    8588      for (int i = 0; i < tree.Length; i++) {
    86         quality[i] = evaluator.Evaluate(childContext, tree[i], ProblemData, rows);
     89        quality[i] = evaluator.Evaluate(childContext, tree[i], ProblemDataParameter.ActualValue, rows);
    8790        if (IsBetter(quality[i], bestQuality, Maximization.Value)) {
    8891          bestQuality = quality[i];
Note: See TracChangeset for help on using the changeset viewer.