Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14538


Ignore:
Timestamp:
01/03/17 23:04:56 (7 years ago)
Author:
jzenisek
Message:

#2719 enhanced the optimizer's functionality

Location:
branches/HeuristicLab.DatastreamAnalysis
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/DatastreamAnalysisOptimizerView.Designer.cs

    r14536 r14538  
    4343      // startButton
    4444      //
    45       this.startButton.Location = new System.Drawing.Point(6, 636);
     45      this.startButton.Location = new System.Drawing.Point(9, 978);
     46      this.startButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
     47      this.startButton.Size = new System.Drawing.Size(36, 37);
    4648      this.toolTip.SetToolTip(this.startButton, "Start/Resume Optimizer");
    4749      //
    4850      // executionTimeTextBox
    4951      //
    50       this.executionTimeTextBox.Location = new System.Drawing.Point(936, 640);
     52      this.executionTimeTextBox.Location = new System.Drawing.Point(1404, 985);
     53      this.executionTimeTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
     54      this.executionTimeTextBox.Size = new System.Drawing.Size(204, 26);
    5155      //
    5256      // executionTimeLabel
    5357      //
    54       this.executionTimeLabel.Location = new System.Drawing.Point(847, 643);
     58      this.executionTimeLabel.Location = new System.Drawing.Point(1270, 989);
     59      this.executionTimeLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
    5560      //
    5661      // pauseButton
    5762      //
    58       this.pauseButton.Location = new System.Drawing.Point(36, 636);
     63      this.pauseButton.Location = new System.Drawing.Point(54, 978);
     64      this.pauseButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
     65      this.pauseButton.Size = new System.Drawing.Size(36, 37);
    5966      this.toolTip.SetToolTip(this.pauseButton, "Pause Optimizer");
    6067      //
    6168      // stopButton
    6269      //
    63       this.stopButton.Location = new System.Drawing.Point(66, 636);
     70      this.stopButton.Location = new System.Drawing.Point(99, 978);
     71      this.stopButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
     72      this.stopButton.Size = new System.Drawing.Size(36, 37);
    6473      this.toolTip.SetToolTip(this.stopButton, "Stop Optimizer");
    6574      //
    6675      // resetButton
    6776      //
    68       this.resetButton.Location = new System.Drawing.Point(96, 636);
     77      this.resetButton.Location = new System.Drawing.Point(144, 978);
     78      this.resetButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
     79      this.resetButton.Size = new System.Drawing.Size(36, 37);
    6980      this.toolTip.SetToolTip(this.resetButton, "Reset Optimizer");
    7081      //
     
    7384      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    7485      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    75       this.nameTextBox.Size = new System.Drawing.Size(1008, 20);
     86      this.nameTextBox.Location = new System.Drawing.Point(87, 0);
     87      this.nameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
     88      this.nameTextBox.Size = new System.Drawing.Size(1510, 26);
     89      //
     90      // nameLabel
     91      //
     92      this.nameLabel.Location = new System.Drawing.Point(4, 5);
     93      this.nameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
    7694      //
    7795      // infoLabel
    7896      //
    79       this.infoLabel.Location = new System.Drawing.Point(995, 3);
     97      this.infoLabel.Location = new System.Drawing.Point(1492, 5);
     98      this.infoLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
     99      this.infoLabel.Size = new System.Drawing.Size(24, 25);
    80100      //
    81101      // tabControl
    82102      //
    83103      this.tabControl.AllowDrop = true;
    84       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    85             | System.Windows.Forms.AnchorStyles.Left)
     104      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     105            | System.Windows.Forms.AnchorStyles.Left) 
    86106            | System.Windows.Forms.AnchorStyles.Right)));
    87107      this.tabControl.Controls.Add(this.ensemblesTab);
     
    89109      this.tabControl.Controls.Add(this.resultsTab);
    90110      this.tabControl.Controls.Add(this.runsTab);
    91       this.tabControl.Location = new System.Drawing.Point(3, 26);
     111      this.tabControl.Location = new System.Drawing.Point(4, 40);
     112      this.tabControl.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
    92113      this.tabControl.Name = "tabControl";
    93114      this.tabControl.SelectedIndex = 0;
    94       this.tabControl.Size = new System.Drawing.Size(1070, 604);
     115      this.tabControl.Size = new System.Drawing.Size(1605, 929);
    95116      this.tabControl.TabIndex = 0;
    96117      //
     
    99120      this.ensemblesTab.AllowDrop = true;
    100121      this.ensemblesTab.Controls.Add(this.ensemblesViewHost);
    101       this.ensemblesTab.Location = new System.Drawing.Point(4, 22);
     122      this.ensemblesTab.Location = new System.Drawing.Point(4, 29);
     123      this.ensemblesTab.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
    102124      this.ensemblesTab.Name = "ensemblesTab";
    103       this.ensemblesTab.Padding = new System.Windows.Forms.Padding(3);
    104       this.ensemblesTab.Size = new System.Drawing.Size(527, 259);
     125      this.ensemblesTab.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
     126      this.ensemblesTab.Size = new System.Drawing.Size(1597, 896);
    105127      this.ensemblesTab.TabIndex = 0;
    106128      this.ensemblesTab.Text = "Ensembles";
     
    118140      this.ensemblesViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    119141      this.ensemblesViewHost.Enabled = false;
    120       this.ensemblesViewHost.Location = new System.Drawing.Point(3, 3);
     142      this.ensemblesViewHost.Location = new System.Drawing.Point(4, 5);
     143      this.ensemblesViewHost.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
    121144      this.ensemblesViewHost.Name = "ensemblesViewHost";
    122145      this.ensemblesViewHost.ReadOnly = false;
    123       this.ensemblesViewHost.Size = new System.Drawing.Size(521, 253);
     146      this.ensemblesViewHost.Size = new System.Drawing.Size(1589, 886);
    124147      this.ensemblesViewHost.TabIndex = 0;
    125148      this.ensemblesViewHost.ViewsLabelVisible = true;
     
    130153      this.datastreamTab.AllowDrop = true;
    131154      this.datastreamTab.Controls.Add(this.datastreamViewHost);
    132       this.datastreamTab.Location = new System.Drawing.Point(4, 22);
     155      this.datastreamTab.Location = new System.Drawing.Point(4, 29);
     156      this.datastreamTab.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
    133157      this.datastreamTab.Name = "datastreamTab";
    134       this.datastreamTab.Padding = new System.Windows.Forms.Padding(3);
    135       this.datastreamTab.Size = new System.Drawing.Size(950, 554);
     158      this.datastreamTab.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
     159      this.datastreamTab.Size = new System.Drawing.Size(1597, 896);
    136160      this.datastreamTab.TabIndex = 1;
    137161      this.datastreamTab.Text = "Datastream";
     
    147171      this.datastreamViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    148172      this.datastreamViewHost.Enabled = false;
    149       this.datastreamViewHost.Location = new System.Drawing.Point(3, 3);
     173      this.datastreamViewHost.Location = new System.Drawing.Point(4, 5);
     174      this.datastreamViewHost.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
    150175      this.datastreamViewHost.Name = "datastreamViewHost";
    151176      this.datastreamViewHost.ReadOnly = false;
    152       this.datastreamViewHost.Size = new System.Drawing.Size(944, 548);
     177      this.datastreamViewHost.Size = new System.Drawing.Size(1589, 886);
    153178      this.datastreamViewHost.TabIndex = 0;
    154179      this.datastreamViewHost.ViewsLabelVisible = true;
     
    158183      //
    159184      this.resultsTab.Controls.Add(this.resultsView);
    160       this.resultsTab.Location = new System.Drawing.Point(4, 22);
     185      this.resultsTab.Location = new System.Drawing.Point(4, 29);
     186      this.resultsTab.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
     187      this.resultsTab.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
    161188      this.resultsTab.Name = "resultsTab";
    162       this.resultsTab.Size = new System.Drawing.Size(950, 554);
     189      this.resultsTab.Size = new System.Drawing.Size(1597, 896);
    163190      this.resultsTab.TabIndex = 3;
    164191      this.resultsTab.Text = "Results";
    165192      this.resultsTab.UseVisualStyleBackColor = true;
    166193      //
    167       // resultsViewHost
     194      // resultsView
    168195      //
    169196      this.resultsView.Caption = "View";
     
    171198      this.resultsView.Dock = System.Windows.Forms.DockStyle.Fill;
    172199      this.resultsView.Enabled = false;
    173       this.resultsView.Location = new System.Drawing.Point(0, 0);
    174       this.resultsView.Name = "resultsViewHost";
    175       this.resultsView.ReadOnly = false;
    176       this.resultsView.Size = new System.Drawing.Size(950, 554);
     200      this.resultsView.Location = new System.Drawing.Point(4, 5);
     201      this.resultsView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
     202      this.resultsView.Name = "resultsView";
     203      this.resultsView.ReadOnly = true;
     204      this.resultsView.ShowDetails = true;
     205      this.resultsView.Size = new System.Drawing.Size(1597, 896);
    177206      this.resultsView.TabIndex = 0;
    178       //
     207      // 
    179208      // runsTab
    180       //
    181       //this.runsTabPage.Controls.Add(this.storeAlgorithmInEachRunCheckBox);
     209      //
    182210      this.runsTab.Controls.Add(this.runsView);
    183       this.runsTab.Location = new System.Drawing.Point(4, 22);
    184       this.runsTab.Name = "runsTabPage";
    185       this.runsTab.Padding = new System.Windows.Forms.Padding(3);
    186       this.runsTab.Size = new System.Drawing.Size(950, 554);
     211      this.runsTab.Location = new System.Drawing.Point(4, 29);
     212      this.runsTab.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
     213      this.runsTab.Name = "runsTab";
     214      this.runsTab.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
     215      this.runsTab.Size = new System.Drawing.Size(1597, 896);
    187216      this.runsTab.TabIndex = 3;
    188217      this.runsTab.Text = "Runs";
    189218      this.runsTab.UseVisualStyleBackColor = true;
    190       //
     219      // 
    191220      // runsView
    192       //
    193       this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    194       | System.Windows.Forms.AnchorStyles.Left)
    195       | System.Windows.Forms.AnchorStyles.Right)));
     221      //
    196222      this.runsView.Caption = "RunCollection View";
    197223      this.runsView.Content = null;
    198       this.runsView.Location = new System.Drawing.Point(0, 0);
     224      this.runsView.Dock = System.Windows.Forms.DockStyle.Fill;
     225      this.runsView.Enabled = false;
     226      this.runsView.Location = new System.Drawing.Point(4, 5);
     227      this.runsView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
    199228      this.runsView.Name = "runsView";
    200229      this.runsView.ReadOnly = false;
    201       this.runsView.Size = new System.Drawing.Size(950, 554);
     230      this.runsView.Size = new System.Drawing.Size(1589, 886);
    202231      this.runsView.TabIndex = 0;
    203232      //
     
    205234      //
    206235      this.AllowDrop = true;
    207       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     236      this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
    208237      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    209238      this.Controls.Add(this.tabControl);
     239      this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
    210240      this.Name = "DatastreamAnalysisOptimizerView";
    211       this.Size = new System.Drawing.Size(1076, 663);
     241      this.Size = new System.Drawing.Size(1614, 1020);
    212242      this.Controls.SetChildIndex(this.tabControl, 0);
    213243      this.Controls.SetChildIndex(this.nameLabel, 0);
     
    225255      this.datastreamTab.ResumeLayout(false);
    226256      this.resultsTab.ResumeLayout(false);
     257      this.runsTab.ResumeLayout(false);
    227258      this.ResumeLayout(false);
    228259      this.PerformLayout();
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/DatastreamAnalysisOptimizerView.cs

    r14536 r14538  
    7575        runsView.Content = null;
    7676      } else {
     77        ensemblesViewHost.ViewType = null;
    7778        ensemblesViewHost.Content = Content.Ensembles;
     79        datastreamViewHost.ViewType = null;
    7880        datastreamViewHost.Content = Content.Datastream;
    7981        resultsView.Content = Content.Results.AsReadOnly();
     
    8486    protected override void SetEnabledStateOfControls() {
    8587      base.SetEnabledStateOfControls();
     88
    8689      resultsView.Enabled = Content != null;
    8790      runsView.Enabled = Content != null;
     
    118121    }
    119122
    120     #region
     123    #region content events
    121124    protected override void Content_Prepared(object sender, EventArgs e) {
    122125      if (InvokeRequired)
     
    132135        Invoke(new EventHandler(Content_EnsemblesChanged), sender, e);
    133136      else {
     137        ensemblesViewHost.ViewType = null;
    134138        ensemblesViewHost.Content = Content.Ensembles;
    135139      }
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/HeuristicLab.DatastreamAnalysis.Views.csproj

    r14536 r14538  
    121121  </ItemGroup>
    122122  <ItemGroup>
     123    <EmbeddedResource Include="DatastreamAnalysisOptimizerView.resx">
     124      <DependentUpon>DatastreamAnalysisOptimizerView.cs</DependentUpon>
     125    </EmbeddedResource>
    123126    <EmbeddedResource Include="RegressionEnsembleModelView.resx">
    124127      <DependentUpon>RegressionEnsembleModelView.cs</DependentUpon>
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/Plugin.cs

    r14536 r14538  
    2323
    2424namespace HeuristicLab.DatastreamAnalysis.Views {
    25   [Plugin("HeuristicLab.DatastreamAnalysis.Views", "3.4.14.14491")]
     25  [Plugin("HeuristicLab.DatastreamAnalysis.Views", "3.4.14.14536")]
    2626  [PluginFile("HeuristicLab.DatastreamAnalysis.Views-3.4.dll", PluginFileType.Assembly)]
    2727  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/Properties/AssemblyInfo.cs

    r14536 r14538  
    5454// [assembly: AssemblyVersion("1.0.*")]
    5555[assembly: AssemblyVersion("3.4.0.0")]
    56 [assembly: AssemblyFileVersion("3.4.14.14491")]
     56[assembly: AssemblyFileVersion("3.4.14.14536")]
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Datastream.cs

    r14536 r14538  
    4343    protected const string SlidingWindowStepWidthParameterName = "SlidingWindowStepWidth";
    4444    protected const string SlidingWindowMovementIntervalParameterName = "SlidingWindowMovementInterval";
     45    protected const string FitnessPartitionParameterName = "FitnessPartition";
    4546
    4647    #region parameter properites
     
    5051    }
    5152
    52     public IFixedValueParameter<IntRange> InitialSlidingWindowParameter {
    53       get { return (IFixedValueParameter<IntRange>) Parameters[InitialSlidingWindowParameterName]; }
    54     }
    55 
    56     public IFixedValueParameter<IntValue> SlidingWindowSizeParameter {
    57       get { return (IFixedValueParameter<IntValue>)Parameters[InitialSlidingWindowParameterName]; }
    58     }
    59 
    60     public IFixedValueParameter<IntValue> SlidingWindowStepWidthParameter {
    61       get { return (IFixedValueParameter<IntValue>)Parameters[SlidingWindowStepWidthParameterName]; }
    62     }
    63 
    64     public IFixedValueParameter<IntValue> SlidingWindowMovementIntervalParameter {
    65       get { return (IFixedValueParameter<IntValue>)Parameters[SlidingWindowMovementIntervalParameterName]; }
    66     }
    67 
     53    public IValueParameter<IntRange> InitialSlidingWindowParameter {
     54      get { return (IValueParameter<IntRange>) Parameters[InitialSlidingWindowParameterName]; }
     55    }
     56
     57    public IValueParameter<IntValue> SlidingWindowSizeParameter {
     58      get { return (IValueParameter<IntValue>) Parameters[SlidingWindowSizeParameterName]; }
     59    }
     60
     61    public IValueParameter<IntValue> SlidingWindowStepWidthParameter {
     62      get { return (IValueParameter<IntValue>) Parameters[SlidingWindowStepWidthParameterName]; }
     63    }
     64
     65    public IValueParameter<IntValue> SlidingWindowMovementIntervalParameter {
     66      get { return (IValueParameter<IntValue>) Parameters[SlidingWindowMovementIntervalParameterName]; }
     67    }
     68
     69    //public IValueParameter<IntRange> FitnessPartitionParameter {
     70    //  get { return (IValueParameter<IntRange>) Parameters[FitnessPartitionParameterName]; }
     71    //}
    6872
    6973    #endregion
     
    7579      set {
    7680        if(value == null) throw new ArgumentNullException("problemData", "The provided value for the problemData is null.");
    77         if (value == ProblemData) return;
    7881        ProblemDataParameter.Value = value;
    79       }
    80     }
     82        //OnProblemDataChanged();
     83      }
     84    }
     85   
    8186
    8287    public IntRange InitialSlidingWindow {
    8388      get { return InitialSlidingWindowParameter.Value; }
     89      set { InitialSlidingWindowParameter.Value = value; }
    8490    }
    8591
    8692    public IntValue SlidingWindowSize {
    8793      get { return SlidingWindowSizeParameter.Value; }
     94      set { SlidingWindowSizeParameter.Value = value; }
    8895    }
    8996
    9097    public IntValue SlidingWindowStepWidth {
    9198      get { return SlidingWindowStepWidthParameter.Value; }
     99      set { SlidingWindowStepWidthParameter.Value = value; }
    92100    }
    93101
    94102    public IntValue SlidingWindowMovementInterval {
    95103      get { return SlidingWindowMovementIntervalParameter.Value; }
     104      set { SlidingWindowMovementIntervalParameter.Value = value; }
    96105    }
    97106
     
    101110
    102111    public IntRange FitnessPartition { get; set; }
     112
     113    public bool UpdateAvailable {
     114      get { return false; }
     115    }
    103116
    104117    public bool SlidingWindowMovementPossible {
    105118      get {
    106119        return ProblemData != null && ProblemData.Dataset != null &&
    107                FitnessPartition.End + SlidingWindowStepWidth.Value <= ProblemData.Dataset.Rows;
    108         // TODO: add external datastream, hub, etc to condition
     120               (
     121                (FitnessPartition.End + SlidingWindowStepWidth.Value <= ProblemData.Dataset.Rows) // shift end
     122                || (FitnessPartition.Size > SlidingWindowSize.Value && (FitnessPartition.Start + SlidingWindowStepWidth.Value) < FitnessPartition.End) // shift start
     123               );
    109124      }
    110125    }
     
    112127    public bool SlidingWindowEvaluationPossible {
    113128      get {
    114         return ProblemData != null && ProblemData.Dataset != null &&
    115               FitnessPartition.Size > 0;
     129        //return ProblemData != null && ProblemData.Dataset != null && ProblemData.Dataset.Rows > 0 && FitnessPartition.Size > 0;
     130        return FitnessPartition.Size > 0;
    116131      }
    117132    }
     
    120135      if (ProblemData?.Dataset == null || ProblemData.Dataset.Rows == 0) return false;
    121136      if (FitnessPartition.End + SlidingWindowStepWidth.Value > ProblemData.Dataset.Rows) return false;
    122      
    123       if (FitnessPartition.Size > SlidingWindowSize.Value) {
    124         FitnessPartition.Start += SlidingWindowStepWidth.Value;
    125       } else if (FitnessPartition.Size == SlidingWindowSize.Value) {
     137
     138      if (FitnessPartition.Size == SlidingWindowSize.Value) {
    126139        FitnessPartition.Start += SlidingWindowStepWidth.Value;
    127140        FitnessPartition.End += SlidingWindowStepWidth.Value;
    128       } else {
     141      } else { 
    129142        FitnessPartition.End += SlidingWindowStepWidth.Value;
    130       }   
     143        FitnessPartition.Start += FitnessPartition.End - SlidingWindowSize.Value;
     144      }
     145
     146      //if (FitnessPartition.Size > SlidingWindowSize.Value) {
     147      //  FitnessPartition.Start += SlidingWindowStepWidth.Value;
     148      //} else if (FitnessPartition.Size == SlidingWindowSize.Value) {
     149      //  FitnessPartition.Start += SlidingWindowStepWidth.Value;
     150      //  FitnessPartition.End += SlidingWindowStepWidth.Value;
     151      //} else {
     152      //  FitnessPartition.End += SlidingWindowStepWidth.Value;
     153      //  if (FitnessPartition.Size > SlidingWindowSize.Value) {
     154      //    FitnessPartition.Start = FitnessPartition.End - FitnessPartition.Size;
     155      //  }
     156      //}   
    131157      return true;
    132158    }
     
    141167    private void AfterDeserialization() {
    142168      RegisterParameterEvents();
     169      RecoverState();
    143170    }
    144171
    145172    protected Datastream(Datastream original, Cloner cloner) : base(original, cloner) {
    146173      RegisterParameterEvents();
     174      RecoverState();
    147175    }
    148176
     
    151179    }
    152180
    153     public Datastream() {
     181    public Datastream() : base() {
    154182      Parameters.Add(new ValueParameter<RegressionProblemData>(ProblemDataParameterName, "ProblemData for analysis with selected ensembles.", null));
    155       Parameters.Add(new FixedValueParameter<IntRange>(InitialSlidingWindowParameterName, "Initial sliding window boundaries", new IntRange(0, 1)));
    156       Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowSizeParameterName, "Sliding window size", new IntValue(1)));
     183      Parameters.Add(new FixedValueParameter<IntRange>(InitialSlidingWindowParameterName, "Initial sliding window boundaries", new IntRange(0, 5)));
     184      Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowSizeParameterName, "Sliding window size", new IntValue(5)));
    157185      Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowStepWidthParameterName, "Sliding window step width", new IntValue(1)));
    158       Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowMovementIntervalParameterName, "Sliding window movement interval (milliseconds)", new IntValue(1000)));
     186      Parameters.Add(new FixedValueParameter<IntValue>(SlidingWindowMovementIntervalParameterName, "Sliding window movement interval (milliseconds)", new IntValue(2000)));
     187      RegisterParameterEvents();
    159188      InitializeState();
    160189    }
    161190    #endregion
    162191
    163 
    164     public void InitializeState() {
     192    public void InitializeState(){
    165193      if (ProblemData == null || ProblemData.Dataset == null || ProblemData.Dataset.Rows == 0) {
    166194        FitnessPartition = new IntRange(0, 0);
     
    173201    }
    174202
     203    public void RecoverState() {
     204      if (ProblemData == null || ProblemData.Dataset == null || ProblemData.Dataset.Rows == 0) {
     205        FitnessPartition = new IntRange(0, 0);
     206      } else {
     207        if(FitnessPartition == null) FitnessPartition = (IntRange)InitialSlidingWindow.Clone();
     208        if (FitnessPartition.End > ProblemData.Dataset.Rows) {
     209          FitnessPartition.End = ProblemData.Dataset.Rows;
     210        }
     211      }
     212    }
     213
    175214    public event EventHandler ProblemDataChanged;
    176 
     215    public event EventHandler Reset;
     216    public event EventHandler SlidingWindowChanged;
     217
     218
     219    //protected virtual void OnProblemDataChanged() {
     220    //  EventHandler handler = ProblemDataChanged;
     221    //  if(handler != null) handler(this, EventArgs.Empty);
     222    //}
     223
     224    //protected virtual void OnReset() {
     225    //  EventHandler handler = Reset;
     226    //  if (handler != null) handler(this, EventArgs.Empty);
     227    //}
    177228
    178229    private void RegisterParameterEvents() {
    179230      ProblemDataParameter.ValueChanged += new EventHandler(ProblemData_ValueChanged);
     231      //SlidingWindowSizeParameter.ValueChanged += new EventHandler(SlidingWindow_Changed);
     232      InitialSlidingWindowParameter.ValueChanged += new EventHandler(SlidingWindow_Changed);
    180233    }
    181234
     
    183236      if (e == null) return;
    184237
     238      InitializeState();
    185239      DatastreamAnalysisUtil.RaiseEvent(this, ProblemDataChanged);
    186240    }
    187241
     242    private void SlidingWindow_Changed(object sender, EventArgs e) {
     243      InitializeState();
     244    }
     245
     246
     247    // TODO
     248    public IEnumerable<IParameterizedItem> ExecutionContextItems { get; }
    188249   
    189 
    190250  }
    191251}
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/DatastreamAnalysisOptimizer.cs

    r14536 r14538  
    2424using System;
    2525using System.Collections.Generic;
     26using System.ComponentModel;
    2627using System.Diagnostics;
    2728using System.Drawing;
     
    7677    private bool stopPending;
    7778    private DateTime lastUpdateTime;
     79    private bool prepared;
     80    private bool finished;
    7881
    7982    [Storable]
     
    106109        if (value == null || value == ensembles)
    107110          return;
    108 
     111        if(!(value is IRegressionEnsembleModel)) throw new ArgumentException("Invaid ensemble model type");
     112        DeregisterEnsembleEvents();
    109113        ensembles = value;
     114        RegisterEnsembleEvents();
     115        OnEnsemblesChanged();
     116        Prepare();
    110117      }
    111118    }
     
    121128        if (value == null || value == datastream)
    122129          return;
    123 
     130        if(!(value is IDatastream)) throw new ArgumentException("Invalid datastream type");
     131        DeregisterDatastreamEvents();
    124132        datastream = value;
     133        RegisterDatastreamEvents();
     134        OnDatastreamChanged();
     135        Prepare();
    125136      }
    126137    }
     
    128139    #endregion properties
    129140
    130     #region ResultsProperties
    131     private double ResultsBestQuality
    132     {
     141    #region results properties
     142    private int ResultsSlidingWindowMovements {
     143      get { return ((IntValue)Results["Sliding Window Movements"].Value).Value; }
     144      set { ((IntValue)Results["Sliding Window Movements"].Value).Value = value; }
     145    }
     146    private double ResultsBestQuality {
    133147      get { return ((DoubleValue)Results["Best Quality"].Value).Value; }
    134148      set { ((DoubleValue)Results["Best Quality"].Value).Value = value; }
    135149    }
    136     private DataTable ResultsQualities
    137     {
     150    private DataTable ResultsQualities {
    138151      get { return ((DataTable)Results["Qualities"].Value); }
    139152    }
     153
     154    private const string ResultsQualitiesR2 = "R²";
     155    private const string ResultsQualitiesPearson = "Pearson";
     156
     157    private DataTable ResultsTargets {
     158      get { return ((DataTable) Results["Targets"].Value); }
     159    }
     160
     161    private const string ResultsTargetsReal = "Real";
     162
     163    protected void SetupResults() {
     164      Results.Clear();
     165
     166      Results.Add(new Result("Sliding Window Movements", new IntValue(0)));
     167      Results.Add(new Result("Best Quality", new DoubleValue(0)));
     168      Results.Add(new Result("Qualities", new DataTable("Qualities")));
     169      Results.Add(new Result("Targets", new DataTable("Targets")));
     170
     171      ResultsQualities.Rows.Add(new DataRow(ResultsQualitiesR2));
     172      ResultsQualities.Rows.Add(new DataRow(ResultsQualitiesPearson));
     173      ResultsTargets.Rows.Add(new DataRow(ResultsTargetsReal));
     174      foreach (var ensemble in Ensembles) {
     175        ResultsTargets.Rows.Add(new DataRow(ensemble.Name));
     176      }
     177    }
     178
    140179    #endregion
    141180
    142181    #region constructors, cloner,...
    143182
    144     public DatastreamAnalysisOptimizer() {
     183    public DatastreamAnalysisOptimizer() : base() {
    145184      name = "Datastream Analysis";
    146185      log = new Log();
     
    159198    [StorableHook(HookType.AfterDeserialization)]
    160199    private void AfterDeserialization() {
    161       // nothing to do in here
     200      Initialize();
    162201    }
    163202
     
    179218    private void Initialize() {
    180219      if (runs != null) RegisterRunsEvents();
     220      if (datastream != null) RegisterDatastreamEvents();
     221      if (ensembles != null) RegisterEnsembleEvents();
    181222    }
    182223    #endregion
     
    185226
    186227    public override void Prepare() {
    187       if (ensembles == null || datastream == null) return;
    188       Prepare(true);
     228      if (ensembles == null || ensembles.Count == 0 || datastream == null || !datastream.SlidingWindowEvaluationPossible) return;
     229      //if (ensembles.SelectMany(x => x.Models).Count() == 0) return;
     230      base.Prepare();
     231      OnPrepared();
    189232    }
    190233
    191234    public void Prepare(bool clearRuns) {
    192       if (ensembles == null || datastream == null) return;
     235      if (ensembles == null || ensembles.Count == 0 || datastream == null || !datastream.SlidingWindowEvaluationPossible) return;
     236
    193237      base.Prepare();
    194       if (clearRuns) results.Clear();
     238      if (clearRuns) runs.Clear();
    195239      OnPrepared();
    196240    }
     
    201245      cancellationTokenSource = new CancellationTokenSource();
    202246      stopPending = false;
     247
     248      if (prepared) {
     249        SetupResults();
     250        //prepared = false;
     251      }
    203252
    204253      Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token);
     
    219268
    220269        // handle stop/pause
    221         if(stopPending) { }
    222         if(!Datastream.SlidingWindowMovementPossible) OnStopped();
    223         else OnPaused();
     270        if (stopPending || finished) {
     271          OnStopped();
     272        } else {
     273          OnPaused();
     274        }
     275        //if(!Datastream.SlidingWindowMovementPossible) OnStopped();
     276        //else OnPaused();
    224277      });
    225278
     
    244297
    245298    protected override void OnPrepared() {
     299      ExecutionTime = TimeSpan.Zero;
     300      foreach (IStatefulItem statefulItem in this.GetObjectGraphObjects(new HashSet<object>() {Runs}).OfType<IStatefulItem>()) {
     301        statefulItem.InitializeState();
     302      }
     303      results.Clear();
     304      prepared = true;
     305      finished = false;
    246306      Log.LogMessage("Datastream analysis prepared");
    247307      base.OnPrepared();
     
    259319
    260320    protected override void OnStopped() {
    261       Log.LogMessage("Datastream analysis stopped");
    262       base.OnStopped();
     321      try {
     322        runsCounter++;
     323        var run = new Run();
     324        run.Filename = Filename;
     325        run.Name = string.Format("{0} Run {1}", Name, runsCounter);
     326        CollectParameterValues(run.Parameters);
     327        CollectResultValues(run.Results);
     328        runs.Add(run);
     329      }
     330      finally {
     331        Log.LogMessage("Datastream analysis stopped");
     332        base.OnStopped();
     333      }
    263334    }
    264335
    265336    #endregion
    266337
    267 
     338    #region run
    268339    private void Run(object state) {
    269340      CancellationToken cancellationToken = (CancellationToken) state;
     
    287358    }
    288359
     360    private int replayedIndex;
     361
    289362    protected void Run(CancellationToken cancellationToken) {
    290 
    291       // setup results
    292       var slidingWindowMovements = new IntValue(0);
    293       Results.Add(new Result("Sliding Window Movements", slidingWindowMovements));
    294 
    295       var qtable = new DataTable("Qualities");
    296       qtable.Rows.Add(new DataRow("R²"));
    297       qtable.Rows.Add(new DataRow("Pearson"));
    298       Results.Add(new Result("Qualities", qtable));
    299 
    300       var curLoss = new DoubleValue();
    301       Results.Add(new Result("R²", curLoss));
    302       Results.Add(new Result("Best Quality", curLoss));
    303 
    304 
    305363      // init algorithm
    306364      var problemData = Datastream.ProblemData;
    307365      var targetVarName = problemData.TargetVariable;
    308366      var activeVariables = problemData.AllowedInputVariables;
     367
     368      if (prepared) {
     369        // replay datastream until FitnessPartition.End
     370        //for (int i = 0; i < Datastream.FitnessPartition.End; i++) {
     371        //  var val = problemData.Dataset.GetDoubleValue(targetVarName, i);
     372        //  ResultsTargets.Rows[ResultsTargetsReal].Values.Add(val);
     373        //}
     374        //replayedIndex = Datastream.FitnessPartition.End;
     375        replayedIndex = 0;
     376        prepared = false;
     377      }
     378
     379
    309380      Random rnd = new Random();
    310381
    311382      try {
    312         while (Datastream.SlidingWindowMovementPossible) {
    313           cancellationToken.ThrowIfCancellationRequested();
    314 
    315           Task.Delay(Datastream.SlidingWindowMovementInterval.Value);
    316 
    317           Datastream.MoveSlidingWindow();
    318 
    319           // TODO do the window evaluation
    320 
    321           // TODO: collect results and display them
    322 
    323           curLoss.Value = rnd.Next(100);
    324           qtable.Rows["R²"].Values.Add(curLoss.Value);
    325           qtable.Rows["Pearson"].Values.Add(curLoss.Value % 10);
    326 
    327           slidingWindowMovements.Value++;
    328         }
    329 
    330         // TODO: collect runs (c.f. goal seeking)
     383        do {
     384          do {
     385            cancellationToken.ThrowIfCancellationRequested();
     386
     387            Thread.Sleep(Datastream.SlidingWindowMovementInterval.Value);
     388            Datastream.MoveSlidingWindow();
     389
     390            if (Datastream.SlidingWindowEvaluationPossible) {
     391              foreach (var ensemble in Ensembles) {
     392                // TODO do the window evaluation
     393                double estimatedVal = problemData.Dataset.GetDoubleValue(targetVarName, replayedIndex)
     394                                      * (1.0 + (((double)rnd.Next(0, 30)) / 100));
     395                for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) {
     396                  ResultsTargets.Rows[ensemble.Name].Values.Add(estimatedVal);
     397                }
     398              }
     399            }
     400
     401            // replay datastream until FitnessPartition.End
     402            for (int i = replayedIndex; i < Datastream.FitnessPartition.End; i++) {
     403              var val = problemData.Dataset.GetDoubleValue(targetVarName, i);
     404              ResultsTargets.Rows[ResultsTargetsReal].Values.Add(val);
     405            }
     406            replayedIndex = Datastream.FitnessPartition.End;
     407
     408
     409            // TODO: collect results and display them
     410
     411            int exp = rnd.Next(100);
     412            ResultsQualities.Rows[ResultsQualitiesR2].Values.Add(exp);
     413            ResultsQualities.Rows[ResultsQualitiesPearson].Values.Add((double)exp / 10);
     414            ResultsSlidingWindowMovements++;
     415            ResultsBestQuality = (double)exp / 42;
     416
     417          } while (Datastream.SlidingWindowMovementPossible);
     418        } while (Datastream.UpdateAvailable);
     419        finished = true;
    331420      }
    332421      catch (Exception ex) {
     
    349438    }
    350439
     440    public void CollectParameterValues(IDictionary<string, IItem> values) {
     441      values.Add("Datastream Analysis Name", new StringValue(Name));
     442      if (Datastream != null) {
     443        Datastream.CollectParameterValues(values);
     444        values.Add("Datastream Name", new StringValue(Datastream.Name));
     445      }
     446    }
     447
    351448    public void CollectResultValues(IDictionary<string, IItem> values) {
    352449      values.Add("Execution Time", new TimeSpanValue(ExecutionTime));
    353450      Results.CollectResultValues(values);
    354451    }
     452    #endregion
    355453
    356454    #region events
     455
     456    #region events registration
    357457
    358458    public EventHandler EnsemblesChanged;
     
    367467    }
    368468
     469    protected virtual void RegisterDatastreamEvents() {
     470      datastream.Reset += new EventHandler(Datastream_Reset);
     471      datastream.ProblemDataChanged += new EventHandler(Datastream_ProblemDataChanged);
     472    }
     473
     474    protected virtual void DeregisterDatastreamEvents() {
     475      datastream.Reset -= new EventHandler(Datastream_Reset);
     476      datastream.ProblemDataChanged -= new EventHandler(Datastream_ProblemDataChanged);
     477    }
     478
     479    protected virtual void RegisterEnsembleEvents() {
     480      ensembles.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_ItemsChanged);
     481      ensembles.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_ItemsChanged);
     482      ensembles.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_ItemsChanged);
     483      ensembles.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_ItemsChanged);
     484      ensembles.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_Reset);
     485    }
     486
     487    protected virtual void DeregisterEnsembleEvents() {
     488      ensembles.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_ItemsChanged);
     489      ensembles.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_ItemsChanged);
     490      ensembles.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_ItemsChanged);
     491      ensembles.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_ItemsChanged);
     492      ensembles.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<RegressionEnsembleModel>>(Ensembles_Reset);
     493    }
     494    #endregion
     495
     496    #region event handling
     497
    369498    protected virtual void Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    370499      runsCounter = runs.Count;
    371500    }
    372501
    373     #region event handling
     502    protected virtual void Datastream_Reset(object sender, EventArgs e) {
     503      Prepare();
     504    }
     505
     506    protected virtual void Datastream_ProblemDataChanged(object sender, EventArgs e) {
     507      Prepare();
     508    }
     509
     510    protected virtual void Ensembles_Reset(object sender, EventArgs e) {
     511      Prepare();
     512    }
     513
     514    protected virtual void Ensembles_ItemsChanged(object sender, EventArgs e) {
     515      Prepare();
     516    }
    374517
    375518    private void OnEnsemblesChanged() {
     
    389532    #endregion
    390533
    391     #region nameditem
    392 
    393     [Storable] protected string name;
     534    #region NamedItem
     535
     536    [Storable]
     537    protected string name;
    394538
    395539    /// <inheritdoc/>
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/IDatastream.cs

    r14536 r14538  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526
    2627namespace HeuristicLab.DatastreamAnalysis {
    27   public interface IDatastream : IParameterizedNamedItem, INamedItem, IItem, IContent, IDeepCloneable, ICloneable, IParameterizedItem {
     28  /// <summary>
     29  /// Interface to represent a datastream.
     30  /// </summary>
     31  public interface IDatastream : IParameterizedNamedItem {
     32    IEnumerable<IParameterizedItem> ExecutionContextItems { get; }
     33    event EventHandler Reset;
     34    event EventHandler ProblemDataChanged;
    2835  }
    2936}
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Plugin.cs

    r14536 r14538  
    2323
    2424namespace HeuristicLab.DatastreamAnalysis {
    25   [Plugin("HeuristicLab.DatastreamAnalysis", "3.4.14.14491")]
     25  [Plugin("HeuristicLab.DatastreamAnalysis", "3.4.14.14536")]
    2626  [PluginFile("HeuristicLab.DatastreamAnalysis-3.4.dll", PluginFileType.Assembly)]
    2727  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/Properties/AssemblyInfo.cs

    r14536 r14538  
    5454// [assembly: AssemblyVersion("1.0.*")]
    5555[assembly: AssemblyVersion("3.4.0.0")]
    56 [assembly: AssemblyFileVersion("3.4.14.14491")]
     56[assembly: AssemblyFileVersion("3.4.14.14536")]
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleModel.cs

    r14536 r14538  
    8282    [StorableHook(HookType.AfterDeserialization)]
    8383    private void AfterDeserialization() {
    84 
    85       foreach (var model in Models) {
    86         this.models.Add(model);
    87       }
    88 
    8984      // BackwardsCompatibility 3.3.14
    9085      #region Backwards compatible code, remove with 3.4
Note: See TracChangeset for help on using the changeset viewer.