Changeset 8524


Ignore:
Timestamp:
08/27/12 10:39:03 (7 years ago)
Author:
jkarder
Message:

#1853:

  • added problem instance selection to CreateExperimentDialog
  • adopted experiment creation
  • minor code improvements
Location:
branches/ParameterConfigurationEncoding
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.Designer.cs

    r8517 r8524  
    1 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
    223  partial class CreateExperimentDialogV2 {
    324    /// <summary>
     
    3960      this.combinationsLabel = new System.Windows.Forms.Label();
    4061      this.combinationsTextBox = new System.Windows.Forms.TextBox();
     62      this.configurationTabControl = new System.Windows.Forms.TabControl();
     63      this.parameterConfigurationTabPage = new System.Windows.Forms.TabPage();
     64      this.problemInstancesTabPage = new System.Windows.Forms.TabPage();
     65      this.instanceTreeView = new System.Windows.Forms.TreeView();
     66      this.libraryLabel = new System.Windows.Forms.Label();
     67      this.libraryComboBox = new System.Windows.Forms.ComboBox();
     68      this.instanceDiscoveryBackgroundWorker = new System.ComponentModel.BackgroundWorker();
    4169      this.parameterConfigurationTreeView = new HeuristicLab.Encodings.ParameterConfigurationEncoding.Views.ParameterConfigurationTreeView();
    4270      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
    4371      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    4472      ((System.ComponentModel.ISupportInitialize)(this.warningProvider)).BeginInit();
     73      this.configurationTabControl.SuspendLayout();
     74      this.parameterConfigurationTabPage.SuspendLayout();
     75      this.problemInstancesTabPage.SuspendLayout();
    4576      this.SuspendLayout();
    4677      //
     
    188219      this.combinationsTextBox.TabIndex = 11;
    189220      //
     221      // configurationTabControl
     222      //
     223      this.configurationTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     224                  | System.Windows.Forms.AnchorStyles.Left)
     225                  | System.Windows.Forms.AnchorStyles.Right)));
     226      this.configurationTabControl.Controls.Add(this.parameterConfigurationTabPage);
     227      this.configurationTabControl.Controls.Add(this.problemInstancesTabPage);
     228      this.configurationTabControl.Location = new System.Drawing.Point(12, 81);
     229      this.configurationTabControl.Name = "configurationTabControl";
     230      this.configurationTabControl.SelectedIndex = 0;
     231      this.configurationTabControl.Size = new System.Drawing.Size(960, 470);
     232      this.configurationTabControl.TabIndex = 12;
     233      this.configurationTabControl.SelectedIndexChanged += new System.EventHandler(this.configurationTabControl_SelectedIndexChanged);
     234      //
     235      // parameterConfigurationTabPage
     236      //
     237      this.parameterConfigurationTabPage.Controls.Add(this.parameterConfigurationTreeView);
     238      this.parameterConfigurationTabPage.Location = new System.Drawing.Point(4, 22);
     239      this.parameterConfigurationTabPage.Name = "parameterConfigurationTabPage";
     240      this.parameterConfigurationTabPage.Padding = new System.Windows.Forms.Padding(3);
     241      this.parameterConfigurationTabPage.Size = new System.Drawing.Size(952, 444);
     242      this.parameterConfigurationTabPage.TabIndex = 0;
     243      this.parameterConfigurationTabPage.Text = "Parameter Configuration";
     244      this.parameterConfigurationTabPage.UseVisualStyleBackColor = true;
     245      //
     246      // problemInstancesTabPage
     247      //
     248      this.problemInstancesTabPage.Controls.Add(this.instanceTreeView);
     249      this.problemInstancesTabPage.Controls.Add(this.libraryLabel);
     250      this.problemInstancesTabPage.Controls.Add(this.libraryComboBox);
     251      this.problemInstancesTabPage.Location = new System.Drawing.Point(4, 22);
     252      this.problemInstancesTabPage.Name = "problemInstancesTabPage";
     253      this.problemInstancesTabPage.Padding = new System.Windows.Forms.Padding(3);
     254      this.problemInstancesTabPage.Size = new System.Drawing.Size(952, 444);
     255      this.problemInstancesTabPage.TabIndex = 1;
     256      this.problemInstancesTabPage.Text = "Problem Instances";
     257      this.problemInstancesTabPage.UseVisualStyleBackColor = true;
     258      //
     259      // instanceTreeView
     260      //
     261      this.instanceTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     262                  | System.Windows.Forms.AnchorStyles.Left)
     263                  | System.Windows.Forms.AnchorStyles.Right)));
     264      this.instanceTreeView.CheckBoxes = true;
     265      this.instanceTreeView.Location = new System.Drawing.Point(6, 33);
     266      this.instanceTreeView.Name = "instanceTreeView";
     267      this.instanceTreeView.Size = new System.Drawing.Size(940, 405);
     268      this.instanceTreeView.TabIndex = 2;
     269      this.instanceTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.instanceTreeView_AfterCheck);
     270      //
     271      // libraryLabel
     272      //
     273      this.libraryLabel.AutoSize = true;
     274      this.libraryLabel.Location = new System.Drawing.Point(6, 9);
     275      this.libraryLabel.Name = "libraryLabel";
     276      this.libraryLabel.Size = new System.Drawing.Size(41, 13);
     277      this.libraryLabel.TabIndex = 1;
     278      this.libraryLabel.Text = "Library:";
     279      //
     280      // libraryComboBox
     281      //
     282      this.libraryComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     283                  | System.Windows.Forms.AnchorStyles.Right)));
     284      this.libraryComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     285      this.libraryComboBox.FormattingEnabled = true;
     286      this.libraryComboBox.Location = new System.Drawing.Point(53, 6);
     287      this.libraryComboBox.Name = "libraryComboBox";
     288      this.libraryComboBox.Size = new System.Drawing.Size(893, 21);
     289      this.libraryComboBox.TabIndex = 0;
     290      this.libraryComboBox.SelectedIndexChanged += new System.EventHandler(this.libraryComboBox_SelectedIndexChanged);
     291      //
     292      // instanceDiscoveryBackgroundWorker
     293      //
     294      this.instanceDiscoveryBackgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.instanceDiscoveryBackgroundWorker_DoWork);
     295      this.instanceDiscoveryBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.instanceDiscoveryBackgroundWorker_RunWorkerCompleted);
     296      //
    190297      // parameterConfigurationTreeView
    191298      //
     
    195302      this.parameterConfigurationTreeView.Caption = "ParameterConfiguration View";
    196303      this.parameterConfigurationTreeView.Content = null;
    197       this.parameterConfigurationTreeView.Location = new System.Drawing.Point(12, 81);
     304      this.parameterConfigurationTreeView.Location = new System.Drawing.Point(6, 6);
    198305      this.parameterConfigurationTreeView.Name = "parameterConfigurationTreeView";
    199306      this.parameterConfigurationTreeView.ReadOnly = false;
    200       this.parameterConfigurationTreeView.Size = new System.Drawing.Size(960, 470);
     307      this.parameterConfigurationTreeView.Size = new System.Drawing.Size(940, 432);
    201308      this.parameterConfigurationTreeView.TabIndex = 6;
    202309      //
     
    205312      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    206313      this.ClientSize = new System.Drawing.Size(984, 592);
     314      this.Controls.Add(this.configurationTabControl);
    207315      this.Controls.Add(this.combinationsTextBox);
    208316      this.Controls.Add(this.combinationsLabel);
     
    210318      this.Controls.Add(this.cancelButton);
    211319      this.Controls.Add(this.okButton);
    212       this.Controls.Add(this.parameterConfigurationTreeView);
    213320      this.Controls.Add(this.engineLabel);
    214321      this.Controls.Add(this.engineComboBox);
     
    229336      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    230337      ((System.ComponentModel.ISupportInitialize)(this.warningProvider)).EndInit();
     338      this.configurationTabControl.ResumeLayout(false);
     339      this.parameterConfigurationTabPage.ResumeLayout(false);
     340      this.problemInstancesTabPage.ResumeLayout(false);
     341      this.problemInstancesTabPage.PerformLayout();
    231342      this.ResumeLayout(false);
    232343      this.PerformLayout();
     
    251362    private System.Windows.Forms.Label combinationsLabel;
    252363    private System.Windows.Forms.Button calculateCombinationsButton;
     364    private System.Windows.Forms.TabControl configurationTabControl;
     365    private System.Windows.Forms.TabPage parameterConfigurationTabPage;
     366    private System.Windows.Forms.TabPage problemInstancesTabPage;
     367    private System.Windows.Forms.TreeView instanceTreeView;
     368    private System.Windows.Forms.Label libraryLabel;
     369    private System.Windows.Forms.ComboBox libraryComboBox;
     370    private System.ComponentModel.BackgroundWorker instanceDiscoveryBackgroundWorker;
    253371  }
    254372}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.cs

    r8519 r8524  
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
     25using System.Linq;
    2426using System.Threading;
    2527using System.Threading.Tasks;
     
    3032using HeuristicLab.Optimization;
    3133using HeuristicLab.PluginInfrastructure;
     34using HeuristicLab.Problems.Instances;
    3235
    3336namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
     
    4144    private Task generation;
    4245    private CancellationTokenSource cts;
     46    private Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> problemInstanceProviders;
     47    private Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> selectedProblemInstanceProviders;
    4348
    4449    public Experiment Experiment { get; private set; }
     
    5762      createBatchRun = createBatchRunCheckBox.Checked;
    5863      repetitions = (int)repetitionsNumericUpDown.Value;
     64      selectedProblemInstanceProviders = new Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>>();
    5965      progress = new Progress {
    6066        CanBeCanceled = true,
     
    6672    }
    6773
    68     private void SetEnabledStateOfControls(bool state) {
    69       createBatchRunCheckBox.Enabled = state;
    70       repetitionsNumericUpDown.Enabled = state;
    71       engineComboBox.Enabled = state;
    72       okButton.Enabled = state;
    73       cancelButton.Enabled = state;
    74     }
    75 
    76     private void StartProgressView() {
    77       if (InvokeRequired) {
    78         Invoke(new Action(StartProgressView));
    79       } else {
    80         SetEnabledStateOfControls(false);
    81         progress.ProgressValue = 0;
    82         progress.ProgressState = ProgressState.Started;
    83       }
    84     }
    85 
    86     private void FinishProgressView() {
    87       if (InvokeRequired) {
    88         Invoke(new Action(FinishProgressView));
    89       } else {
    90         progress.Finish();
    91         SetEnabledStateOfControls(true);
    92       }
    93     }
    94 
    95     private void CloseDialog() {
    96       if (InvokeRequired) {
    97         Invoke(new Action(CloseDialog));
    98       } else {
    99         this.DialogResult = DialogResult.OK;
    100         this.Close();
    101       }
    102     }
    103 
    104     private void ReportError(Exception e) {
    105       if (InvokeRequired) {
    106         Invoke(new Action<Exception>(ReportError), e);
    107       } else {
    108         ErrorHandling.ShowErrorDialog(this, "An error occurred generating the experiment.", e);
    109       }
    110     }
    111 
     74    #region Background worker
     75    private void instanceDiscoveryBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
     76      var instanceProviders = new Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>>();
     77      foreach (var provider in ProblemInstanceManager.GetProviders(algorithm.Problem))
     78        instanceProviders[provider] = new HashSet<IDataDescriptor>(ProblemInstanceManager.GetDataDescriptors(provider));
     79      e.Result = instanceProviders;
     80    }
     81
     82    private void instanceDiscoveryBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
     83      problemInstanceProviders = (Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>>)e.Result;
     84      libraryComboBox.DisplayMember = "Name";
     85      libraryComboBox.DataSource = problemInstanceProviders.Keys.ToList();
     86      libraryComboBox.Enabled = true;
     87    }
     88    #endregion
     89
     90    #region Events
    11291    private void CreateExperimentDialogV2_Load(object sender, System.EventArgs e) {
    11392      if (algorithm.Problem != null) {
     
    11594        parameterConfigurationTree.ExperimentGenerationProgressChanged += (o, args) => progress.ProgressValue = parameterConfigurationTree.ExperimentGenerationProgress;
    11695        new ProgressView(parameterConfigurationTreeView, progress) { CancelTimeoutMs = 10000 };
     96      } else {
     97        configurationTabControl.TabPages.Remove(problemInstancesTabPage);
     98        SetEnabledStateOfControls(false);
    11799      }
    118100    }
     
    136118    }
    137119
     120    private void configurationTabControl_SelectedIndexChanged(object sender, EventArgs e) {
     121      if (configurationTabControl.SelectedTab == problemInstancesTabPage && problemInstanceProviders == null) {
     122        libraryComboBox.Enabled = false;
     123        instanceDiscoveryBackgroundWorker.RunWorkerAsync();
     124      }
     125    }
     126
     127    private void libraryComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     128      UpdateTreeView((IProblemInstanceProvider)libraryComboBox.SelectedItem);
     129    }
     130
     131    private void instanceTreeView_AfterCheck(object sender, TreeViewEventArgs e) {
     132      if (e.Action != TreeViewAction.Unknown) {
     133        var provider = e.Node.Tag as IProblemInstanceProvider;
     134        if (provider != null) {
     135          if (e.Node.Checked) {
     136            if (!selectedProblemInstanceProviders.ContainsKey(provider))
     137              selectedProblemInstanceProviders[provider] = new HashSet<IDataDescriptor>();
     138            foreach (TreeNode node in e.Node.Nodes) {
     139              selectedProblemInstanceProviders[provider].Add((IDataDescriptor)node.Tag);
     140              node.Checked = e.Node.Checked;
     141            }
     142          } else {
     143            selectedProblemInstanceProviders[provider].Clear();
     144            foreach (TreeNode node in e.Node.Nodes) {
     145              node.Checked = e.Node.Checked;
     146            }
     147          }
     148        } else {
     149          provider = (IProblemInstanceProvider)e.Node.Parent.Tag;
     150          if (!selectedProblemInstanceProviders.ContainsKey(provider))
     151            selectedProblemInstanceProviders[provider] = new HashSet<IDataDescriptor>();
     152          if (e.Node.Checked) {
     153            selectedProblemInstanceProviders[provider].Add((IDataDescriptor)e.Node.Tag);
     154            var instances = new TreeNode[e.Node.Parent.Nodes.Count];
     155            e.Node.Parent.Nodes.CopyTo(instances, 0);
     156            e.Node.Parent.Checked = instances.All(x => x.Checked);
     157          } else {
     158            selectedProblemInstanceProviders[provider].Remove((IDataDescriptor)e.Node.Tag);
     159            e.Node.Parent.Checked = e.Node.Checked;
     160          }
     161        }
     162      }
     163    }
     164
    138165    private void calculateCombinationsButton_Click(object sender, EventArgs e) {
    139       combinationsTextBox.Text = parameterConfigurationTree.GetCombinationCount(0).ToString();
     166      long parameterConfigurationsCnt = parameterConfigurationTree.GetCombinationCount(0);
     167      int problemInstanceCnt = 1 + selectedProblemInstanceProviders.Values.Sum(x => x.Count);
     168      combinationsTextBox.Text = (parameterConfigurationsCnt * problemInstanceCnt).ToString();
    140169    }
    141170
    142171    private void okButton_Click(object sender, System.EventArgs e) {
     172      configurationTabControl.SelectedTab = parameterConfigurationTabPage;
    143173      generation = Task.Factory.StartNew(() => {
    144174        StartProgressView();
     
    146176        if (engineAlgorithm != null) engineAlgorithm.Engine = engine;
    147177        try {
    148           Experiment = createBatchRun ? parameterConfigurationTree.GenerateExperiment(engineAlgorithm, true, repetitions, cts.Token)
    149                                       : parameterConfigurationTree.GenerateExperiment(engineAlgorithm, false, 0, cts.Token);
     178          Experiment = createBatchRun ? parameterConfigurationTree.GenerateExperiment(engineAlgorithm, true, repetitions, selectedProblemInstanceProviders, cts.Token)
     179                                      : parameterConfigurationTree.GenerateExperiment(engineAlgorithm, false, 0, selectedProblemInstanceProviders, cts.Token);
    150180        }
    151181        finally { FinishProgressView(); }
     
    164194      }, TaskContinuationOptions.NotOnRanToCompletion);
    165195    }
     196    #endregion
     197
     198    #region Helpers
     199    private void SetEnabledStateOfControls(bool state) {
     200      createBatchRunCheckBox.Enabled = state;
     201      repetitionsNumericUpDown.Enabled = state;
     202      engineComboBox.Enabled = state;
     203      calculateCombinationsButton.Enabled = state;
     204      okButton.Enabled = state;
     205      cancelButton.Enabled = state;
     206    }
     207
     208    private void UpdateTreeView(IProblemInstanceProvider provider) {
     209      instanceTreeView.Nodes.Clear();
     210      var rootNode = new TreeNode("All") { Tag = provider };
     211      TreeNode[] instances = problemInstanceProviders[provider]
     212                              .Select(x => new TreeNode(x.Name) {
     213                                Tag = x,
     214                                Checked = selectedProblemInstanceProviders.ContainsKey(provider)
     215                                          && selectedProblemInstanceProviders[provider].Contains(x)
     216                              })
     217                              .ToArray();
     218      rootNode.Checked = instances.All(x => x.Checked);
     219      rootNode.Nodes.AddRange(instances);
     220      rootNode.ExpandAll();
     221      instanceTreeView.Nodes.Add(rootNode);
     222    }
     223
     224    private void StartProgressView() {
     225      if (InvokeRequired) {
     226        Invoke(new Action(StartProgressView));
     227      } else {
     228        SetEnabledStateOfControls(false);
     229        problemInstancesTabPage.Enabled = false;
     230        progress.ProgressValue = 0;
     231        progress.ProgressState = ProgressState.Started;
     232      }
     233    }
     234
     235    private void FinishProgressView() {
     236      if (InvokeRequired) {
     237        Invoke(new Action(FinishProgressView));
     238      } else {
     239        progress.Finish();
     240        problemInstancesTabPage.Enabled = true;
     241        SetEnabledStateOfControls(true);
     242      }
     243    }
     244
     245    private void ReportError(Exception e) {
     246      if (InvokeRequired) {
     247        Invoke(new Action<Exception>(ReportError), e);
     248      } else {
     249        ErrorHandling.ShowErrorDialog(this, "An error occurred generating the experiment.", e);
     250      }
     251    }
     252
     253    private void CloseDialog() {
     254      if (InvokeRequired) {
     255        Invoke(new Action(CloseDialog));
     256      } else {
     257        this.DialogResult = DialogResult.OK;
     258        this.Close();
     259      }
     260    }
     261    #endregion
    166262  }
    167263}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views-3.3.csproj

    r8519 r8524  
    8484      <Private>False</Private>
    8585    </Reference>
     86    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     87      <Private>False</Private>
     88    </Reference>
    8689    <Reference Include="System" />
    8790    <Reference Include="System.Core" />
     
    106109      <SubType>Form</SubType>
    107110    </Compile>
    108     <Compile Include="ObjectSelectorDialog.designer.cs">
     111    <Compile Include="ObjectSelectorDialog.Designer.cs">
    109112      <DependentUpon>ObjectSelectorDialog.cs</DependentUpon>
    110113    </Compile>
     
    112115      <SubType>UserControl</SubType>
    113116    </Compile>
    114     <Compile Include="OptimizableView.designer.cs">
     117    <Compile Include="OptimizableView.Designer.cs">
    115118      <DependentUpon>OptimizableView.cs</DependentUpon>
    116119    </Compile>
     
    118121      <SubType>UserControl</SubType>
    119122    </Compile>
    120     <Compile Include="ParameterConfigurationTreeView.designer.cs">
     123    <Compile Include="ParameterConfigurationTreeView.Designer.cs">
    121124      <DependentUpon>ParameterConfigurationTreeView.cs</DependentUpon>
    122125    </Compile>
     
    127130      <SubType>UserControl</SubType>
    128131    </Compile>
    129     <Compile Include="ValueConfigurationViews\RangeView.designer.cs">
     132    <Compile Include="ValueConfigurationViews\RangeView.Designer.cs">
    130133      <DependentUpon>RangeView.cs</DependentUpon>
    131134    </Compile>
     
    133136      <SubType>UserControl</SubType>
    134137    </Compile>
    135     <Compile Include="ValueConfigurationViews\ValueView.designer.cs">
     138    <Compile Include="ValueConfigurationViews\ValueView.Designer.cs">
    136139      <DependentUpon>ValueView.cs</DependentUpon>
    137140    </Compile>
     
    157160</PreBuildEvent>
    158161  </PropertyGroup>
    159   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
     162  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    160163       Other similar extension points exist, see Microsoft.Common.targets.
    161164  <Target Name="BeforeBuild">
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ObjectSelectorDialog.Designer.cs

    r8517 r8524  
    1 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
    223  partial class ObjectSelectorDialog<T> {
    324    /// <summary>
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/OptimizableView.Designer.cs

    r8517 r8524  
    1 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
    223  partial class OptimizableView {
    324    /// <summary>
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ParameterConfigurationTreeView.Designer.cs

    r8517 r8524  
    1 using HeuristicLab.Core.Views;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Core.Views;
    223namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
    324  partial class ParameterConfigurationTreeView {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/Plugin.cs.frame

    r8517 r8524  
    4343  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4444  [PluginDependency("HeuristicLab.Parameters.Views", "3.3")]
     45  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    4546  public class HeuristicLabEncodingsParameterConfigurationEncodingViewsPlugin : PluginBase {
    4647  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ValueConfigurationViews/RangeView.Designer.cs

    r8517 r8524  
    1 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
    223  partial class RangeView {
    324    /// <summary>
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ValueConfigurationViews/ValueView.Designer.cs

    r8518 r8524  
    1 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
    223  partial class ValueView {
    324    /// <summary>
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/HeuristicLab.Encodings.ParameterConfigurationEncoding-3.3.csproj

    r8519 r8524  
    8282      <Private>False</Private>
    8383    </Reference>
     84    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     85      <Private>False</Private>
     86    </Reference>
    8487    <Reference Include="System" />
    8588    <Reference Include="System.Core" />
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurationTree.cs

    r8517 r8524  
    3131using HeuristicLab.Optimization;
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     33using HeuristicLab.Problems.Instances;
    3334
    3435namespace HeuristicLab.Encodings.ParameterConfigurationEncoding {
    35   // todo: storable, name, descr, ...
     36  [Item("ParameterConfigurationTree", "Represents a parameter configuration.")]
    3637  [StorableClass]
    3738  public class ParameterConfigurationTree : ParameterizedValueConfiguration, IEnumerable {
    38 
    3939    [Storable]
    4040    private DoubleValue quality;
     
    180180    }
    181181
    182     #region constructors and cloning
    183     public ParameterConfigurationTree(IAlgorithm algorithm, IProblem problem)
    184       : base(null, algorithm.GetType(), false) {
    185       this.Optimize = false;
    186       this.IsOptimizable = false;
    187       this.parameters = new Dictionary<string, IItem>();
    188       this.Name = algorithm.ItemName;
    189 
    190       var algproblemitem = new AlgorithmProblemItem();
    191       algproblemitem.AlgorithmParameter.Value = algorithm;
    192       algproblemitem.ProblemParameter.Value = problem;
    193       this.discoverValidValues = false;
    194 
    195       this.parameterConfigurations.Add(new SingleValuedParameterConfiguration("Algorithm", algproblemitem.AlgorithmParameter));
    196       this.parameterConfigurations.Add(new SingleValuedParameterConfiguration("Problem", algproblemitem.ProblemParameter));
    197 
    198       // problems can be modified in the list of problem instances, so the parameters which are not Optimize=true,
    199       // must not be modifiable in the parameter configuration tree. otherwise the parameter values would be ambiguous
    200       ProblemConfiguration.ValuesReadOnly = true;
    201     }
    202     public ParameterConfigurationTree() { }
     182    #region Constructors and Cloning
    203183    [StorableConstructor]
    204184    protected ParameterConfigurationTree(bool deserializing) : base(deserializing) { }
     
    225205      }
    226206    }
     207    public ParameterConfigurationTree() : base() { }
     208    public ParameterConfigurationTree(IAlgorithm algorithm, IProblem problem)
     209      : base(null, algorithm.GetType(), false) {
     210      this.Optimize = false;
     211      this.IsOptimizable = false;
     212      this.parameters = new Dictionary<string, IItem>();
     213      this.Name = algorithm.ItemName;
     214
     215      var algproblemitem = new AlgorithmProblemItem();
     216      algproblemitem.AlgorithmParameter.Value = algorithm;
     217      algproblemitem.ProblemParameter.Value = problem;
     218      this.discoverValidValues = false;
     219
     220      this.parameterConfigurations.Add(new SingleValuedParameterConfiguration("Algorithm", algproblemitem.AlgorithmParameter));
     221      this.parameterConfigurations.Add(new SingleValuedParameterConfiguration("Problem", algproblemitem.ProblemParameter));
     222
     223      // problems can be modified in the list of problem instances, so the parameters which are not Optimize=true,
     224      // must not be modifiable in the parameter configuration tree. otherwise the parameter values would be ambiguous
     225      ProblemConfiguration.ValuesReadOnly = true;
     226    }
     227
    227228    public override IDeepCloneable Clone(Cloner cloner) {
    228229      return new ParameterConfigurationTree(this, cloner);
    229230    }
     231
    230232    [StorableHook(HookType.AfterDeserialization)]
    231233    private void AfterDeserialization() {
     
    274276    public override void Parameterize(IParameterizedItem item) {
    275277      this.parameters.Clear();
    276       var algorithm = item as IAlgorithm;
     278      var algorithm = (IAlgorithm)item;
    277279      var problem = algorithm.Problem;
    278280
     
    283285    }
    284286
    285     public Experiment GenerateExperiment(IAlgorithm algorithm, bool createBatchRuns, int repetitions, CancellationToken ct) {
     287    public Experiment GenerateExperiment(IAlgorithm algorithm, bool createBatchRuns, int repetitions, Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> problemInstances, CancellationToken ct) {
    286288      Experiment experiment = new Experiment();
     289      var algorithms = new List<IAlgorithm>(1 + problemInstances.Values.Count) { (IAlgorithm)algorithm.Clone() };
     290      foreach (var provider in problemInstances) {
     291        foreach (var descriptor in provider.Value) {
     292          var alg = (IAlgorithm)algorithm.Clone();
     293          ProblemInstanceManager.LoadData(provider.Key, descriptor, (IProblemInstanceConsumer)alg.Problem);
     294          algorithms.Add(alg);
     295        }
     296      }
    287297      ExperimentGenerationProgress = 0;
    288       foreach (ParameterizedValueConfiguration combination in this) {
    289         ct.ThrowIfCancellationRequested();
    290         IAlgorithm clonedAlg = (IAlgorithm)algorithm.Clone();
    291         clonedAlg.Name = combination.ParameterInfoString;
    292         combination.Parameterize(clonedAlg);
    293         clonedAlg.StoreAlgorithmInEachRun = false;
    294         if (createBatchRuns) {
    295           BatchRun batchRun = new BatchRun(string.Format("BatchRun: {0}", combination.ParameterInfoString));
    296           batchRun.Optimizer = clonedAlg;
    297           batchRun.Repetitions = repetitions;
    298           experiment.Optimizers.Add(batchRun);
    299         } else {
    300           experiment.Optimizers.Add(clonedAlg);
    301         }
    302         ExperimentGenerationProgress = (double)experiment.Optimizers.Count / this.GetCombinationCount(0);
     298      foreach (var alg in algorithms) {
     299        foreach (ParameterizedValueConfiguration combination in this) {
     300          ct.ThrowIfCancellationRequested();
     301          var clonedAlg = (IAlgorithm)alg.Clone();
     302          clonedAlg.Name = combination.ParameterInfoString;
     303          combination.Parameterize(clonedAlg);
     304          clonedAlg.StoreAlgorithmInEachRun = false;
     305          if (createBatchRuns) {
     306            BatchRun batchRun = new BatchRun(string.Format("BatchRun: {0}", combination.ParameterInfoString));
     307            batchRun.Optimizer = clonedAlg;
     308            batchRun.Repetitions = repetitions;
     309            experiment.Optimizers.Add(batchRun);
     310          } else {
     311            experiment.Optimizers.Add(clonedAlg);
     312          }
     313          ExperimentGenerationProgress = (double)experiment.Optimizers.Count / (this.GetCombinationCount(0) * algorithms.Count);
     314        }
    303315      }
    304316      return experiment;
     
    306318
    307319    public Experiment GenerateExperiment(IAlgorithm algorithm) {
    308       return GenerateExperiment(algorithm, false, 0, CancellationToken.None);
     320      return GenerateExperiment(algorithm, false, 0, null, CancellationToken.None);
    309321    }
    310322
    311323    public Experiment GenerateExperiment(IAlgorithm algorithm, bool createBatchRuns, int repetitions) {
    312       return GenerateExperiment(algorithm, createBatchRuns, repetitions, CancellationToken.None);
     324      return GenerateExperiment(algorithm, createBatchRuns, repetitions, null, CancellationToken.None);
    313325    }
    314326
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Plugin.cs.frame

    r8517 r8524  
    3838  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3939  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]
     40  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    4041  public class HeuristicLabEncodingsParameterConfigurationEncodingPlugin : PluginBase {
    4142  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/ValueConfiguration.cs

    r8517 r8524  
    2828
    2929namespace HeuristicLab.Encodings.ParameterConfigurationEncoding {
    30   // TODO: ItemName/Descr, storability
     30  [Item("ValueConfiguration", "Represents a value configuration.")]
    3131  [StorableClass]
    3232  public abstract class ValueConfiguration : NamedItem, IValueConfiguration {
     
    5959          if (value == true && !this.IsOptimizable)
    6060            throw new NotSupportedException("This value is not optimizable.");
    61 
    6261          optimize = value;
    6362          OnOptimizeChanged();
     
    106105
    107106    #region Constructors and Cloning
    108     public ValueConfiguration(IItem value, Type valueDataType) {
    109       this.ActualValue = new ConstrainedValue(value, valueDataType, new ItemSet<IItem> { value }, false);
    110       this.IsOptimizable = true;
    111     }
    112 
    113     public ValueConfiguration() { }
    114107    [StorableConstructor]
    115     protected ValueConfiguration(bool deserializing) { }
     108    protected ValueConfiguration(bool deserializing) : base(deserializing) { }
    116109    protected ValueConfiguration(ValueConfiguration original, Cloner cloner)
    117110      : base(original, cloner) {
     
    122115      this.valuesReadOnly = original.valuesReadOnly;
    123116      RegisterActualValueEvents();
     117    }
     118    protected ValueConfiguration() : base() { }
     119    protected ValueConfiguration(IItem value, Type valueDataType) {
     120      this.ActualValue = new ConstrainedValue(value, valueDataType, new ItemSet<IItem> { value }, false);
     121      this.IsOptimizable = true;
    124122    }
    125123    #endregion
Note: See TracChangeset for help on using the changeset viewer.