Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12800


Ignore:
Timestamp:
07/22/15 16:20:26 (9 years ago)
Author:
gkronber
Message:

#2434 added support for a partition variable to CrossValidation

Location:
branches/crossvalidation-2434
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/CrossValidationView.Designer.cs

    r12012 r12800  
    4646    /// </summary>
    4747    private void InitializeComponent() {
     48      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CrossValidationView));
    4849      this.startButton = new System.Windows.Forms.Button();
    4950      this.pauseButton = new System.Windows.Forms.Button();
     
    7980      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    8081      this.splitContainer = new System.Windows.Forms.SplitContainer();
     82      this.partitionVariableComboBox = new System.Windows.Forms.ComboBox();
     83      this.partitionVariableLabel = new System.Windows.Forms.Label();
    8184      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    8285      ((System.ComponentModel.ISupportInitialize)(this.foldsNumericUpDown)).BeginInit();
     
    109112      //
    110113      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    111       this.startButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
     114      this.startButton.Image = ((System.Drawing.Image)(resources.GetObject("startButton.Image")));
    112115      this.startButton.Location = new System.Drawing.Point(0, 514);
    113116      this.startButton.Name = "startButton";
     
    120123      //
    121124      this.pauseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    122       this.pauseButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Pause;
     125      this.pauseButton.Image = ((System.Drawing.Image)(resources.GetObject("pauseButton.Image")));
    123126      this.pauseButton.Location = new System.Drawing.Point(30, 514);
    124127      this.pauseButton.Name = "pauseButton";
     
    131134      //
    132135      this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    133       this.stopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Stop;
     136      this.stopButton.Image = ((System.Drawing.Image)(resources.GetObject("stopButton.Image")));
    134137      this.stopButton.Location = new System.Drawing.Point(60, 514);
    135138      this.stopButton.Name = "stopButton";
     
    142145      //
    143146      this.resetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    144       this.resetButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Restart;
     147      this.resetButton.Image = ((System.Drawing.Image)(resources.GetObject("resetButton.Image")));
    145148      this.resetButton.Location = new System.Drawing.Point(90, 514);
    146149      this.resetButton.Name = "resetButton";
     
    171174      // foldsNumericUpDown
    172175      //
    173       this.foldsNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    174                   | System.Windows.Forms.AnchorStyles.Right)));
    175       this.foldsNumericUpDown.Location = new System.Drawing.Point(55, 26);
     176      this.foldsNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     177            | System.Windows.Forms.AnchorStyles.Right)));
     178      this.foldsNumericUpDown.Location = new System.Drawing.Point(62, 26);
    176179      this.foldsNumericUpDown.Maximum = new decimal(new int[] {
    177180            50,
     
    185188            0});
    186189      this.foldsNumericUpDown.Name = "foldsNumericUpDown";
    187       this.foldsNumericUpDown.Size = new System.Drawing.Size(248, 20);
     190      this.foldsNumericUpDown.Size = new System.Drawing.Size(241, 20);
    188191      this.foldsNumericUpDown.TabIndex = 3;
    189192      this.foldsNumericUpDown.ThousandsSeparator = true;
     
    207210      // workersNumericUpDown
    208211      //
    209       this.workersNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    210                   | System.Windows.Forms.AnchorStyles.Right)));
    211       this.workersNumericUpDown.Location = new System.Drawing.Point(55, 0);
     212      this.workersNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     213            | System.Windows.Forms.AnchorStyles.Right)));
     214      this.workersNumericUpDown.Location = new System.Drawing.Point(62, 0);
    212215      this.workersNumericUpDown.Maximum = new decimal(new int[] {
    213216            50,
     
    221224            0});
    222225      this.workersNumericUpDown.Name = "workersNumericUpDown";
    223       this.workersNumericUpDown.Size = new System.Drawing.Size(248, 20);
     226      this.workersNumericUpDown.Size = new System.Drawing.Size(241, 20);
    224227      this.workersNumericUpDown.TabIndex = 1;
    225228      this.workersNumericUpDown.ThousandsSeparator = true;
     
    248251      this.samplesStartLabel.Size = new System.Drawing.Size(75, 13);
    249252      this.samplesStartLabel.TabIndex = 0;
    250       this.samplesStartLabel.Text = "&Samples Start:";
     253      this.samplesStartLabel.Text = "Samples &Start:";
    251254      //
    252255      // samplesEndLabel
     
    257260      this.samplesEndLabel.Size = new System.Drawing.Size(72, 13);
    258261      this.samplesEndLabel.TabIndex = 2;
    259       this.samplesEndLabel.Text = "&Samples End:";
     262      this.samplesEndLabel.Text = "Samples &End:";
    260263      //
    261264      // samplesEndStringConvertibleValueView
    262265      //
    263       this.samplesEndStringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    264                   | System.Windows.Forms.AnchorStyles.Right)));
     266      this.samplesEndStringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     267            | System.Windows.Forms.AnchorStyles.Right)));
    265268      this.samplesEndStringConvertibleValueView.Caption = "StringConvertibleValue View";
    266269      this.samplesEndStringConvertibleValueView.Content = null;
     
    274277      // samplesStartStringConvertibleValueView
    275278      //
    276       this.samplesStartStringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    277                   | System.Windows.Forms.AnchorStyles.Right)));
     279      this.samplesStartStringConvertibleValueView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     280            | System.Windows.Forms.AnchorStyles.Right)));
    278281      this.samplesStartStringConvertibleValueView.Caption = "StringConvertibleValue View";
    279282      this.samplesStartStringConvertibleValueView.Content = null;
     
    288291      //
    289292      this.tabControl.AllowDrop = true;
    290       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    291                   | System.Windows.Forms.AnchorStyles.Left)
    292                   | System.Windows.Forms.AnchorStyles.Right)));
     293      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     294            | System.Windows.Forms.AnchorStyles.Left)
     295            | System.Windows.Forms.AnchorStyles.Right)));
    293296      this.tabControl.Controls.Add(this.algorithmTabPage);
    294297      this.tabControl.Controls.Add(this.resultsTabPage);
    295298      this.tabControl.Controls.Add(this.runsTabPage);
    296       this.tabControl.Location = new System.Drawing.Point(0, 87);
     299      this.tabControl.Location = new System.Drawing.Point(0, 109);
    297300      this.tabControl.Name = "tabControl";
    298301      this.tabControl.SelectedIndex = 0;
    299       this.tabControl.Size = new System.Drawing.Size(616, 421);
    300       this.tabControl.TabIndex = 4;
     302      this.tabControl.Size = new System.Drawing.Size(616, 399);
     303      this.tabControl.TabIndex = 5;
    301304      //
    302305      // algorithmTabPage
     
    310313      this.algorithmTabPage.Name = "algorithmTabPage";
    311314      this.algorithmTabPage.Padding = new System.Windows.Forms.Padding(3);
    312       this.algorithmTabPage.Size = new System.Drawing.Size(608, 395);
     315      this.algorithmTabPage.Size = new System.Drawing.Size(608, 373);
    313316      this.algorithmTabPage.TabIndex = 0;
    314317      this.algorithmTabPage.Text = "Algorithm";
     
    320323      // algorithmNamedItemView
    321324      //
    322       this.algorithmNamedItemView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    323                   | System.Windows.Forms.AnchorStyles.Right)));
     325      this.algorithmNamedItemView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     326            | System.Windows.Forms.AnchorStyles.Right)));
    324327      this.algorithmNamedItemView.Caption = "NamedItem View";
    325328      this.algorithmNamedItemView.Content = null;
     
    333336      //
    334337      this.algorithmTabControl.AllowDrop = true;
    335       this.algorithmTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    336                   | System.Windows.Forms.AnchorStyles.Left)
    337                   | System.Windows.Forms.AnchorStyles.Right)));
     338      this.algorithmTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     339            | System.Windows.Forms.AnchorStyles.Left)
     340            | System.Windows.Forms.AnchorStyles.Right)));
    338341      this.algorithmTabControl.Controls.Add(this.algorithmProblemTabPage);
    339342      this.algorithmTabControl.Controls.Add(this.algorithmParametersTabPage);
     
    341344      this.algorithmTabControl.Name = "algorithmTabControl";
    342345      this.algorithmTabControl.SelectedIndex = 0;
    343       this.algorithmTabControl.Size = new System.Drawing.Size(594, 324);
     346      this.algorithmTabControl.Size = new System.Drawing.Size(594, 302);
    344347      this.algorithmTabControl.TabIndex = 3;
    345348      //
     
    353356      this.algorithmProblemTabPage.Name = "algorithmProblemTabPage";
    354357      this.algorithmProblemTabPage.Padding = new System.Windows.Forms.Padding(3);
    355       this.algorithmProblemTabPage.Size = new System.Drawing.Size(586, 298);
     358      this.algorithmProblemTabPage.Size = new System.Drawing.Size(586, 276);
    356359      this.algorithmProblemTabPage.TabIndex = 0;
    357360      this.algorithmProblemTabPage.Text = "Problem";
     
    363366      // openProblemButton
    364367      //
    365       this.openProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
     368      this.openProblemButton.Image = ((System.Drawing.Image)(resources.GetObject("openProblemButton.Image")));
    366369      this.openProblemButton.Location = new System.Drawing.Point(36, 6);
    367370      this.openProblemButton.Name = "openProblemButton";
     
    374377      // algorithmProblemViewHost
    375378      //
    376       this.algorithmProblemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    377                   | System.Windows.Forms.AnchorStyles.Left)
    378                   | System.Windows.Forms.AnchorStyles.Right)));
     379      this.algorithmProblemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     380            | System.Windows.Forms.AnchorStyles.Left)
     381            | System.Windows.Forms.AnchorStyles.Right)));
    379382      this.algorithmProblemViewHost.Caption = "View";
    380383      this.algorithmProblemViewHost.Content = null;
     
    383386      this.algorithmProblemViewHost.Name = "algorithmProblemViewHost";
    384387      this.algorithmProblemViewHost.ReadOnly = false;
    385       this.algorithmProblemViewHost.Size = new System.Drawing.Size(574, 256);
     388      this.algorithmProblemViewHost.Size = new System.Drawing.Size(574, 234);
    386389      this.algorithmProblemViewHost.TabIndex = 2;
    387390      this.algorithmProblemViewHost.ViewsLabelVisible = true;
     
    390393      // newProblemButton
    391394      //
    392       this.newProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
     395      this.newProblemButton.Image = ((System.Drawing.Image)(resources.GetObject("newProblemButton.Image")));
    393396      this.newProblemButton.Location = new System.Drawing.Point(6, 6);
    394397      this.newProblemButton.Name = "newProblemButton";
     
    405408      this.algorithmParametersTabPage.Name = "algorithmParametersTabPage";
    406409      this.algorithmParametersTabPage.Padding = new System.Windows.Forms.Padding(3);
    407       this.algorithmParametersTabPage.Size = new System.Drawing.Size(586, 298);
     410      this.algorithmParametersTabPage.Size = new System.Drawing.Size(586, 276);
    408411      this.algorithmParametersTabPage.TabIndex = 1;
    409412      this.algorithmParametersTabPage.Text = "Parameters";
     
    412415      // algorithmParameterCollectionView
    413416      //
     417      this.algorithmParameterCollectionView.AllowEditingOfHiddenParameters = true;
    414418      this.algorithmParameterCollectionView.Caption = "ParameterCollection View";
    415419      this.algorithmParameterCollectionView.Content = null;
     
    418422      this.algorithmParameterCollectionView.Name = "algorithmParameterCollectionView";
    419423      this.algorithmParameterCollectionView.ReadOnly = false;
    420       this.algorithmParameterCollectionView.Size = new System.Drawing.Size(580, 292);
     424      this.algorithmParameterCollectionView.ShowDetails = true;
     425      this.algorithmParameterCollectionView.Size = new System.Drawing.Size(580, 270);
    421426      this.algorithmParameterCollectionView.TabIndex = 0;
    422427      //
    423428      // openAlgorithmButton
    424429      //
    425       this.openAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
     430      this.openAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("openAlgorithmButton.Image")));
    426431      this.openAlgorithmButton.Location = new System.Drawing.Point(38, 6);
    427432      this.openAlgorithmButton.Name = "openAlgorithmButton";
     
    434439      // newAlgorithmButton
    435440      //
    436       this.newAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
     441      this.newAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("newAlgorithmButton.Image")));
    437442      this.newAlgorithmButton.Location = new System.Drawing.Point(8, 6);
    438443      this.newAlgorithmButton.Name = "newAlgorithmButton";
     
    449454      this.resultsTabPage.Name = "resultsTabPage";
    450455      this.resultsTabPage.Padding = new System.Windows.Forms.Padding(3);
    451       this.resultsTabPage.Size = new System.Drawing.Size(608, 395);
     456      this.resultsTabPage.Size = new System.Drawing.Size(608, 373);
    452457      this.resultsTabPage.TabIndex = 1;
    453458      this.resultsTabPage.Text = "Results";
     
    462467      this.resultCollectionView.Name = "resultCollectionView";
    463468      this.resultCollectionView.ReadOnly = true;
    464       this.resultCollectionView.Size = new System.Drawing.Size(602, 389);
     469      this.resultCollectionView.ShowDetails = true;
     470      this.resultCollectionView.Size = new System.Drawing.Size(602, 367);
    465471      this.resultCollectionView.TabIndex = 0;
    466472      //
     
    472478      this.runsTabPage.Name = "runsTabPage";
    473479      this.runsTabPage.Padding = new System.Windows.Forms.Padding(3);
    474       this.runsTabPage.Size = new System.Drawing.Size(608, 395);
     480      this.runsTabPage.Size = new System.Drawing.Size(608, 373);
    475481      this.runsTabPage.TabIndex = 2;
    476482      this.runsTabPage.Text = "Runs";
     
    501507      this.runCollectionView.Name = "runCollectionView";
    502508      this.runCollectionView.ReadOnly = false;
    503       this.runCollectionView.Size = new System.Drawing.Size(602, 389);
     509      this.runCollectionView.Size = new System.Drawing.Size(602, 367);
    504510      this.runCollectionView.TabIndex = 0;
    505511      //
     
    513519      // splitContainer
    514520      //
    515       this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    516                   | System.Windows.Forms.AnchorStyles.Right)));
     521      this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     522            | System.Windows.Forms.AnchorStyles.Right)));
    517523      this.splitContainer.Location = new System.Drawing.Point(0, 26);
    518524      this.splitContainer.Name = "splitContainer";
     
    527533      // splitContainer.Panel2
    528534      //
     535      this.splitContainer.Panel2.Controls.Add(this.partitionVariableComboBox);
     536      this.splitContainer.Panel2.Controls.Add(this.partitionVariableLabel);
    529537      this.splitContainer.Panel2.Controls.Add(this.foldsNumericUpDown);
    530538      this.splitContainer.Panel2.Controls.Add(this.foldsLabel);
    531539      this.splitContainer.Panel2.Controls.Add(this.workersLabel);
    532540      this.splitContainer.Panel2.Controls.Add(this.workersNumericUpDown);
    533       this.splitContainer.Size = new System.Drawing.Size(616, 55);
     541      this.splitContainer.Size = new System.Drawing.Size(616, 77);
    534542      this.splitContainer.SplitterDistance = 306;
    535543      this.splitContainer.TabIndex = 3;
    536544      //
     545      // partitionVariableComboBox
     546      //
     547      this.partitionVariableComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     548            | System.Windows.Forms.AnchorStyles.Right)));
     549      this.partitionVariableComboBox.FormattingEnabled = true;
     550      this.partitionVariableComboBox.Items.AddRange(new object[] {
     551            "<none>"});
     552      this.partitionVariableComboBox.Location = new System.Drawing.Point(62, 52);
     553      this.partitionVariableComboBox.Name = "partitionVariableComboBox";
     554      this.partitionVariableComboBox.Size = new System.Drawing.Size(241, 21);
     555      this.partitionVariableComboBox.TabIndex = 4;
     556      this.partitionVariableComboBox.SelectionChangeCommitted += new System.EventHandler(this.partitionVariableComboBox_SelectionChangeCommitted);
     557      //
     558      // partitionVariableLabel
     559      //
     560      this.partitionVariableLabel.AutoSize = true;
     561      this.partitionVariableLabel.Location = new System.Drawing.Point(3, 55);
     562      this.partitionVariableLabel.Name = "partitionVariableLabel";
     563      this.partitionVariableLabel.Size = new System.Drawing.Size(53, 13);
     564      this.partitionVariableLabel.TabIndex = 4;
     565      this.partitionVariableLabel.Text = "&Partitions:";
     566      //
    537567      // CrossValidationView
    538568      //
    539       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    540569      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    541570      this.Controls.Add(this.tabControl);
     
    617646    private System.Windows.Forms.SplitContainer splitContainer;
    618647    private Optimization.Views.ResultCollectionView resultCollectionView;
     648    private System.Windows.Forms.ComboBox partitionVariableComboBox;
     649    private System.Windows.Forms.Label partitionVariableLabel;
    619650  }
    620651}
  • branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/CrossValidationView.cs

    r12012 r12800  
    6464        Locked = ReadOnly = Content.ExecutionState == ExecutionState.Started;
    6565        workersNumericUpDown.Value = Content.NumberOfWorkers.Value;
    66         foldsNumericUpDown.Value = Content.Folds.Value;
     66        foldsNumericUpDown.Value = Content.Folds;
    6767        samplesStartStringConvertibleValueView.Content = Content.SamplesStart;
    6868        samplesEndStringConvertibleValueView.Content = Content.SamplesEnd;
     
    8181      Content.AlgorithmChanged += new EventHandler(Content_AlgorithmChanged);
    8282      Content.ProblemChanged += new EventHandler(Content_ProblemChanged);
    83       Content.Folds.ValueChanged += new EventHandler(Content_Folds_ValueChanged);
     83      if (Content.Problem != null) Content.Problem.Reset += Content_ProblemReset;
     84      Content.FoldsChanged += Content_FoldsChanged;
    8485      Content.NumberOfWorkers.ValueChanged += new EventHandler(Content_NumberOfWorker_ValueChanged);
    8586
     
    9394      Content.AlgorithmChanged -= new EventHandler(Content_AlgorithmChanged);
    9495      Content.ProblemChanged -= new EventHandler(Content_ProblemChanged);
    95       Content.Folds.ValueChanged -= new EventHandler(Content_Folds_ValueChanged);
     96      if (Content.Problem != null) Content.Problem.Reset -= Content_ProblemReset;
     97      Content.FoldsChanged -= Content_FoldsChanged;
    9698      Content.NumberOfWorkers.ValueChanged -= new EventHandler(Content_NumberOfWorker_ValueChanged);
    9799
     
    132134          samplesEndStringConvertibleValueView.Enabled = Content.ExecutionState == ExecutionState.Prepared;
    133135          workersNumericUpDown.Enabled = (Content.ExecutionState == ExecutionState.Prepared) || (Content.ExecutionState == ExecutionState.Paused);
     136          partitionVariableLabel.Enabled = (Content.ExecutionState == ExecutionState.Prepared);
     137          partitionVariableComboBox.Enabled = (Content.ExecutionState == ExecutionState.Prepared);
    134138
    135139          startButton.Enabled = (Content.ExecutionState == ExecutionState.Prepared) || (Content.ExecutionState == ExecutionState.Paused);
     
    144148    private void Content_AlgorithmChanged(object sender, EventArgs e) {
    145149      UpdateAlgorithmView();
     150      UpdateFolds();
    146151      UpdateProblemView();
    147152      SetEnabledStateOfControls();
    148153    }
    149154    private void UpdateAlgorithmView() {
    150       algorithmNamedItemView.Content = Content.Algorithm;
    151       UpdateProblemView();
     155      if (InvokeRequired) Invoke((Action)UpdateAlgorithmView);
     156      else {
     157        algorithmNamedItemView.Content = Content.Algorithm;
     158        UpdateProblemView();
     159      }
    152160    }
    153161
    154162    private void Content_ProblemChanged(object sender, EventArgs e) {
     163      if (Content.Problem != null) Content.Problem.Reset += Content_ProblemReset;
     164      UpdateFolds();
    155165      UpdateProblemView();
    156166      SetEnabledStateOfControls();
    157167    }
     168
     169    private void Content_ProblemReset(object sender, EventArgs e) {
     170      UpdateFolds();
     171    }
     172
     173
    158174    private void UpdateProblemView() {
    159       algorithmProblemViewHost.Content = Content.Problem;
    160     }
    161 
    162     private void Content_Folds_ValueChanged(object sender, EventArgs e) {
    163       foldsNumericUpDown.Value = Content.Folds.Value;
    164     }
     175      if (InvokeRequired) Invoke((Action)UpdateProblemView);
     176      else {
     177        algorithmProblemViewHost.Content = Content.Problem;
     178      }
     179    }
     180
     181    private void Content_FoldsChanged(object sender, EventArgs e) {
     182      UpdateFolds();
     183    }
     184
     185    private bool disableUpdateToContent = false; // to prevent changing Content.Folds or Content.PartitionVariable while updating the GUI from the content
     186    private void UpdateFolds() {
     187      if (InvokeRequired) Invoke((Action)UpdateFolds);
     188      else {
     189        disableUpdateToContent = true;
     190        foldsNumericUpDown.Value = Content.Folds;
     191
     192        partitionVariableComboBox.BeginUpdate();
     193        partitionVariableComboBox.Items.Clear();
     194        partitionVariableComboBox.Items.Add(CrossValidation.NoPartitionVariable);
     195        var ds = Content.Problem.ProblemData.Dataset;
     196        var rows = Enumerable.Range(Content.SamplesStart.Value, Content.SamplesEnd.Value - Content.SamplesStart.Value);
     197        foreach (var variable in Content.Problem.ProblemData.Dataset.DoubleVariables) {
     198          if (Content.Problem.ProblemData.AllowedInputVariables.Contains(variable)) continue;
     199          int distinctValues = ds.GetDoubleValues(variable, rows).Distinct().Count();
     200          if (distinctValues < 2 || distinctValues > 20) continue;
     201          partitionVariableComboBox.Items.Add(variable);
     202        }
     203        partitionVariableComboBox.SelectedItem = Content.PartitionVariable;
     204        partitionVariableComboBox.EndUpdate();
     205        disableUpdateToContent = false;
     206      }
     207    }
     208
    165209    private void Content_NumberOfWorker_ValueChanged(object sender, EventArgs e) {
    166210      workersNumericUpDown.Value = Content.NumberOfWorkers.Value;
     
    202246    }
    203247    private void foldsNumericUpDown_ValueChanged(object sender, EventArgs e) {
    204       if (Content != null)
    205         Content.Folds.Value = (int)foldsNumericUpDown.Value;
     248      if (Content != null && !disableUpdateToContent) {
     249        Content.Folds = (int)foldsNumericUpDown.Value;
     250      }
    206251    }
    207252
     
    238283        try {
    239284          Content.Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    240         }
    241         catch (Exception ex) {
     285        } catch (Exception ex) {
    242286          ErrorHandling.ShowErrorDialog(this, ex);
    243287        }
     
    258302            else
    259303              Content.Algorithm = algorithm;
    260           }
    261           catch (Exception ex) {
     304          } catch (Exception ex) {
    262305            ErrorHandling.ShowErrorDialog(this, ex);
    263           }
    264           finally {
     306          } finally {
    265307            Invoke(new Action(delegate() {
    266308              algorithmTabControl.Enabled = true;
     
    298340            else
    299341              Content.Problem = problem;
    300           }
    301           catch (Exception ex) {
     342          } catch (Exception ex) {
    302343            Invoke(new Action(() => ErrorHandling.ShowErrorDialog(this, ex)));
    303           }
    304           finally {
     344          } finally {
    305345            Invoke(new Action(delegate() {
    306346              algorithmProblemViewHost.Enabled = true;
     
    358398    #endregion
    359399
     400    private void partitionVariableComboBox_SelectionChangeCommitted(object sender, EventArgs e) {
     401      // when the user changes the selection in the GUI
     402      if (Content != null && !disableUpdateToContent)
     403        Content.PartitionVariable = (string)partitionVariableComboBox.SelectedItem;
     404    }
    360405  }
    361406}
  • branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r12504 r12800  
    5252      results = new ResultCollection();
    5353
    54       folds = new IntValue(2);
     54      folds = 2;
    5555      numberOfWorkers = new IntValue(1);
    5656      samplesStart = new IntValue(0);
     
    7373      RegisterEvents();
    7474      if (Algorithm != null) RegisterAlgorithmEvents();
     75
     76      // BackwardsCompatibility3.4
     77      #region Backwards compatible code, remove with 3.6
     78      if (persistenceCompatibilityFolds != null) folds = persistenceCompatibilityFolds.Value;
     79      #endregion
    7580    }
    7681
     
    8590      results = cloner.Clone(original.results);
    8691
    87       folds = cloner.Clone(original.folds);
     92      folds = original.folds;
    8893      numberOfWorkers = cloner.Clone(original.numberOfWorkers);
    8994      samplesStart = cloner.Clone(original.samplesStart);
     
    171176    }
    172177
    173     [Storable]
    174     private IntValue folds;
    175     public IntValue Folds {
     178    // BackwardsCompatibility3.4
     179    #region Backwards compatible code, remove with 3.6
     180    [Storable(Name = "folds")]
     181    private IntValue persistenceCompatibilityFolds;
     182    #endregion
     183
     184    [Storable(Name = "foldsNew")]
     185    private int folds;
     186    public int Folds {
    176187      get { return folds; }
    177     }
     188      set {
     189        if (value != folds) {
     190          folds = value;
     191          partitionVariable = NoPartitionVariable; // setting folds updates the partition variable
     192          OnFoldsChanged();
     193        }
     194      }
     195    }
     196
     197    [Storable]
     198    // folds are either specified explicitly or by a varaible from the dataset
     199    public const string NoPartitionVariable = "<none>";
     200    private string partitionVariable = NoPartitionVariable;
     201    public string PartitionVariable {
     202      get { return partitionVariable; }
     203      set {
     204        if (value != partitionVariable) {
     205          partitionVariable = value;
     206          UpdateNumberOfFolds();
     207        }
     208      }
     209    }
     210
    178211    [Storable]
    179212    private IntValue samplesStart;
     
    244277      }
    245278    }
     279
    246280    #endregion
    247281
     
    273307        //create cloned algorithms
    274308        if (clonedAlgorithms.Count == 0) {
    275           int testSamplesCount = (SamplesEnd.Value - SamplesStart.Value) / Folds.Value;
    276 
    277           for (int i = 0; i < Folds.Value; i++) {
     309
     310          for (int i = 0; i < folds; i++) {
    278311            IAlgorithm clonedAlgorithm = (IAlgorithm)algorithm.Clone();
    279312            clonedAlgorithm.Name = algorithm.Name + " Fold " + i;
     
    281314            ISymbolicDataAnalysisProblem symbolicProblem = problem as ISymbolicDataAnalysisProblem;
    282315
    283             int testStart = (i * testSamplesCount) + SamplesStart.Value;
    284             int testEnd = (i + 1) == Folds.Value ? SamplesEnd.Value : (i + 1) * testSamplesCount + SamplesStart.Value;
     316            int trainingStart, trainingEnd, testStart, testEnd;
     317            // assumes that partitions are subset of subsequent rows
     318            GetTrainingAndTestPartitions(i, out trainingStart, out trainingEnd, out testStart, out testEnd);
    285319
    286320            problem.ProblemData.TrainingPartition.Start = SamplesStart.Value;
     
    306340        int startedAlgorithms = 0;
    307341        foreach (IAlgorithm clonedAlgorithm in clonedAlgorithms) {
    308           if (startedAlgorithms < NumberOfWorkers.Value) {
     342          if (startedAlgorithms < numberOfWorkers.Value) {
    309343            if (clonedAlgorithm.ExecutionState == ExecutionState.Prepared ||
    310344                clonedAlgorithm.ExecutionState == ExecutionState.Paused) {
     
    324358        }
    325359        OnStarted();
     360      }
     361    }
     362
     363    private void GetTrainingAndTestPartitions(int fold, out int trainingStart, out int trainingEnd, out int testStart, out int testEnd) {
     364      if (partitionVariable == NoPartitionVariable) {
     365        // uniform split
     366        int testSamplesCount = (SamplesEnd.Value - SamplesStart.Value) / folds;
     367        trainingStart = SamplesStart.Value;
     368        trainingEnd = SamplesEnd.Value;
     369        testStart = (fold * testSamplesCount) + SamplesStart.Value;
     370        testEnd = (fold + 1) == folds ? SamplesEnd.Value : (fold + 1) * testSamplesCount + SamplesStart.Value;
     371      } else {
     372        // group rowIdx by partition
     373        var partition = Problem.ProblemData.Dataset.GetReadOnlyDoubleValues(partitionVariable);
     374        var g = Enumerable.Range(SamplesStart.Value, SamplesEnd.Value - SamplesStart.Value).GroupBy(r => partition[r]).OrderBy(r => r.Key).ToList();
     375        trainingStart = SamplesStart.Value;
     376        trainingEnd = SamplesEnd.Value;
     377        testStart = g[fold].Min();
     378        testEnd = g[fold].Max() + 1;
    326379      }
    327380    }
     
    365418      values.Add("Algorithm Name", new StringValue(Name));
    366419      values.Add("Algorithm Type", new StringValue(GetType().GetPrettyName()));
    367       values.Add("Folds", new IntValue(Folds.Value));
     420      values.Add("Folds", new IntValue(folds));
    368421
    369422      if (algorithm != null) {
     
    516569    #region events
    517570    private void RegisterEvents() {
    518       Folds.ValueChanged += new EventHandler(Folds_ValueChanged);
     571      SamplesStart.ValueChanged += (s, e) => UpdateNumberOfFolds();
     572      SamplesEnd.ValueChanged += (s, e) => UpdateNumberOfFolds();
     573
    519574      RegisterClonedAlgorithmsEvents();
    520575    }
    521     private void Folds_ValueChanged(object sender, EventArgs e) {
    522       if (ExecutionState != ExecutionState.Prepared)
    523         throw new InvalidOperationException("Can not change number of folds if the execution state is not prepared.");
     576
     577    private void UpdateNumberOfFolds() {
     578      if (ExecutionState == ExecutionState.Paused || executionState == ExecutionState.Started)
     579        throw new InvalidOperationException("Can not change number of folds if crossvalidation is paused or started.");
     580
     581      if (partitionVariable != NoPartitionVariable) {
     582        // number of folds is the number of distinct values of the partition variable in the range [SamplesStart..SamplesEnd[
     583        var ds = Problem.ProblemData.Dataset;
     584        var partitionValues = ds.GetDoubleValues(PartitionVariable, Enumerable.Range(SamplesStart.Value, SamplesEnd.Value - SamplesStart.Value)).Distinct().Count();
     585        folds = partitionValues;
     586        OnFoldsChanged();
     587      }
    524588    }
    525589
     
    555619    public event EventHandler ProblemChanged;
    556620    private void OnProblemChanged() {
     621      ConfigureProblem();
    557622      EventHandler handler = ProblemChanged;
    558623      if (handler != null) handler(this, EventArgs.Empty);
    559       ConfigureProblem();
    560624    }
    561625
     
    565629
    566630    private void ConfigureProblem() {
     631      folds = 2;
     632      partitionVariable = NoPartitionVariable;
    567633      SamplesStart.Value = 0;
    568634      if (Problem != null) {
     
    687753
    688754    #region event firing
     755
     756    public event EventHandler FoldsChanged;
     757    private void OnFoldsChanged() {
     758      EventHandler handler = FoldsChanged;
     759      if (handler != null) handler(this, EventArgs.Empty);
     760    }
    689761    public event EventHandler ExecutionStateChanged;
    690762    private void OnExecutionStateChanged() {
Note: See TracChangeset for help on using the changeset viewer.