Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7850


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
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r7845 r7850  
    5050    <DebugType>pdbonly</DebugType>
    5151    <Optimize>true</Optimize>
    52     <OutputPath>$(SolutionDir)\bin\</OutputPath>
     52    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    5353    <DefineConstants>TRACE</DefineConstants>
    5454    <ErrorReport>prompt</ErrorReport>
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SlidingWindowDataView.Designer.cs

    r7845 r7850  
    2626    /// </summary>
    2727    private void InitializeComponent() {
     28      System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    2829      this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
    2930      ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
     
    3233      // chart
    3334      //
     35      chartArea1.Name = "ChartArea1";
     36      this.chart.ChartAreas.Add(chartArea1);
    3437      this.chart.Dock = System.Windows.Forms.DockStyle.Fill;
    3538      this.chart.Location = new System.Drawing.Point(0, 0);
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SlidingWindowDataView.cs

    r7845 r7850  
    5151
    5252      StripLine stripLine = new StripLine();
    53       stripLine.BackColor = Color.Yellow;
     53      stripLine.BackColor = Color.Gold;
    5454      stripLine.Font = new Font("Times New Roman", 12, FontStyle.Bold);
    5555      stripLine.Text = "Sliding Window";
     
    7272
    7373    private void SlidingWindowPosition_ValueChanged(object sender, System.EventArgs e) {
    74       UpdateStripLine();
     74      if (InvokeRequired) Invoke((Action<object, EventArgs>)SlidingWindowPosition_ValueChanged, sender, e);
     75      else UpdateStripLine();
    7576    }
    7677
     
    8182      chart.Series.Add(TARGETVARIABLE_SERIES_NAME);
    8283      chart.Series[TARGETVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    83       chart.Series[TARGETVARIABLE_SERIES_NAME].Points.AddY(Content.TargetValues);
     84      chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindY(Content.TargetValues.ToArray());
    8485
    8586      UpdateStripLine();
     87      UpdateCursorInterval();
    8688    }
    8789
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r7845 r7850  
    9595    <Reference Include="ALGLIB-3.5.0">
    9696      <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.5.0.dll</HintPath>
     97      <Private>False</Private>
    9798    </Reference>
    9899    <Reference Include="HeuristicLab.Analysis-3.3">
     
    135136      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
    136137    </Reference>
     138    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    137139    <Reference Include="HeuristicLab.Random-3.3">
    138140      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
     
    153155  </ItemGroup>
    154156  <ItemGroup>
     157    <Compile Include="SlidingWindow\OffspringSelectionSlidingWindowAnalyzer.cs" />
    155158    <Compile Include="SlidingWindow\SlidingWindowData.cs" />
    156159    <Compile Include="SlidingWindow\GenerationalSlidingWindowAnalyzer.cs" />
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame

    r7696 r7850  
    4141  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    4242  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
     43  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    4344  [PluginDependency("HeuristicLab.Random", "3.3")]
    4445  public class HeuristicLabProblemsDataAnalysisSymbolicPlugin : PluginBase {
  • 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;
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r7726 r7850  
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3333using HeuristicLab.PluginInfrastructure;
     34using HeuristicLab.Problems.Instances;
    3435
    3536namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3637  [StorableClass]
    37   public abstract class SymbolicDataAnalysisProblem<T, U, V> : HeuristicOptimizationProblem<U, V>, IDataAnalysisProblem<T>, ISymbolicDataAnalysisProblem, IStorableContent
     38  public abstract class SymbolicDataAnalysisProblem<T, U, V> : HeuristicOptimizationProblem<U, V>, IDataAnalysisProblem<T>, ISymbolicDataAnalysisProblem, IStorableContent,
     39    IProblemInstanceConsumer<T>, IProblemInstanceExporter<T>
    3840    where T : class, IDataAnalysisProblemData
    3941    where U : class, ISymbolicDataAnalysisEvaluator<T>
     
    204206      Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
    205207      Operators.Add(new SymbolicExpressionTreeLengthAnalyzer());
     208      Operators.Add(new GenerationalSlidingWindowAnalyzer<T>());
    206209      ParameterizeOperators();
    207210    }
     
    318321        op.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
    319322      }
    320     }
    321 
    322     public abstract void ImportProblemDataFromFile(string fileName);
     323
     324      foreach (var op in operators.OfType<SlidingWindowAnalyzer<T>>()) {
     325        op.FitnessCalculationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
     326        op.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
     327
     328        var start = ProblemData.TrainingPartition.Start;
     329        var end = ProblemData.TrainingPartition.End;
     330        var size = (end - start) / 5;
     331        op.SlidingWindowSize.Value = size;
     332        op.SlidingWindowStepWidth.Value = size / 2;
     333      }
     334    }
     335
     336    #region Import & Export
     337    public void Load(T data) {
     338      Name = data.Name;
     339      Description = data.Description;
     340      ProblemData = data;
     341      OnReset();
     342    }
     343
     344    public T Export() {
     345      return ProblemData;
     346    }
     347    #endregion
    323348  }
    324349}
Note: See TracChangeset for help on using the changeset viewer.