Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/21/12 10:30:41 (13 years ago)
Author:
mkommend
Message:

#1837: Added view for sliding window GP and updated analyzer.

Location:
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/GenerationalSlidingWindowAnalyzer.cs

    r7845 r7850  
    7272      Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, ""));
    7373      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, ""));
    74       Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalParameterName, "", new IntValue(0)));
    75       Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalStartParameterName, "", new IntValue(10)));
     74      Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalParameterName, "", new IntValue(5)));
     75      Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalStartParameterName, "", new IntValue(0)));
     76
     77      GenerationsIntervalStartParameter.Hidden = true;
    7678    }
    7779
     
    8082      var start = GenerationsIntervalStart.Value;
    8183      var step = GenerationsInterval.Value;
     84      if (iteration == 0) return false;
    8285      if (iteration < start) return false;
    83 
    8486      if ((iteration - start) % step == 0) return true;
    8587
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowAnalyzer.cs

    r7845 r7850  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    3536    private const string ResultCollectionParameterName = "Results";
    3637    private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
    37     private const string SlidingWindowParameterName = "Sliding Window";
    3838    private const string SlidingWindowSizeParameterName = "Sliding Window Size";
    3939    private const string SlidingWindowStepWidthParameterName = "Sliding Window Step Width";
     
    5252    }
    5353
    54     public IValueLookupParameter<IntRange> SlidingWindowParameter {
    55       get { return (IValueLookupParameter<IntRange>)Parameters[SlidingWindowParameterName]; }
    56     }
    5754    public IFixedValueParameter<IntValue> SlidingWindowSizeParameter {
    5855      get { return (IFixedValueParameter<IntValue>)Parameters[SlidingWindowSizeParameterName]; }
     
    6562    #region properties
    6663    public bool EnabledByDefault { get { return false; } }
    67     public IntRange SlidingWindow { get { return SlidingWindowParameter.Value; } }
    6864    public IntValue SlidingWindowSize { get { return SlidingWindowSizeParameter.Value; } }
    6965    public IntValue SlidingWindowStepWidth { get { return SlidingWindowStepWidthParameter.Value; } }
     
    7773
    7874    protected SlidingWindowAnalyzer() {
     75      Parameters.Add(new LookupParameter<ResultCollection>(ResultCollectionParameterName, "The result collection to store the analysis results."));
    7976      Parameters.Add(new ValueLookupParameter<T>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
    8077      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, ""));
    81       Parameters.Add(new ValueLookupParameter<IntRange>(SlidingWindowParameterName, ""));
    8278      Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowSizeParameterName, "", new IntValue(1)));
    8379      Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowStepWidthParameterName, "", new IntValue(1)));
     
    8581
    8682    public override IOperation Apply() {
    87       if (!ExecutionContext.Scope.Variables.ContainsKey(FitnessCalculationPartitionParameter.ActualName))
    88         ExecutionContext.Scope.Variables.Add(new Core.Variable(FitnessCalculationPartitionParameter.ActualName, (IntRange)SlidingWindow.Clone()));
    89 
    9083      if (CheckForUpdate()) {
    9184        var fitnessPartition = FitnessCalculationPartitionParameter.ActualValue;
     85        if (fitnessPartition.End - fitnessPartition.Start == SlidingWindowSize.Value)
     86          fitnessPartition.Start += SlidingWindowStepWidth.Value;
    9287
    9388        fitnessPartition.End += SlidingWindowStepWidth.Value;
    94         if (fitnessPartition.End - fitnessPartition.Start > SlidingWindowStepWidth.Value)
     89        if (fitnessPartition.End - fitnessPartition.Start > SlidingWindowSize.Value)
    9590          fitnessPartition.End = fitnessPartition.Start + SlidingWindowSize.Value;
    96 
    97         if (fitnessPartition.End - fitnessPartition.Start == SlidingWindowSize.Value) {
    98           fitnessPartition.Start += SlidingWindowStepWidth.Value;
    99         }
    10091      }
    10192
     
    10495      SlidingWindowData slidingWindowData;
    10596      if (!results.ContainsKey(SlidingWindowDataResultName)) {
    106         slidingWindowData = new SlidingWindowData(FitnessCalculationPartitionParameter.ActualValue, new double[10]);
     97        string targetVariable;
     98        var classificationProblemData = ProblemDataParameter.ActualValue as IClassificationProblemData;
     99        var regressionProblemData = ProblemDataParameter.ActualValue as IRegressionProblemData;
     100        if (classificationProblemData != null) targetVariable = classificationProblemData.TargetVariable;
     101        else if (regressionProblemData != null) targetVariable = regressionProblemData.TargetVariable;
     102        else throw new NotSupportedException();
     103
     104        var targetData = ProblemDataParameter.ActualValue.Dataset.GetDoubleValues(targetVariable);
     105        slidingWindowData = new SlidingWindowData(FitnessCalculationPartitionParameter.ActualValue, targetData);
    107106        results.Add(new Result(SlidingWindowDataResultName, slidingWindowData));
    108       } else slidingWindowData = (SlidingWindowData)results[SlidingWindowDataResultName];
     107      } else slidingWindowData = (SlidingWindowData)results[SlidingWindowDataResultName].Value;
    109108
    110109      slidingWindowData.SlidingWindowPosition.Start = FitnessCalculationPartitionParameter.ActualValue.Start;
Note: See TracChangeset for help on using the changeset viewer.