Index: /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/ChangeNestingLevelDialog.Designer.cs
===================================================================
--- /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/ChangeNestingLevelDialog.Designer.cs (revision 15323)
+++ /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/ChangeNestingLevelDialog.Designer.cs (revision 15323)
@@ -0,0 +1,146 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.Optimizer {
+ partial class ChangeNestingLevelDialog {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ this.okButton = new System.Windows.Forms.Button();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.nestingLevelNumericUpDownn = new System.Windows.Forms.NumericUpDown();
+ this.nestingLevelLabel = new System.Windows.Forms.Label();
+ this.infoLabel = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.nestingLevelNumericUpDownn)).BeginInit();
+ this.SuspendLayout();
+ //
+ // okButton
+ //
+ this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.okButton.Location = new System.Drawing.Point(124, 130);
+ this.okButton.Name = "okButton";
+ this.okButton.Size = new System.Drawing.Size(75, 23);
+ this.okButton.TabIndex = 0;
+ this.okButton.Text = "&OK";
+ this.okButton.UseVisualStyleBackColor = true;
+ this.okButton.Click += new System.EventHandler(this.okButton_Click);
+ //
+ // cancelButton
+ //
+ this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.cancelButton.Location = new System.Drawing.Point(205, 130);
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.Size = new System.Drawing.Size(75, 23);
+ this.cancelButton.TabIndex = 1;
+ this.cancelButton.Text = "&Cancel";
+ this.cancelButton.UseVisualStyleBackColor = true;
+ //
+ // nestingLevelNumericUpDownn
+ //
+ this.nestingLevelNumericUpDownn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.nestingLevelNumericUpDownn.Location = new System.Drawing.Point(147, 12);
+ this.nestingLevelNumericUpDownn.Name = "nestingLevelNumericUpDownn";
+ this.nestingLevelNumericUpDownn.Size = new System.Drawing.Size(133, 20);
+ this.nestingLevelNumericUpDownn.TabIndex = 2;
+ //
+ // nestingLevelLabel
+ //
+ this.nestingLevelLabel.AutoSize = true;
+ this.nestingLevelLabel.Location = new System.Drawing.Point(12, 14);
+ this.nestingLevelLabel.Name = "nestingLevelLabel";
+ this.nestingLevelLabel.Size = new System.Drawing.Size(116, 13);
+ this.nestingLevelLabel.TabIndex = 3;
+ this.nestingLevelLabel.Text = "Maximum nesting level:";
+ //
+ // infoLabel
+ //
+ this.infoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.infoLabel.Location = new System.Drawing.Point(12, 46);
+ this.infoLabel.Name = "infoLabel";
+ this.infoLabel.Size = new System.Drawing.Size(268, 81);
+ this.infoLabel.TabIndex = 4;
+ this.infoLabel.Text = "A high nesting level of controls can cause problems. A maximum level of 35 is rec" +
+ "ommended. If you are using Windows 10 Creators Update, a maximum nesting level o" +
+ "f 25 is recommended.";
+ //
+ // ChangeNestingLevelDialog
+ //
+ this.AcceptButton = this.okButton;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.cancelButton;
+ this.ClientSize = new System.Drawing.Size(292, 165);
+ this.Controls.Add(this.infoLabel);
+ this.Controls.Add(this.nestingLevelLabel);
+ this.Controls.Add(this.nestingLevelNumericUpDownn);
+ this.Controls.Add(this.cancelButton);
+ this.Controls.Add(this.okButton);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "ChangeNestingLevelDialog";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Change Nesting Level";
+ this.TopMost = true;
+ this.Load += new System.EventHandler(this.ChangeNestingLevelDialog_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.nestingLevelNumericUpDownn)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button okButton;
+ private System.Windows.Forms.Button cancelButton;
+ private System.Windows.Forms.NumericUpDown nestingLevelNumericUpDownn;
+ private System.Windows.Forms.Label nestingLevelLabel;
+ private System.Windows.Forms.Label infoLabel;
+ }
+}
Index: /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/ChangeNestingLevelDialog.cs
===================================================================
--- /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/ChangeNestingLevelDialog.cs (revision 15323)
+++ /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/ChangeNestingLevelDialog.cs (revision 15323)
@@ -0,0 +1,43 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Windows.Forms;
+
+namespace HeuristicLab.Optimizer {
+ public partial class ChangeNestingLevelDialog : Form {
+
+ public ChangeNestingLevelDialog() {
+ InitializeComponent();
+ }
+
+ private void ChangeNestingLevelDialog_Load(object sender, EventArgs e) {
+ var settings = HeuristicLab.Core.Views.Properties.Settings.Default;
+ nestingLevelNumericUpDownn.Value = settings.MaximumNestedControls;
+ }
+
+ private void okButton_Click(object sender, EventArgs e) {
+ var settings = HeuristicLab.Core.Views.Properties.Settings.Default;
+ settings.MaximumNestedControls = (int)nestingLevelNumericUpDownn.Value;
+ settings.Save();
+ }
+ }
+}
Index: /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs
===================================================================
--- /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs (revision 15323)
+++ /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs (revision 15323)
@@ -0,0 +1,509 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.Optimizer {
+ partial class CreateExperimentDialog {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ this.components = new System.ComponentModel.Container();
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CreateExperimentDialog));
+ this.okButton = new System.Windows.Forms.Button();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.createBatchRunCheckBox = new System.Windows.Forms.CheckBox();
+ this.createBatchRunLabel = new System.Windows.Forms.Label();
+ this.repetitionsLabel = new System.Windows.Forms.Label();
+ this.repetitionsNumericUpDown = new System.Windows.Forms.NumericUpDown();
+ this.toolTip = new System.Windows.Forms.ToolTip(this.components);
+ this.experimentCreationBackgroundWorker = new System.ComponentModel.BackgroundWorker();
+ this.instanceDiscoveryProgressBar = new System.Windows.Forms.ProgressBar();
+ this.instanceDiscoveryProgressLabel = new System.Windows.Forms.Label();
+ this.selectAllCheckBox = new System.Windows.Forms.CheckBox();
+ this.selectNoneCheckBox = new System.Windows.Forms.CheckBox();
+ this.instanceDiscoveryBackgroundWorker = new System.ComponentModel.BackgroundWorker();
+ this.tabControl = new System.Windows.Forms.TabControl();
+ this.parametersTabPage = new System.Windows.Forms.TabPage();
+ this.parametersSplitContainer = new System.Windows.Forms.SplitContainer();
+ this.parametersListView = new System.Windows.Forms.ListView();
+ this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.generateButton = new System.Windows.Forms.Button();
+ this.stringConvertibleArrayView = new HeuristicLab.Data.Views.StringConvertibleArrayView();
+ this.detailsTypeLabel = new System.Windows.Forms.Label();
+ this.choicesListView = new System.Windows.Forms.ListView();
+ this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.instancesTabPage = new System.Windows.Forms.TabPage();
+ this.label1 = new System.Windows.Forms.Label();
+ this.instancesTreeView = new System.Windows.Forms.TreeView();
+ this.experimentsToCreateDescriptionLabel = new System.Windows.Forms.Label();
+ this.variationsLabel = new System.Windows.Forms.Label();
+ this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
+ this.warningProvider = new System.Windows.Forms.ErrorProvider(this.components);
+ this.experimentCreationProgressBar = new System.Windows.Forms.ProgressBar();
+ ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
+ this.tabControl.SuspendLayout();
+ this.parametersTabPage.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.parametersSplitContainer)).BeginInit();
+ this.parametersSplitContainer.Panel1.SuspendLayout();
+ this.parametersSplitContainer.Panel2.SuspendLayout();
+ this.parametersSplitContainer.SuspendLayout();
+ this.instancesTabPage.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.warningProvider)).BeginInit();
+ this.SuspendLayout();
+ //
+ // okButton
+ //
+ this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.okButton.Enabled = false;
+ this.okButton.Location = new System.Drawing.Point(246, 377);
+ this.okButton.Name = "okButton";
+ this.okButton.Size = new System.Drawing.Size(75, 23);
+ this.okButton.TabIndex = 7;
+ this.okButton.Text = "&OK";
+ this.okButton.UseVisualStyleBackColor = true;
+ this.okButton.Click += new System.EventHandler(this.okButton_Click);
+ //
+ // cancelButton
+ //
+ this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.cancelButton.Location = new System.Drawing.Point(327, 377);
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.Size = new System.Drawing.Size(75, 23);
+ this.cancelButton.TabIndex = 8;
+ this.cancelButton.Text = "&Cancel";
+ this.cancelButton.UseVisualStyleBackColor = true;
+ //
+ // createBatchRunCheckBox
+ //
+ this.createBatchRunCheckBox.AutoSize = true;
+ this.createBatchRunCheckBox.Checked = true;
+ this.createBatchRunCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.createBatchRunCheckBox.Location = new System.Drawing.Point(113, 8);
+ this.createBatchRunCheckBox.Name = "createBatchRunCheckBox";
+ this.createBatchRunCheckBox.Size = new System.Drawing.Size(15, 14);
+ this.createBatchRunCheckBox.TabIndex = 1;
+ this.toolTip.SetToolTip(this.createBatchRunCheckBox, "Check to create a batch run for executing an optimizer multiple times.");
+ this.createBatchRunCheckBox.UseVisualStyleBackColor = true;
+ this.createBatchRunCheckBox.CheckedChanged += new System.EventHandler(this.createBatchRunCheckBox_CheckedChanged);
+ //
+ // createBatchRunLabel
+ //
+ this.createBatchRunLabel.AutoSize = true;
+ this.createBatchRunLabel.Location = new System.Drawing.Point(12, 9);
+ this.createBatchRunLabel.Name = "createBatchRunLabel";
+ this.createBatchRunLabel.Size = new System.Drawing.Size(95, 13);
+ this.createBatchRunLabel.TabIndex = 0;
+ this.createBatchRunLabel.Text = "&Create Batch Run:";
+ //
+ // repetitionsLabel
+ //
+ this.repetitionsLabel.AutoSize = true;
+ this.repetitionsLabel.Location = new System.Drawing.Point(12, 31);
+ this.repetitionsLabel.Name = "repetitionsLabel";
+ this.repetitionsLabel.Size = new System.Drawing.Size(63, 13);
+ this.repetitionsLabel.TabIndex = 2;
+ this.repetitionsLabel.Text = "&Repetitions:";
+ //
+ // repetitionsNumericUpDown
+ //
+ this.repetitionsNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.repetitionsNumericUpDown.Location = new System.Drawing.Point(113, 28);
+ this.repetitionsNumericUpDown.Maximum = new decimal(new int[] {
+ 1000000,
+ 0,
+ 0,
+ 0});
+ this.repetitionsNumericUpDown.Minimum = new decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 0});
+ this.repetitionsNumericUpDown.Name = "repetitionsNumericUpDown";
+ this.repetitionsNumericUpDown.Size = new System.Drawing.Size(289, 20);
+ this.repetitionsNumericUpDown.TabIndex = 3;
+ this.repetitionsNumericUpDown.ThousandsSeparator = true;
+ this.toolTip.SetToolTip(this.repetitionsNumericUpDown, "Number of repetitions executed by the batch run.");
+ this.repetitionsNumericUpDown.Value = new decimal(new int[] {
+ 10,
+ 0,
+ 0,
+ 0});
+ this.repetitionsNumericUpDown.Validated += new System.EventHandler(this.repetitionsNumericUpDown_Validated);
+ //
+ // experimentCreationBackgroundWorker
+ //
+ this.experimentCreationBackgroundWorker.WorkerReportsProgress = true;
+ this.experimentCreationBackgroundWorker.WorkerSupportsCancellation = true;
+ this.experimentCreationBackgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.experimentCreationBackgroundWorker_DoWork);
+ this.experimentCreationBackgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.experimentCreationBackgroundWorker_ProgressChanged);
+ this.experimentCreationBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.experimentCreationBackgroundWorker_RunWorkerCompleted);
+ //
+ // instanceDiscoveryProgressBar
+ //
+ this.instanceDiscoveryProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
+ this.instanceDiscoveryProgressBar.Location = new System.Drawing.Point(6, 141);
+ this.instanceDiscoveryProgressBar.Name = "instanceDiscoveryProgressBar";
+ this.instanceDiscoveryProgressBar.Size = new System.Drawing.Size(367, 23);
+ this.instanceDiscoveryProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
+ this.instanceDiscoveryProgressBar.TabIndex = 4;
+ this.instanceDiscoveryProgressBar.Visible = false;
+ //
+ // instanceDiscoveryProgressLabel
+ //
+ this.instanceDiscoveryProgressLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
+ this.instanceDiscoveryProgressLabel.BackColor = System.Drawing.SystemColors.Control;
+ this.instanceDiscoveryProgressLabel.Location = new System.Drawing.Point(6, 167);
+ this.instanceDiscoveryProgressLabel.Name = "instanceDiscoveryProgressLabel";
+ this.instanceDiscoveryProgressLabel.Size = new System.Drawing.Size(367, 23);
+ this.instanceDiscoveryProgressLabel.TabIndex = 5;
+ this.instanceDiscoveryProgressLabel.Text = "label1";
+ this.instanceDiscoveryProgressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.instanceDiscoveryProgressLabel.Visible = false;
+ //
+ // selectAllCheckBox
+ //
+ this.selectAllCheckBox.AutoSize = true;
+ this.selectAllCheckBox.Location = new System.Drawing.Point(52, 12);
+ this.selectAllCheckBox.Name = "selectAllCheckBox";
+ this.selectAllCheckBox.Size = new System.Drawing.Size(36, 17);
+ this.selectAllCheckBox.TabIndex = 1;
+ this.selectAllCheckBox.Text = "all";
+ this.selectAllCheckBox.UseVisualStyleBackColor = true;
+ this.selectAllCheckBox.CheckedChanged += new System.EventHandler(this.selectAllCheckBox_CheckedChanged);
+ //
+ // selectNoneCheckBox
+ //
+ this.selectNoneCheckBox.AutoSize = true;
+ this.selectNoneCheckBox.Location = new System.Drawing.Point(94, 12);
+ this.selectNoneCheckBox.Name = "selectNoneCheckBox";
+ this.selectNoneCheckBox.Size = new System.Drawing.Size(50, 17);
+ this.selectNoneCheckBox.TabIndex = 2;
+ this.selectNoneCheckBox.Text = "none";
+ this.selectNoneCheckBox.UseVisualStyleBackColor = true;
+ this.selectNoneCheckBox.CheckedChanged += new System.EventHandler(this.selectNoneCheckBox_CheckedChanged);
+ //
+ // instanceDiscoveryBackgroundWorker
+ //
+ this.instanceDiscoveryBackgroundWorker.WorkerReportsProgress = true;
+ this.instanceDiscoveryBackgroundWorker.WorkerSupportsCancellation = true;
+ this.instanceDiscoveryBackgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.instanceDiscoveryBackgroundWorker_DoWork);
+ this.instanceDiscoveryBackgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.instanceDiscoveryBackgroundWorker_ProgressChanged);
+ this.instanceDiscoveryBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.instanceDiscoveryBackgroundWorker_RunWorkerCompleted);
+ //
+ // tabControl
+ //
+ this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tabControl.Controls.Add(this.parametersTabPage);
+ this.tabControl.Controls.Add(this.instancesTabPage);
+ this.tabControl.Location = new System.Drawing.Point(15, 54);
+ this.tabControl.Name = "tabControl";
+ this.tabControl.SelectedIndex = 0;
+ this.tabControl.Size = new System.Drawing.Size(387, 317);
+ this.tabControl.TabIndex = 4;
+ //
+ // parametersTabPage
+ //
+ this.parametersTabPage.Controls.Add(this.parametersSplitContainer);
+ this.parametersTabPage.Location = new System.Drawing.Point(4, 22);
+ this.parametersTabPage.Name = "parametersTabPage";
+ this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3);
+ this.parametersTabPage.Size = new System.Drawing.Size(379, 291);
+ this.parametersTabPage.TabIndex = 1;
+ this.parametersTabPage.Text = "Parameter Variations";
+ this.parametersTabPage.UseVisualStyleBackColor = true;
+ //
+ // parametersSplitContainer
+ //
+ this.parametersSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.parametersSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
+ this.parametersSplitContainer.Location = new System.Drawing.Point(3, 3);
+ this.parametersSplitContainer.Name = "parametersSplitContainer";
+ //
+ // parametersSplitContainer.Panel1
+ //
+ this.parametersSplitContainer.Panel1.Controls.Add(this.parametersListView);
+ //
+ // parametersSplitContainer.Panel2
+ //
+ this.parametersSplitContainer.Panel2.Controls.Add(this.generateButton);
+ this.parametersSplitContainer.Panel2.Controls.Add(this.stringConvertibleArrayView);
+ this.parametersSplitContainer.Panel2.Controls.Add(this.detailsTypeLabel);
+ this.parametersSplitContainer.Panel2.Controls.Add(this.choicesListView);
+ this.parametersSplitContainer.Size = new System.Drawing.Size(373, 285);
+ this.parametersSplitContainer.SplitterDistance = 155;
+ this.parametersSplitContainer.TabIndex = 1;
+ //
+ // parametersListView
+ //
+ this.parametersListView.CheckBoxes = true;
+ this.parametersListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.columnHeader1});
+ this.parametersListView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.parametersListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
+ this.parametersListView.Location = new System.Drawing.Point(0, 0);
+ this.parametersListView.MultiSelect = false;
+ this.parametersListView.Name = "parametersListView";
+ this.parametersListView.ShowItemToolTips = true;
+ this.parametersListView.Size = new System.Drawing.Size(155, 285);
+ this.parametersListView.TabIndex = 0;
+ this.parametersListView.UseCompatibleStateImageBehavior = false;
+ this.parametersListView.View = System.Windows.Forms.View.Details;
+ this.parametersListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.parametersListView_ItemChecked);
+ this.parametersListView.SelectedIndexChanged += new System.EventHandler(this.parametersListView_SelectedIndexChanged);
+ //
+ // columnHeader1
+ //
+ this.columnHeader1.Width = 150;
+ //
+ // generateButton
+ //
+ this.generateButton.Location = new System.Drawing.Point(16, 10);
+ this.generateButton.Name = "generateButton";
+ this.generateButton.Size = new System.Drawing.Size(75, 23);
+ this.generateButton.TabIndex = 8;
+ this.generateButton.Text = "Generate...";
+ this.generateButton.UseVisualStyleBackColor = true;
+ this.generateButton.Click += new System.EventHandler(this.generateButton_Click);
+ //
+ // stringConvertibleArrayView
+ //
+ this.stringConvertibleArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.stringConvertibleArrayView.Caption = "StringConvertibleArray View";
+ this.stringConvertibleArrayView.Content = null;
+ this.stringConvertibleArrayView.Location = new System.Drawing.Point(16, 39);
+ this.stringConvertibleArrayView.Name = "stringConvertibleArrayView";
+ this.stringConvertibleArrayView.ReadOnly = false;
+ this.stringConvertibleArrayView.Size = new System.Drawing.Size(183, 233);
+ this.stringConvertibleArrayView.TabIndex = 7;
+ //
+ // detailsTypeLabel
+ //
+ this.detailsTypeLabel.AutoSize = true;
+ this.detailsTypeLabel.Location = new System.Drawing.Point(13, 15);
+ this.detailsTypeLabel.Name = "detailsTypeLabel";
+ this.detailsTypeLabel.Size = new System.Drawing.Size(48, 13);
+ this.detailsTypeLabel.TabIndex = 0;
+ this.detailsTypeLabel.Text = "Choices:";
+ //
+ // choicesListView
+ //
+ this.choicesListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.choicesListView.CheckBoxes = true;
+ this.choicesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.columnHeader2});
+ this.choicesListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
+ this.choicesListView.Location = new System.Drawing.Point(16, 34);
+ this.choicesListView.Name = "choicesListView";
+ this.choicesListView.Size = new System.Drawing.Size(183, 238);
+ this.choicesListView.TabIndex = 6;
+ this.choicesListView.UseCompatibleStateImageBehavior = false;
+ this.choicesListView.View = System.Windows.Forms.View.Details;
+ this.choicesListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.choiceListView_ItemChecked);
+ //
+ // columnHeader2
+ //
+ this.columnHeader2.Width = 150;
+ //
+ // instancesTabPage
+ //
+ this.instancesTabPage.Controls.Add(this.label1);
+ this.instancesTabPage.Controls.Add(this.instanceDiscoveryProgressBar);
+ this.instancesTabPage.Controls.Add(this.selectNoneCheckBox);
+ this.instancesTabPage.Controls.Add(this.instanceDiscoveryProgressLabel);
+ this.instancesTabPage.Controls.Add(this.selectAllCheckBox);
+ this.instancesTabPage.Controls.Add(this.instancesTreeView);
+ this.instancesTabPage.Location = new System.Drawing.Point(4, 22);
+ this.instancesTabPage.Name = "instancesTabPage";
+ this.instancesTabPage.Padding = new System.Windows.Forms.Padding(3);
+ this.instancesTabPage.Size = new System.Drawing.Size(379, 291);
+ this.instancesTabPage.TabIndex = 0;
+ this.instancesTabPage.Text = "Problem Instances";
+ this.instancesTabPage.UseVisualStyleBackColor = true;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(6, 13);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(40, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Select:";
+ //
+ // instancesTreeView
+ //
+ this.instancesTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.instancesTreeView.CheckBoxes = true;
+ this.instancesTreeView.Location = new System.Drawing.Point(6, 35);
+ this.instancesTreeView.Name = "instancesTreeView";
+ this.instancesTreeView.Size = new System.Drawing.Size(367, 250);
+ this.instancesTreeView.TabIndex = 6;
+ this.instancesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.instancesTreeView_AfterCheck);
+ //
+ // experimentsToCreateDescriptionLabel
+ //
+ this.experimentsToCreateDescriptionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.experimentsToCreateDescriptionLabel.AutoSize = true;
+ this.experimentsToCreateDescriptionLabel.Location = new System.Drawing.Point(12, 382);
+ this.experimentsToCreateDescriptionLabel.Name = "experimentsToCreateDescriptionLabel";
+ this.experimentsToCreateDescriptionLabel.Size = new System.Drawing.Size(56, 13);
+ this.experimentsToCreateDescriptionLabel.TabIndex = 5;
+ this.experimentsToCreateDescriptionLabel.Text = "Variations:";
+ //
+ // variationsLabel
+ //
+ this.variationsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.variationsLabel.AutoSize = true;
+ this.variationsLabel.Location = new System.Drawing.Point(74, 382);
+ this.variationsLabel.Name = "variationsLabel";
+ this.variationsLabel.Size = new System.Drawing.Size(13, 13);
+ this.variationsLabel.TabIndex = 6;
+ this.variationsLabel.Text = "1";
+ this.variationsLabel.TextChanged += new System.EventHandler(this.experimentsLabel_TextChanged);
+ //
+ // errorProvider
+ //
+ this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+ this.errorProvider.ContainerControl = this;
+ //
+ // warningProvider
+ //
+ this.warningProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+ this.warningProvider.ContainerControl = this;
+ this.warningProvider.Icon = ((System.Drawing.Icon)(resources.GetObject("warningProvider.Icon")));
+ //
+ // experimentCreationProgressBar
+ //
+ this.experimentCreationProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.experimentCreationProgressBar.Location = new System.Drawing.Point(187, 377);
+ this.experimentCreationProgressBar.Name = "experimentCreationProgressBar";
+ this.experimentCreationProgressBar.Size = new System.Drawing.Size(134, 23);
+ this.experimentCreationProgressBar.TabIndex = 9;
+ this.experimentCreationProgressBar.Visible = false;
+ //
+ // CreateExperimentDialog
+ //
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
+ this.CancelButton = this.cancelButton;
+ this.ClientSize = new System.Drawing.Size(414, 412);
+ this.Controls.Add(this.experimentCreationProgressBar);
+ this.Controls.Add(this.variationsLabel);
+ this.Controls.Add(this.experimentsToCreateDescriptionLabel);
+ this.Controls.Add(this.tabControl);
+ this.Controls.Add(this.repetitionsNumericUpDown);
+ this.Controls.Add(this.repetitionsLabel);
+ this.Controls.Add(this.createBatchRunLabel);
+ this.Controls.Add(this.createBatchRunCheckBox);
+ this.Controls.Add(this.cancelButton);
+ this.Controls.Add(this.okButton);
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "CreateExperimentDialog";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Create Experiment";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CreateExperimentDialog_FormClosing);
+ this.Load += new System.EventHandler(this.CreateExperimentDialog_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
+ this.tabControl.ResumeLayout(false);
+ this.parametersTabPage.ResumeLayout(false);
+ this.parametersSplitContainer.Panel1.ResumeLayout(false);
+ this.parametersSplitContainer.Panel2.ResumeLayout(false);
+ this.parametersSplitContainer.Panel2.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.parametersSplitContainer)).EndInit();
+ this.parametersSplitContainer.ResumeLayout(false);
+ this.instancesTabPage.ResumeLayout(false);
+ this.instancesTabPage.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.warningProvider)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button okButton;
+ private System.Windows.Forms.Button cancelButton;
+ private System.Windows.Forms.CheckBox createBatchRunCheckBox;
+ private System.Windows.Forms.Label createBatchRunLabel;
+ private System.Windows.Forms.Label repetitionsLabel;
+ private System.Windows.Forms.NumericUpDown repetitionsNumericUpDown;
+ private System.Windows.Forms.ToolTip toolTip;
+ private System.ComponentModel.BackgroundWorker experimentCreationBackgroundWorker;
+ private System.Windows.Forms.ProgressBar instanceDiscoveryProgressBar;
+ private System.Windows.Forms.Label instanceDiscoveryProgressLabel;
+ private System.Windows.Forms.CheckBox selectAllCheckBox;
+ private System.Windows.Forms.CheckBox selectNoneCheckBox;
+ private System.ComponentModel.BackgroundWorker instanceDiscoveryBackgroundWorker;
+ private System.Windows.Forms.TabControl tabControl;
+ private System.Windows.Forms.TabPage parametersTabPage;
+ private System.Windows.Forms.TabPage instancesTabPage;
+ private System.Windows.Forms.SplitContainer parametersSplitContainer;
+ private System.Windows.Forms.ListView parametersListView;
+ private System.Windows.Forms.ColumnHeader columnHeader1;
+ private System.Windows.Forms.Label experimentsToCreateDescriptionLabel;
+ private System.Windows.Forms.Label variationsLabel;
+ private System.Windows.Forms.Label detailsTypeLabel;
+ private System.Windows.Forms.ListView choicesListView;
+ private System.Windows.Forms.ColumnHeader columnHeader2;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.ErrorProvider errorProvider;
+ private System.Windows.Forms.ErrorProvider warningProvider;
+ private System.Windows.Forms.TreeView instancesTreeView;
+ private Data.Views.StringConvertibleArrayView stringConvertibleArrayView;
+ private System.Windows.Forms.ProgressBar experimentCreationProgressBar;
+ private System.Windows.Forms.Button generateButton;
+
+ }
+}
Index: /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs
===================================================================
--- /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs (revision 15323)
+++ /branches/SimplifierViewsProgress/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs (revision 15323)
@@ -0,0 +1,959 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.MainForm.WindowsForms;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Problems.Instances;
+
+namespace HeuristicLab.Optimizer {
+ public partial class CreateExperimentDialog : Form {
+ private enum DialogMode { Normal = 1, DiscoveringInstances = 2, CreatingExperiment = 3, PreparingExperiment = 4 };
+
+ private IOptimizer optimizer;
+ public IOptimizer Optimizer {
+ get { return optimizer; }
+ set {
+ optimizer = value;
+ Experiment = null;
+ okButton.Enabled = optimizer != null;
+ SetTabControlVisibility();
+ FillInstanceTreeViewAsync();
+ FillParametersListView();
+ }
+ }
+
+ public Experiment Experiment { get; private set; }
+
+ private bool createBatchRun;
+ private int repetitions;
+ private readonly Dictionary> instances;
+ private readonly Dictionary intParameters;
+ private readonly Dictionary doubleParameters;
+ private readonly HashSet boolParameters;
+ private readonly Dictionary> multipleChoiceParameters;
+ private readonly IItem optionalNullChoice = new BoolValue(); // any item will do
+
+ private StringBuilder failedInstances;
+ private bool suppressTreeViewEventHandling, suppressCheckAllNoneEventHandling;
+
+ public CreateExperimentDialog() : this(null) { }
+ public CreateExperimentDialog(IOptimizer optimizer) {
+ InitializeComponent();
+ instanceDiscoveryProgressLabel.BackColor = instancesTabPage.BackColor;
+ createBatchRun = createBatchRunCheckBox.Checked;
+ repetitions = (int)repetitionsNumericUpDown.Value;
+ // do not set the Optimizer property here, because we want to delay instance discovery to the time when the form loads
+ this.optimizer = optimizer;
+ Experiment = null;
+ okButton.Enabled = optimizer != null;
+
+ instances = new Dictionary>();
+ intParameters = new Dictionary();
+ doubleParameters = new Dictionary();
+ boolParameters = new HashSet();
+ multipleChoiceParameters = new Dictionary>();
+ }
+
+ #region Event handlers
+ private void CreateExperimentDialog_Load(object sender, EventArgs e) {
+ SetTabControlVisibility();
+ FillInstanceTreeViewAsync();
+ FillParametersListView();
+ }
+
+ private void CreateExperimentDialog_FormClosing(object sender, FormClosingEventArgs e) {
+ if (experimentCreationBackgroundWorker.IsBusy) {
+ if (DialogResult != System.Windows.Forms.DialogResult.OK) {
+ if (experimentCreationBackgroundWorker.IsBusy) experimentCreationBackgroundWorker.CancelAsync();
+ if (instanceDiscoveryBackgroundWorker.IsBusy) instanceDiscoveryBackgroundWorker.CancelAsync();
+ }
+ e.Cancel = true;
+ }
+ }
+
+ private void okButton_Click(object sender, EventArgs e) {
+ SetMode(DialogMode.CreatingExperiment);
+ experimentCreationBackgroundWorker.RunWorkerAsync();
+ }
+
+ #region Parameters variation
+ private void parametersListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
+ var parameter = (IValueParameter)e.Item.Tag;
+ var isConstrainedValueParameter = typeof(OptionalConstrainedValueParameter<>).Equals(parameter.GetType().GetGenericTypeDefinition())
+ || typeof(ConstrainedValueParameter<>).Equals(parameter.GetType().GetGenericTypeDefinition());
+
+ if (!isConstrainedValueParameter && parameter.Value == null) {
+ if (e.Item.Checked) e.Item.Checked = false;
+ return;
+ }
+
+ if (isConstrainedValueParameter) {
+ if (e.Item.Checked) multipleChoiceParameters.Add(parameter, new HashSet());
+ else multipleChoiceParameters.Remove(parameter);
+ } else {
+
+ var intValue = parameter.Value as ValueTypeValue;
+ if (intValue != null) {
+ if (e.Item.Checked) {
+ IntArray initialValues;
+ if (intValue.Value == int.MinValue)
+ initialValues = new IntArray(new int[] { -100, -50, 5 });
+ else if (intValue.Value == int.MaxValue)
+ initialValues = new IntArray(new int[] { 5, 50, 100 });
+ else if (intValue.Value == 0)
+ initialValues = new IntArray(new int[] { 0, 1, 2 });
+ else if (Math.Abs(intValue.Value) < 10)
+ initialValues = new IntArray(new int[] { intValue.Value - 1, intValue.Value, intValue.Value + 1 });
+ else initialValues = new IntArray(new int[] { intValue.Value / 2, intValue.Value, intValue.Value * 2 });
+ intParameters.Add(parameter, initialValues);
+ intParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
+ } else intParameters.Remove(parameter);
+ }
+
+ var doubleValue = parameter.Value as ValueTypeValue;
+ if (doubleValue != null) {
+ if (e.Item.Checked) {
+ DoubleArray initialValues;
+ if (doubleValue.Value == double.MinValue)
+ initialValues = new DoubleArray(new double[] { -1, -0.5, 0 });
+ else if (doubleValue.Value == double.MaxValue)
+ initialValues = new DoubleArray(new double[] { 0, 0.5, 1 });
+ else if (doubleValue.Value == 0.0)
+ initialValues = new DoubleArray(new double[] { 0, 0.1, 0.2 });
+ else if (Math.Abs(doubleValue.Value) <= 1.0) {
+ if (doubleValue.Value > 0.9 || (doubleValue.Value < 0.0 && doubleValue.Value > -0.1))
+ initialValues = new DoubleArray(new double[] { doubleValue.Value - 0.2, doubleValue.Value - 0.1, doubleValue.Value });
+ else if (doubleValue.Value < -0.9 || (doubleValue.Value > 0 && doubleValue.Value < 0.1))
+ initialValues = new DoubleArray(new double[] { doubleValue.Value, doubleValue.Value + 0.1, doubleValue.Value + 0.2 });
+ else initialValues = new DoubleArray(new double[] { doubleValue.Value - 0.1, doubleValue.Value, doubleValue.Value + 0.1 });
+ } else initialValues = new DoubleArray(new double[] { doubleValue.Value / 2.0, doubleValue.Value, doubleValue.Value * 2.0 });
+ doubleParameters.Add(parameter, initialValues);
+ doubleParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
+ } else doubleParameters.Remove(parameter);
+ }
+
+ var boolValue = parameter.Value as ValueTypeValue;
+ if (boolValue != null) {
+ if (e.Item.Checked) boolParameters.Add(parameter);
+ else boolParameters.Remove(parameter);
+ }
+
+ bool isEnumValue = parameter.Value != null && parameter.Value.GetType().IsGenericType
+ && typeof(EnumValue<>).IsAssignableFrom(parameter.Value.GetType().GetGenericTypeDefinition());
+ if (isEnumValue) {
+ if (e.Item.Checked) multipleChoiceParameters.Add(parameter, new HashSet(new EnumValueEqualityComparer()));
+ else multipleChoiceParameters.Remove(parameter);
+ }
+ }
+
+ UpdateVariationsLabel();
+ if (e.Item.Selected) UpdateDetailsView(parameter);
+ else e.Item.Selected = true;
+ }
+
+ private void parametersListView_SelectedIndexChanged(object sender, EventArgs e) {
+ if (parametersListView.SelectedItems.Count == 0) {
+ ClearDetailsView();
+ } else {
+ var parameter = parametersListView.SelectedItems[0].Tag as IValueParameter;
+ UpdateDetailsView(parameter);
+ }
+ }
+
+ private void UpdateDetailsView(IValueParameter parameter) {
+ ClearDetailsView();
+
+ var isOptionalConstrainedValueParameter = typeof(OptionalConstrainedValueParameter<>).IsAssignableFrom(parameter.GetType().GetGenericTypeDefinition());
+ var isConstrainedValueParameter =
+ isOptionalConstrainedValueParameter
+ || typeof(ConstrainedValueParameter<>).Equals(parameter.GetType().GetGenericTypeDefinition());
+ bool isEnumValue = parameter.Value != null && parameter.Value.GetType().IsGenericType
+ && typeof(EnumValue<>).IsAssignableFrom(parameter.Value.GetType().GetGenericTypeDefinition());
+
+ if (isConstrainedValueParameter || isEnumValue) {
+ detailsTypeLabel.Text = "Choices:";
+ choicesListView.Tag = parameter;
+
+ if (isConstrainedValueParameter) {
+ if (isOptionalConstrainedValueParameter) {
+ choicesListView.Items.Add(new ListViewItem("-") {
+ Tag = optionalNullChoice,
+ Checked = multipleChoiceParameters.ContainsKey(parameter)
+ && multipleChoiceParameters[parameter].Contains(optionalNullChoice)
+ });
+ }
+ dynamic constrainedValuedParameter = parameter;
+ dynamic validValues = constrainedValuedParameter.ValidValues;
+ foreach (var choice in validValues) {
+ choicesListView.Items.Add(new ListViewItem(choice.ToString()) {
+ Tag = choice,
+ Checked = multipleChoiceParameters.ContainsKey(parameter)
+ && multipleChoiceParameters[parameter].Contains(choice)
+ });
+ }
+ }
+ if (isEnumValue) {
+ var enumType = parameter.Value.GetType().GetGenericArguments()[0];
+ var enumValueType = typeof(EnumValue<>).MakeGenericType(enumType);
+ foreach (var enumChoice in Enum.GetValues(enumType)) {
+ choicesListView.Items.Add(new ListViewItem(enumChoice.ToString()) {
+ Tag = Activator.CreateInstance(enumValueType, enumChoice),
+ Checked = multipleChoiceParameters.ContainsKey(parameter)
+ && multipleChoiceParameters[parameter].Any((dynamic item) => item.Value.Equals(enumChoice))
+ });
+ }
+ }
+ choicesListView.Enabled = multipleChoiceParameters.ContainsKey(parameter);
+ detailsTypeLabel.Visible = true;
+ choicesListView.Visible = true;
+ return;
+ }
+
+ if (parameter.Value is ValueTypeValue) {
+ detailsTypeLabel.Text = "Boolean parameter: True / False";
+ detailsTypeLabel.Visible = true;
+ }
+
+ var intValue = parameter.Value as ValueTypeValue;
+ if (intValue != null) {
+ if (intParameters.ContainsKey(parameter))
+ stringConvertibleArrayView.Content = intParameters[parameter];
+ stringConvertibleArrayView.Visible = true;
+ stringConvertibleArrayView.ReadOnly = !intParameters.ContainsKey(parameter);
+ generateButton.Tag = parameter;
+ generateButton.Enabled = intParameters.ContainsKey(parameter);
+ generateButton.Visible = true;
+ return;
+ }
+
+ var doubleValue = parameter.Value as ValueTypeValue;
+ if (doubleValue != null) {
+ if (doubleParameters.ContainsKey(parameter))
+ stringConvertibleArrayView.Content = doubleParameters[parameter];
+ stringConvertibleArrayView.Visible = true;
+ stringConvertibleArrayView.ReadOnly = !doubleParameters.ContainsKey(parameter);
+ generateButton.Tag = parameter;
+ generateButton.Enabled = doubleParameters.ContainsKey(parameter);
+ generateButton.Visible = true;
+ return;
+ }
+ }
+
+ #region Detail controls
+ private void choiceListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
+ var parameter = (IValueParameter)choicesListView.Tag;
+ if (multipleChoiceParameters.ContainsKey(parameter)) {
+ if (e.Item.Checked) {
+ multipleChoiceParameters[parameter].Add((IItem)e.Item.Tag);
+ } else multipleChoiceParameters[parameter].Remove((IItem)e.Item.Tag);
+
+ UpdateVariationsLabel();
+ }
+ }
+
+ private void generateButton_Click(object sender, EventArgs e) {
+ var parameter = (IValueParameter)generateButton.Tag;
+ bool integerOnly = intParameters.ContainsKey(parameter);
+ decimal min = 0, max = 1, step = 1;
+ #region Try to calculate some meaningful values
+ if (integerOnly) {
+ int len = intParameters[parameter].Length;
+ if (len > 0) {
+ min = intParameters[parameter].Min();
+ max = intParameters[parameter].Max();
+ step = len >= 2 ? Math.Abs((intParameters[parameter][len - 1] - intParameters[parameter][len - 2])) : 1;
+ }
+ } else {
+ int len = doubleParameters[parameter].Length;
+ if (len > 0) {
+ min = (decimal)doubleParameters[parameter].Min();
+ max = (decimal)doubleParameters[parameter].Max();
+ step = len >= 2 ? Math.Abs(((decimal)doubleParameters[parameter][len - 1] - (decimal)doubleParameters[parameter][len - 2])) : 1m;
+ }
+ }
+ #endregion
+ using (var dialog = new DefineArithmeticProgressionDialog(integerOnly, min, max, step)) {
+ if (dialog.ShowDialog(this) == DialogResult.OK) {
+ var values = dialog.Values;
+ if (integerOnly) {
+ intParameters[parameter].Reset -= new EventHandler(ValuesArray_Reset);
+ intParameters[parameter] = new IntArray(values.Select(x => (int)x).ToArray());
+ intParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
+ stringConvertibleArrayView.Content = intParameters[parameter];
+ } else {
+ doubleParameters[parameter].Reset -= new EventHandler(ValuesArray_Reset);
+ doubleParameters[parameter] = new DoubleArray(values.Select(x => (double)x).ToArray());
+ doubleParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
+ stringConvertibleArrayView.Content = doubleParameters[parameter];
+ }
+ UpdateVariationsLabel();
+ }
+ }
+ }
+
+ private void ValuesArray_Reset(object sender, EventArgs e) {
+ UpdateVariationsLabel();
+ }
+ #endregion
+ #endregion
+
+ #region Instances
+ private void instancesTreeView_AfterCheck(object sender, TreeViewEventArgs e) {
+ if (!suppressTreeViewEventHandling) {
+ if (e.Node.Nodes.Count > 0) { // provider node was (un)checked
+ SyncProviderNode(e.Node);
+ } else { // descriptor node was (un)checked
+ SyncInstanceNode(e.Node);
+ }
+
+ suppressCheckAllNoneEventHandling = true;
+ try {
+ var treeViewNodes = instancesTreeView.Nodes.OfType().SelectMany(x => x.Nodes.OfType());
+ selectAllCheckBox.Checked = treeViewNodes.Count() == instances.SelectMany(x => x.Value).Count();
+ selectNoneCheckBox.Checked = !treeViewNodes.Any(x => x.Checked);
+ }
+ finally { suppressCheckAllNoneEventHandling = false; }
+ UpdateVariationsLabel();
+ }
+ }
+
+ private void SyncProviderNode(TreeNode node) {
+ suppressTreeViewEventHandling = true;
+ try {
+ foreach (TreeNode n in node.Nodes) {
+ if (n.Checked != node.Checked) {
+ n.Checked = node.Checked;
+ SyncInstanceNode(n, false);
+ }
+ }
+ }
+ finally { suppressTreeViewEventHandling = false; }
+ }
+
+ private void SyncInstanceNode(TreeNode node, bool providerCheck = true) {
+ var provider = (IProblemInstanceProvider)node.Parent.Tag;
+ var descriptor = (IDataDescriptor)node.Tag;
+ if (node.Checked) {
+ if (!instances.ContainsKey(provider))
+ instances.Add(provider, new HashSet());
+ instances[provider].Add(descriptor);
+ } else {
+ if (instances.ContainsKey(provider)) {
+ instances[provider].Remove(descriptor);
+ if (instances[provider].Count == 0)
+ instances.Remove(provider);
+ }
+ }
+ if (providerCheck) {
+ bool allChecked = node.Parent.Nodes.OfType().All(x => x.Checked);
+ suppressTreeViewEventHandling = true;
+ try {
+ node.Parent.Checked = allChecked;
+ }
+ finally { suppressTreeViewEventHandling = false; }
+ }
+ }
+
+ private void selectAllCheckBox_CheckedChanged(object sender, EventArgs e) {
+ if (!suppressCheckAllNoneEventHandling) {
+ if (selectAllCheckBox.Checked) {
+ suppressCheckAllNoneEventHandling = true;
+ try { selectNoneCheckBox.Checked = false; }
+ finally { suppressCheckAllNoneEventHandling = false; }
+ try {
+ suppressTreeViewEventHandling = true;
+ foreach (TreeNode node in instancesTreeView.Nodes) {
+ if (!node.Checked) {
+ node.Checked = true;
+ SyncProviderNode(node);
+ }
+ }
+ }
+ finally { suppressTreeViewEventHandling = false; }
+ }
+ UpdateVariationsLabel();
+ }
+ }
+
+ private void selectNoneCheckBox_CheckedChanged(object sender, EventArgs e) {
+ if (!suppressCheckAllNoneEventHandling) {
+ if (selectNoneCheckBox.Checked) {
+ suppressCheckAllNoneEventHandling = true;
+ try { selectAllCheckBox.Checked = false; }
+ finally { suppressCheckAllNoneEventHandling = false; }
+ try {
+ suppressTreeViewEventHandling = true;
+ foreach (TreeNode node in instancesTreeView.Nodes) {
+ if (node.Checked) {
+ node.Checked = false;
+ SyncProviderNode(node);
+ }
+ }
+ }
+ finally { suppressTreeViewEventHandling = false; }
+ }
+ UpdateVariationsLabel();
+ }
+ }
+ #endregion
+
+ private void createBatchRunCheckBox_CheckedChanged(object sender, EventArgs e) {
+ repetitionsNumericUpDown.Enabled = createBatchRunCheckBox.Checked;
+ createBatchRun = createBatchRunCheckBox.Checked;
+ }
+
+ private void repetitionsNumericUpDown_Validated(object sender, EventArgs e) {
+ if (repetitionsNumericUpDown.Text == string.Empty)
+ repetitionsNumericUpDown.Text = repetitionsNumericUpDown.Value.ToString();
+ repetitions = (int)repetitionsNumericUpDown.Value;
+ }
+
+ private void experimentsLabel_TextChanged(object sender, EventArgs e) {
+ long number;
+ if (long.TryParse(variationsLabel.Text, NumberStyles.AllowThousands, CultureInfo.CurrentCulture.NumberFormat, out number)) {
+ if (number > 1000) warningProvider.SetError(variationsLabel, "Consider reducing the number of variations!");
+ else warningProvider.SetError(variationsLabel, null);
+ }
+ }
+ #endregion
+
+ #region Helpers
+ private void SetTabControlVisibility() {
+ bool isAlgorithm = optimizer != null && optimizer is IAlgorithm;
+ bool instancesAvailable = isAlgorithm
+ && ((IAlgorithm)optimizer).Problem != null
+ && ProblemInstanceManager.GetProviders(((IAlgorithm)optimizer).Problem).Any();
+ if (instancesAvailable && tabControl.TabCount == 1)
+ tabControl.TabPages.Add(instancesTabPage);
+ else if (!instancesAvailable && tabControl.TabCount == 2)
+ tabControl.TabPages.Remove(instancesTabPage);
+ tabControl.Visible = isAlgorithm;
+ if (isAlgorithm) {
+ variationsLabel.Visible = true;
+ experimentsToCreateDescriptionLabel.Visible = true;
+ Height = 450;
+ } else {
+ variationsLabel.Visible = false;
+ experimentsToCreateDescriptionLabel.Visible = false;
+ Height = 130;
+ }
+ }
+
+ private void FillParametersListView() {
+ parametersListView.Items.Clear();
+ intParameters.Clear();
+ doubleParameters.Clear();
+ boolParameters.Clear();
+ multipleChoiceParameters.Clear();
+
+ if (Optimizer is IAlgorithm) {
+ var parameters = ((IAlgorithm)optimizer).Parameters;
+ foreach (var param in parameters) {
+ var valueParam = param as IValueParameter;
+ if (valueParam != null && (valueParam.Value is ValueTypeValue
+ || valueParam.Value is ValueTypeValue
+ || valueParam.Value is ValueTypeValue
+ || (valueParam.Value != null && valueParam.Value.GetType().IsGenericType
+ && typeof(EnumValue<>).IsAssignableFrom(valueParam.Value.GetType().GetGenericTypeDefinition())))
+ || typeof(OptionalConstrainedValueParameter<>).IsAssignableFrom(param.GetType().GetGenericTypeDefinition())
+ || typeof(ConstrainedValueParameter<>).IsAssignableFrom(param.GetType().GetGenericTypeDefinition()))
+ parametersListView.Items.Add(new ListViewItem(param.Name) { Tag = param, ToolTipText = param.Description });
+ }
+ }
+ }
+
+ private void FillInstanceTreeViewAsync() {
+ instances.Clear();
+ instancesTreeView.Nodes.Clear();
+
+ if (Optimizer is IAlgorithm && ((IAlgorithm)Optimizer).Problem != null) {
+ SetMode(DialogMode.DiscoveringInstances);
+ instanceDiscoveryBackgroundWorker.RunWorkerAsync();
+ }
+ }
+
+ private void AddOptimizer(IOptimizer optimizer, Experiment experiment) {
+ if (createBatchRun) {
+ var batchRun = new BatchRun(repetitions.ToString() + "x " + optimizer.Name) {
+ Repetitions = repetitions,
+ Optimizer = optimizer
+ };
+ experiment.Optimizers.Add(batchRun);
+ } else {
+ experiment.Optimizers.Add(optimizer);
+ }
+ }
+
+ private int GetNumberOfVariations() {
+ int instancesCount = 1;
+ if (instances.Values.Any())
+ instancesCount = Math.Max(instances.Values.SelectMany(x => x).Count(), 1);
+
+ int intParameterVariations = 1;
+ foreach (var intParam in intParameters.Values) {
+ intParameterVariations *= Math.Max(intParam.Length, 1);
+ }
+ int doubleParameterVariations = 1;
+ foreach (var doubleParam in doubleParameters.Values) {
+ doubleParameterVariations *= Math.Max(doubleParam.Length, 1);
+ }
+ int boolParameterVariations = 1;
+ foreach (var boolParam in boolParameters) {
+ boolParameterVariations *= 2;
+ }
+ int choiceParameterVariations = 1;
+ foreach (var choiceParam in multipleChoiceParameters.Values) {
+ choiceParameterVariations *= Math.Max(choiceParam.Count, 1);
+ }
+
+ return (instancesCount * intParameterVariations * doubleParameterVariations * boolParameterVariations * choiceParameterVariations);
+ }
+
+ private void SetMode(DialogMode mode) {
+ if (InvokeRequired) Invoke((Action)SetMode, mode);
+ else {
+ createBatchRunCheckBox.Enabled = mode == DialogMode.Normal;
+ repetitionsNumericUpDown.Enabled = mode == DialogMode.Normal;
+ parametersSplitContainer.Enabled = mode == DialogMode.Normal || mode == DialogMode.DiscoveringInstances;
+ selectAllCheckBox.Enabled = mode == DialogMode.Normal;
+ selectNoneCheckBox.Enabled = mode == DialogMode.Normal;
+ instancesTreeView.Enabled = mode == DialogMode.Normal;
+ instancesTreeView.Visible = mode == DialogMode.Normal || mode == DialogMode.CreatingExperiment || mode == DialogMode.PreparingExperiment;
+ okButton.Enabled = mode == DialogMode.Normal;
+ okButton.Visible = mode != DialogMode.CreatingExperiment && mode != DialogMode.PreparingExperiment;
+ cancelButton.Enabled = mode != DialogMode.PreparingExperiment;
+ instanceDiscoveryProgressLabel.Visible = mode == DialogMode.DiscoveringInstances;
+ instanceDiscoveryProgressBar.Visible = mode == DialogMode.DiscoveringInstances;
+ experimentCreationProgressBar.Visible = mode == DialogMode.CreatingExperiment || mode == DialogMode.PreparingExperiment;
+ }
+ }
+
+ private void ClearDetailsView() {
+ stringConvertibleArrayView.Visible = false;
+ stringConvertibleArrayView.Content = null;
+ stringConvertibleArrayView.ReadOnly = true;
+ generateButton.Visible = false;
+ detailsTypeLabel.Visible = false;
+ choicesListView.Items.Clear();
+ choicesListView.Enabled = false;
+ choicesListView.Visible = false;
+ }
+
+ private void UpdateVariationsLabel() {
+ variationsLabel.Text = GetNumberOfVariations().ToString("#,#", CultureInfo.CurrentCulture);
+ }
+
+ #region Retrieve parameter combinations
+ private IEnumerable> GetIntParameterConfigurations() {
+ var configuration = new Dictionary();
+ var enumerators = new Dictionary>();
+ bool finished;
+ do {
+ foreach (var p in intParameters) {
+ if (!enumerators.ContainsKey(p.Key)) {
+ enumerators[p.Key] = p.Value.GetEnumerator();
+ enumerators[p.Key].MoveNext();
+ }
+ configuration[p.Key] = enumerators[p.Key].Current;
+ }
+ yield return configuration;
+
+ finished = true;
+ foreach (var p in intParameters) {
+ if (!enumerators[p.Key].MoveNext()) {
+ enumerators[p.Key] = p.Value.GetEnumerator();
+ enumerators[p.Key].MoveNext();
+ } else {
+ finished = false;
+ break;
+ }
+ }
+ } while (!finished);
+ }
+
+ private IEnumerable> GetDoubleParameterConfigurations() {
+ var configuration = new Dictionary();
+ var enumerators = new Dictionary>();
+ bool finished;
+ do {
+ foreach (var p in doubleParameters) {
+ if (!enumerators.ContainsKey(p.Key)) {
+ enumerators[p.Key] = p.Value.GetEnumerator();
+ enumerators[p.Key].MoveNext();
+ }
+ configuration[p.Key] = enumerators[p.Key].Current;
+ }
+ yield return configuration;
+
+ finished = true;
+ foreach (var p in doubleParameters) {
+ if (!enumerators[p.Key].MoveNext()) {
+ enumerators[p.Key] = p.Value.GetEnumerator();
+ enumerators[p.Key].MoveNext();
+ } else {
+ finished = false;
+ break;
+ }
+ }
+ } while (!finished);
+ }
+
+ private IEnumerable> GetBoolParameterConfigurations() {
+ var configuration = new Dictionary();
+ bool finished;
+ do {
+ foreach (var p in boolParameters) {
+ if (!configuration.ContainsKey(p))
+ configuration.Add(p, false);
+ }
+
+ yield return configuration;
+ finished = true;
+
+ foreach (var p in boolParameters) {
+ if (configuration[p]) {
+ configuration[p] = false;
+ } else {
+ configuration[p] = true;
+ finished = false;
+ break;
+ }
+ }
+ } while (!finished);
+ }
+
+ private IEnumerable> GetMultipleChoiceConfigurations() {
+ var configuration = new Dictionary();
+ var enumerators = new Dictionary>();
+ bool finished;
+ do {
+ foreach (var p in multipleChoiceParameters.Keys.ToArray()) {
+ if (!enumerators.ContainsKey(p)) {
+ enumerators.Add(p, multipleChoiceParameters[p].GetEnumerator());
+ if (!enumerators[p].MoveNext()) {
+ multipleChoiceParameters.Remove(p);
+ continue;
+ }
+ }
+ configuration[p] = enumerators[p].Current;
+ }
+
+ finished = true;
+ foreach (var p in multipleChoiceParameters.Keys) {
+ if (!enumerators[p].MoveNext()) {
+ enumerators[p] = multipleChoiceParameters[p].GetEnumerator();
+ enumerators[p].MoveNext();
+ } else {
+ finished = false;
+ break;
+ }
+ }
+ yield return configuration;
+ } while (!finished);
+ }
+ #endregion
+
+ #region EnumValueEqualityComparer
+ private class EnumValueEqualityComparer : EqualityComparer {
+ public override bool Equals(IItem x, IItem y) {
+ if (typeof(EnumValue<>).IsAssignableFrom(x.GetType().GetGenericTypeDefinition()) &&
+ typeof(EnumValue<>).IsAssignableFrom(y.GetType().GetGenericTypeDefinition())) {
+ dynamic enumValueX = x;
+ dynamic enumValueY = y;
+ return enumValueX.Value.Equals(enumValueY.Value);
+ } else return object.ReferenceEquals(x, y);
+ }
+
+ public override int GetHashCode(IItem obj) {
+ if (typeof(EnumValue<>).IsAssignableFrom(obj.GetType().GetGenericTypeDefinition())) {
+ dynamic enumValue = obj;
+ return enumValue.Value.GetHashCode();
+ } else return obj.GetHashCode();
+ }
+ }
+ #endregion
+
+ #endregion
+
+ #region Background workers
+ #region Instance discovery
+ private void instanceDiscoveryBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
+ instanceDiscoveryBackgroundWorker.ReportProgress(0, "Finding instance providers...");
+ var instanceProviders = ProblemInstanceManager.GetProviders(((IAlgorithm)Optimizer).Problem).ToArray();
+ var nodes = new List(instanceProviders.Length);
+ for (int i = 0; i < instanceProviders.Length; i++) {
+ var provider = instanceProviders[i];
+ var providerNode = new TreeNode(provider.Name) { Tag = provider };
+ var descriptors = ProblemInstanceManager.GetDataDescriptors(provider);
+ foreach (var desc in descriptors) {
+ #region Check cancellation request
+ if (instanceDiscoveryBackgroundWorker.CancellationPending) {
+ e.Cancel = true;
+ e.Result = nodes.ToArray();
+ return;
+ }
+ #endregion
+ var node = new TreeNode(desc.Name) { Tag = desc };
+ providerNode.Nodes.Add(node);
+ }
+
+ //Do not add instance providers without data descriptors
+ if (providerNode.Nodes.Count > 0) {
+ nodes.Add(providerNode);
+ }
+
+ double progress = nodes.Count > 0 ? i / (double)instanceProviders.Length : 0.0;
+ instanceDiscoveryBackgroundWorker.ReportProgress((int)(100 * progress), provider.Name);
+ }
+ e.Result = nodes.ToArray();
+ instanceDiscoveryBackgroundWorker.ReportProgress(100, string.Empty);
+ }
+
+ private void instanceDiscoveryBackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) {
+ if (instanceDiscoveryProgressBar.Value != e.ProgressPercentage)
+ instanceDiscoveryProgressBar.Value = e.ProgressPercentage;
+ instanceDiscoveryProgressLabel.Text = (string)e.UserState;
+ }
+
+ private void instanceDiscoveryBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
+ try {
+ if (((TreeNode[])e.Result).Length > 0) {
+ instancesTreeView.Nodes.AddRange((TreeNode[])e.Result);
+ foreach (TreeNode node in instancesTreeView.Nodes)
+ node.Collapse();
+ }
+ selectNoneCheckBox.Checked = true;
+ }
+ catch { }
+ try {
+ SetMode(DialogMode.Normal);
+ if (e.Error != null) MessageBox.Show(e.Error.Message, "Error occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ catch { }
+ }
+ #endregion
+
+ #region Experiment creation
+ private void experimentCreationBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
+ failedInstances = new StringBuilder();
+ var localExperiment = new Experiment();
+
+ int counter = 0, totalVariations = GetNumberOfVariations();
+ int totalInstances = instances.Values.SelectMany(x => x).Count();
+ if (totalInstances == 0) {
+ try {
+ AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations);
+ }
+ catch (OperationCanceledException) {
+ e.Cancel = true;
+ return;
+ }
+ experimentCreationBackgroundWorker.ReportProgress(100, string.Empty);
+ } else {
+ foreach (var provider in instances.Keys) {
+ foreach (var descriptor in instances[provider]) {
+ var algorithm = (IAlgorithm)Optimizer.Clone();
+ bool failed = false;
+ try {
+ ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem);
+ }
+ catch (Exception ex) {
+ failedInstances.AppendLine(descriptor.Name + ": " + ex.Message);
+ failed = true;
+ }
+ if (!failed) {
+ try {
+ if (totalInstances > 1 && totalVariations / totalInstances > 1) {
+ var experiment = new Experiment(descriptor.Name);
+ AddParameterVariations(algorithm, experiment, ref counter, totalVariations);
+ localExperiment.Optimizers.Add(experiment);
+ } else {
+ AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations);
+ }
+ }
+ catch (OperationCanceledException) {
+ e.Cancel = true;
+ return;
+ }
+ } else experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), "Loading failed (" + descriptor.Name + ")");
+ }
+ }
+ }
+ // this step can take some time
+ SetMode(DialogMode.PreparingExperiment);
+ experimentCreationBackgroundWorker.ReportProgress(-1);
+ localExperiment.Prepare(true);
+ experimentCreationBackgroundWorker.ReportProgress(100);
+ Experiment = localExperiment;
+ }
+
+ private void AddParameterVariations(IOptimizer optimizer, Experiment localExperiment, ref int counter, int totalVariations) {
+ var variations = CalculateParameterVariations(optimizer);
+ foreach (var v in variations) {
+ if (experimentCreationBackgroundWorker.CancellationPending)
+ throw new OperationCanceledException();
+ AddOptimizer(v, localExperiment);
+ counter++;
+ experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), string.Empty);
+ }
+ }
+
+ private IEnumerable CalculateParameterVariations(IOptimizer optimizer) {
+ if (!boolParameters.Any() && !intParameters.Any() && !doubleParameters.Any() && !multipleChoiceParameters.Any()) {
+ var o = (IOptimizer)optimizer.Clone();
+ o.Runs.Clear();
+ yield return o;
+ yield break;
+ }
+ bool finished;
+ var mcEnumerator = GetMultipleChoiceConfigurations().GetEnumerator();
+ var boolEnumerator = GetBoolParameterConfigurations().GetEnumerator();
+ var intEnumerator = GetIntParameterConfigurations().GetEnumerator();
+ var doubleEnumerator = GetDoubleParameterConfigurations().GetEnumerator();
+ mcEnumerator.MoveNext(); boolEnumerator.MoveNext(); intEnumerator.MoveNext(); doubleEnumerator.MoveNext();
+ do {
+ var variant = (IAlgorithm)optimizer.Clone();
+ variant.Runs.Clear();
+ variant.Name += " {";
+ finished = true;
+ if (doubleParameters.Any()) {
+ foreach (var d in doubleEnumerator.Current) {
+ var value = (ValueTypeValue)((IValueParameter)variant.Parameters[d.Key.Name]).Value;
+ value.Value = d.Value;
+ variant.Name += d.Key.Name + "=" + d.Value.ToString() + ", ";
+ }
+ if (finished) {
+ if (doubleEnumerator.MoveNext()) {
+ finished = false;
+ } else {
+ doubleEnumerator = GetDoubleParameterConfigurations().GetEnumerator();
+ doubleEnumerator.MoveNext();
+ }
+ }
+ }
+ if (intParameters.Any()) {
+ foreach (var i in intEnumerator.Current) {
+ var value = (ValueTypeValue)((IValueParameter)variant.Parameters[i.Key.Name]).Value;
+ value.Value = i.Value;
+ variant.Name += i.Key.Name + "=" + i.Value.ToString() + ", ";
+ }
+ if (finished) {
+ if (intEnumerator.MoveNext()) {
+ finished = false;
+ } else {
+ intEnumerator = GetIntParameterConfigurations().GetEnumerator();
+ intEnumerator.MoveNext();
+ }
+ }
+ }
+ if (boolParameters.Any()) {
+ foreach (var b in boolEnumerator.Current) {
+ var value = (ValueTypeValue)((IValueParameter)variant.Parameters[b.Key.Name]).Value;
+ value.Value = b.Value;
+ variant.Name += b.Key.Name + "=" + b.Value.ToString() + ", ";
+ }
+ if (finished) {
+ if (boolEnumerator.MoveNext()) {
+ finished = false;
+ } else {
+ boolEnumerator = GetBoolParameterConfigurations().GetEnumerator();
+ boolEnumerator.MoveNext();
+ }
+ }
+ }
+ if (multipleChoiceParameters.Any()) {
+ foreach (var m in mcEnumerator.Current) {
+ if (m.Key.Value != null && m.Key.Value.GetType().IsGenericType
+ && typeof(EnumValue<>).IsAssignableFrom(m.Key.Value.GetType().GetGenericTypeDefinition())) {
+ var valueParam = (IValueParameter)variant.Parameters[m.Key.Name];
+ dynamic targetEnumValue = valueParam.Value;
+ dynamic sourceEnumValue = m.Value;
+ targetEnumValue.Value = sourceEnumValue.Value;
+ variant.Name += m.Key.Name + "=" + m.Value + ", ";
+ } else {
+ dynamic variantParam = variant.Parameters[m.Key.Name];
+ if (m.Value == optionalNullChoice) {
+ variantParam.Value = null;
+ variant.Name += m.Key.Name + "=null, ";
+ continue;
+ }
+ var variantEnumerator = ((IEnumerable