Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7985


Ignore:
Timestamp:
06/12/12 01:47:25 (12 years ago)
Author:
abeham
Message:

#1851: Allow to specify each value of numeric parameters explicitly as well as provide a dialog for generating the values

Location:
trunk/sources/HeuristicLab.Optimizer/3.3
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs

    r7967 r7985  
    6565      this.parametersListView = new System.Windows.Forms.ListView();
    6666      this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     67      this.generateButton = new System.Windows.Forms.Button();
     68      this.stringConvertibleArrayView = new HeuristicLab.Data.Views.StringConvertibleArrayView();
    6769      this.detailsTypeLabel = new System.Windows.Forms.Label();
    68       this.stepSizeTextBox = new System.Windows.Forms.TextBox();
    69       this.maximumTextBox = new System.Windows.Forms.TextBox();
    70       this.minimumTextBox = new System.Windows.Forms.TextBox();
    71       this.stepSizeLabel = new System.Windows.Forms.Label();
    72       this.maximumLabel = new System.Windows.Forms.Label();
    73       this.minimumLabel = new System.Windows.Forms.Label();
    7470      this.choicesListView = new System.Windows.Forms.ListView();
    7571      this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     
    8076      this.variationsLabel = new System.Windows.Forms.Label();
    8177      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     78      this.warningProvider = new System.Windows.Forms.ErrorProvider(this.components);
    8279      this.experimentCreationProgressBar = new System.Windows.Forms.ProgressBar();
    83       this.warningProvider = new System.Windows.Forms.ErrorProvider(this.components);
    8480      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
    8581      this.tabControl.SuspendLayout();
     
    273269      // parametersSplitContainer.Panel2
    274270      //
     271      this.parametersSplitContainer.Panel2.Controls.Add(this.generateButton);
     272      this.parametersSplitContainer.Panel2.Controls.Add(this.stringConvertibleArrayView);
    275273      this.parametersSplitContainer.Panel2.Controls.Add(this.detailsTypeLabel);
    276       this.parametersSplitContainer.Panel2.Controls.Add(this.stepSizeTextBox);
    277       this.parametersSplitContainer.Panel2.Controls.Add(this.maximumTextBox);
    278       this.parametersSplitContainer.Panel2.Controls.Add(this.minimumTextBox);
    279       this.parametersSplitContainer.Panel2.Controls.Add(this.stepSizeLabel);
    280       this.parametersSplitContainer.Panel2.Controls.Add(this.maximumLabel);
    281       this.parametersSplitContainer.Panel2.Controls.Add(this.minimumLabel);
    282274      this.parametersSplitContainer.Panel2.Controls.Add(this.choicesListView);
    283275      this.parametersSplitContainer.Size = new System.Drawing.Size(314, 267);
     
    306298      this.columnHeader1.Width = 150;
    307299      //
     300      // generateButton
     301      //
     302      this.generateButton.Location = new System.Drawing.Point(16, 10);
     303      this.generateButton.Name = "generateButton";
     304      this.generateButton.Size = new System.Drawing.Size(75, 23);
     305      this.generateButton.TabIndex = 8;
     306      this.generateButton.Text = "Generate...";
     307      this.generateButton.UseVisualStyleBackColor = true;
     308      this.generateButton.Click += new System.EventHandler(this.generateButton_Click);
     309      //
     310      // stringConvertibleArrayView
     311      //
     312      this.stringConvertibleArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     313                  | System.Windows.Forms.AnchorStyles.Left)
     314                  | System.Windows.Forms.AnchorStyles.Right)));
     315      this.stringConvertibleArrayView.Caption = "StringConvertibleArray View";
     316      this.stringConvertibleArrayView.Content = null;
     317      this.stringConvertibleArrayView.Location = new System.Drawing.Point(16, 39);
     318      this.stringConvertibleArrayView.Name = "stringConvertibleArrayView";
     319      this.stringConvertibleArrayView.ReadOnly = false;
     320      this.stringConvertibleArrayView.Size = new System.Drawing.Size(155, 215);
     321      this.stringConvertibleArrayView.TabIndex = 7;
     322      //
    308323      // detailsTypeLabel
    309324      //
     
    314329      this.detailsTypeLabel.TabIndex = 0;
    315330      this.detailsTypeLabel.Text = "Choices:";
    316       //
    317       // stepSizeTextBox
    318       //
    319       this.stepSizeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    320                   | System.Windows.Forms.AnchorStyles.Right)));
    321       this.stepSizeTextBox.Location = new System.Drawing.Point(73, 86);
    322       this.stepSizeTextBox.Name = "stepSizeTextBox";
    323       this.stepSizeTextBox.Size = new System.Drawing.Size(98, 20);
    324       this.stepSizeTextBox.TabIndex = 5;
    325       this.stepSizeTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.detailsTextBox_Validating);
    326       //
    327       // maximumTextBox
    328       //
    329       this.maximumTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    330                   | System.Windows.Forms.AnchorStyles.Right)));
    331       this.maximumTextBox.Location = new System.Drawing.Point(73, 60);
    332       this.maximumTextBox.Name = "maximumTextBox";
    333       this.maximumTextBox.Size = new System.Drawing.Size(98, 20);
    334       this.maximumTextBox.TabIndex = 3;
    335       this.maximumTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.detailsTextBox_Validating);
    336       //
    337       // minimumTextBox
    338       //
    339       this.minimumTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    340                   | System.Windows.Forms.AnchorStyles.Right)));
    341       this.minimumTextBox.Location = new System.Drawing.Point(73, 34);
    342       this.minimumTextBox.Name = "minimumTextBox";
    343       this.minimumTextBox.Size = new System.Drawing.Size(98, 20);
    344       this.minimumTextBox.TabIndex = 1;
    345       this.minimumTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.detailsTextBox_Validating);
    346       //
    347       // stepSizeLabel
    348       //
    349       this.stepSizeLabel.AutoSize = true;
    350       this.stepSizeLabel.Location = new System.Drawing.Point(13, 89);
    351       this.stepSizeLabel.Name = "stepSizeLabel";
    352       this.stepSizeLabel.Size = new System.Drawing.Size(53, 13);
    353       this.stepSizeLabel.TabIndex = 4;
    354       this.stepSizeLabel.Text = "Step size:";
    355       //
    356       // maximumLabel
    357       //
    358       this.maximumLabel.AutoSize = true;
    359       this.maximumLabel.Location = new System.Drawing.Point(13, 63);
    360       this.maximumLabel.Name = "maximumLabel";
    361       this.maximumLabel.Size = new System.Drawing.Size(54, 13);
    362       this.maximumLabel.TabIndex = 2;
    363       this.maximumLabel.Text = "Maximum:";
    364       //
    365       // minimumLabel
    366       //
    367       this.minimumLabel.AutoSize = true;
    368       this.minimumLabel.Location = new System.Drawing.Point(13, 37);
    369       this.minimumLabel.Name = "minimumLabel";
    370       this.minimumLabel.Size = new System.Drawing.Size(51, 13);
    371       this.minimumLabel.TabIndex = 0;
    372       this.minimumLabel.Text = "Minimum:";
    373331      //
    374332      // choicesListView
     
    456414      this.errorProvider.ContainerControl = this;
    457415      //
     416      // warningProvider
     417      //
     418      this.warningProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
     419      this.warningProvider.ContainerControl = this;
     420      this.warningProvider.Icon = ((System.Drawing.Icon)(resources.GetObject("warningProvider.Icon")));
     421      //
    458422      // experimentCreationProgressBar
    459423      //
     
    466430      this.experimentCreationProgressBar.Visible = false;
    467431      //
    468       // warningProvider
    469       //
    470       this.warningProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
    471       this.warningProvider.ContainerControl = this;
    472       this.warningProvider.Icon = ((System.Drawing.Icon)(resources.GetObject("warningProvider.Icon")));
    473       //
    474432      // CreateExperimentDialog
    475433      //
    476434      this.AcceptButton = this.okButton;
    477       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    478435      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    479436      this.CancelButton = this.cancelButton;
     
    542499    private System.Windows.Forms.ListView choicesListView;
    543500    private System.Windows.Forms.ColumnHeader columnHeader2;
    544     private System.Windows.Forms.TextBox stepSizeTextBox;
    545     private System.Windows.Forms.TextBox maximumTextBox;
    546     private System.Windows.Forms.TextBox minimumTextBox;
    547     private System.Windows.Forms.Label stepSizeLabel;
    548     private System.Windows.Forms.Label maximumLabel;
    549     private System.Windows.Forms.Label minimumLabel;
    550501    private System.Windows.Forms.Label label1;
    551502    private System.Windows.Forms.ErrorProvider errorProvider;
    552     private System.Windows.Forms.ProgressBar experimentCreationProgressBar;
    553503    private System.Windows.Forms.ErrorProvider warningProvider;
    554504    private System.Windows.Forms.TreeView instancesTreeView;
     505    private Data.Views.StringConvertibleArrayView stringConvertibleArrayView;
     506    private System.Windows.Forms.ProgressBar experimentCreationProgressBar;
     507    private System.Windows.Forms.Button generateButton;
    555508
    556509  }
  • trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs

    r7976 r7985  
    5656    private int repetitions;
    5757    private Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> instances;
    58     private Dictionary<IValueParameter, Tuple<int, int, int>> intParameters;
    59     private Dictionary<IValueParameter, Tuple<double, double, double>> doubleParameters;
     58    private Dictionary<IValueParameter, IntArray> intParameters;
     59    private Dictionary<IValueParameter, DoubleArray> doubleParameters;
    6060    private HashSet<IValueParameter> boolParameters;
    6161    private Dictionary<IValueParameter, HashSet<IItem>> multipleChoiceParameters;
     
    7777
    7878      instances = new Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>>();
    79       intParameters = new Dictionary<IValueParameter, Tuple<int, int, int>>();
    80       doubleParameters = new Dictionary<IValueParameter, Tuple<double, double, double>>();
     79      intParameters = new Dictionary<IValueParameter, IntArray>();
     80      doubleParameters = new Dictionary<IValueParameter, DoubleArray>();
    8181      boolParameters = new HashSet<IValueParameter>();
    8282      multipleChoiceParameters = new Dictionary<IValueParameter, HashSet<IItem>>();
     
    118118
    119119      if (isConstrainedValueParameter) {
    120         if (e.Item.Checked) {
    121           multipleChoiceParameters.Add(parameter, new HashSet<IItem>());
    122         } else {
    123           multipleChoiceParameters.Remove(parameter);
    124         }
     120        if (e.Item.Checked) multipleChoiceParameters.Add(parameter, new HashSet<IItem>());
     121        else multipleChoiceParameters.Remove(parameter);
    125122      }
    126123
     
    128125      if (intValue != null) {
    129126        if (e.Item.Checked) {
    130           int minimum = intValue.Value;
    131           int maximum = intValue.Value;
    132           int step = 1;
    133           intParameters.Add(parameter, new Tuple<int, int, int>(minimum, maximum, step));
     127          intParameters.Add(parameter, new IntArray());
     128          intParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
    134129        } else intParameters.Remove(parameter);
    135130      }
     
    138133      if (doubleValue != null) {
    139134        if (e.Item.Checked) {
    140           double minimum = doubleValue.Value;
    141           double maximum = doubleValue.Value;
    142           double step = 1;
    143           doubleParameters.Add(parameter, new Tuple<double, double, double>(minimum, maximum, step));
     135          doubleParameters.Add(parameter, new DoubleArray());
     136          doubleParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
    144137        } else doubleParameters.Remove(parameter);
    145138      }
     
    174167      if (isConstrainedValueParameter) {
    175168        detailsTypeLabel.Text = "Choices:";
    176         choicesListView.Enabled = true;
    177         choicesListView.Visible = true;
    178169        choicesListView.Tag = parameter;
    179170
    180         if (!multipleChoiceParameters.ContainsKey(parameter)) return;
    181171        dynamic constrainedValuedParameter = parameter;
    182172        dynamic validValues = constrainedValuedParameter.ValidValues;
     
    184174          choicesListView.Items.Add(new ListViewItem(choice.ToString()) {
    185175            Tag = choice,
    186             Checked = multipleChoiceParameters[parameter].Contains(choice)
     176            Checked = multipleChoiceParameters.ContainsKey(parameter)
     177            && multipleChoiceParameters[parameter].Contains(choice)
    187178          });
    188179        }
     180        choicesListView.Enabled = multipleChoiceParameters.ContainsKey(parameter);
     181        detailsTypeLabel.Visible = true;
     182        choicesListView.Visible = true;
    189183        return;
    190184      }
    191185
    192       if (!(parameter.Value is ValueTypeValue<bool>)) {
    193         minimumLabel.Visible = true; minimumTextBox.Visible = true;
    194         maximumLabel.Visible = true; maximumTextBox.Visible = true;
    195         stepSizeLabel.Visible = true; stepSizeTextBox.Visible = true;
    196       } else detailsTypeLabel.Text = "Boolean parameter: True / False";
     186      if (parameter.Value is ValueTypeValue<bool>) {
     187        detailsTypeLabel.Text = "Boolean parameter: True / False";
     188        detailsTypeLabel.Visible = true;
     189      }
    197190
    198191      var intValue = parameter.Value as ValueTypeValue<int>;
    199192      if (intValue != null) {
    200         detailsTypeLabel.Text = "Integer parameter:";
    201         if (!intParameters.ContainsKey(parameter)) return;
    202         string min = intParameters[parameter].Item1.ToString();
    203         string max = intParameters[parameter].Item2.ToString();
    204         string step = intParameters[parameter].Item3.ToString();
    205         UpdateMinMaxStepSize(parameter, min, max, step);
     193        if (intParameters.ContainsKey(parameter))
     194          stringConvertibleArrayView.Content = intParameters[parameter];
     195        stringConvertibleArrayView.Visible = true;
     196        stringConvertibleArrayView.ReadOnly = !intParameters.ContainsKey(parameter);
     197        generateButton.Tag = parameter;
     198        generateButton.Enabled = intParameters.ContainsKey(parameter);
     199        generateButton.Visible = true;
    206200        return;
    207201      }
     
    209203      var doubleValue = parameter.Value as ValueTypeValue<double>;
    210204      if (doubleValue != null) {
    211         detailsTypeLabel.Text = "Double parameter:";
    212         if (!doubleParameters.ContainsKey(parameter)) return;
    213         string min = doubleParameters[parameter].Item1.ToString();
    214         string max = doubleParameters[parameter].Item2.ToString();
    215         string step = doubleParameters[parameter].Item3.ToString();
    216         UpdateMinMaxStepSize(parameter, min, max, step);
     205        if (doubleParameters.ContainsKey(parameter))
     206          stringConvertibleArrayView.Content = doubleParameters[parameter];
     207        stringConvertibleArrayView.Visible = true;
     208        stringConvertibleArrayView.ReadOnly = !doubleParameters.ContainsKey(parameter);
     209        generateButton.Tag = parameter;
     210        generateButton.Enabled = doubleParameters.ContainsKey(parameter);
     211        generateButton.Visible = true;
    217212        return;
    218213      }
     
    222217    private void choiceListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
    223218      var parameter = (IValueParameter)choicesListView.Tag;
    224       if (e.Item.Checked) {
    225         multipleChoiceParameters[parameter].Add((IItem)e.Item.Tag);
    226       } else multipleChoiceParameters[parameter].Remove((IItem)e.Item.Tag);
    227 
    228       UpdateVariationsLabel();
    229     }
    230 
    231     private void detailsTextBox_Validating(object sender, CancelEventArgs e) {
    232       var parameter = (IValueParameter)((TextBox)sender).Tag;
    233       errorProvider.Clear();
    234 
    235       var intValue = parameter.Value as ValueTypeValue<int>;
    236       if (intValue != null) {
    237         int value;
    238         if (!int.TryParse(((TextBox)sender).Text, out value)) {
    239           errorProvider.SetError(((TextBox)sender), "Please enter a valid integer number.");
    240           e.Cancel = true;
    241         } else {
    242           var before = intParameters[parameter];
    243           var after = default(Tuple<int, int, int>);
    244           if (sender == minimumTextBox) after = new Tuple<int, int, int>(value, before.Item2, before.Item3);
    245           else if (sender == maximumTextBox) after = new Tuple<int, int, int>(before.Item1, value, before.Item3);
    246           else if (sender == stepSizeTextBox) after = new Tuple<int, int, int>(before.Item1, before.Item2, value);
    247           intParameters[parameter] = after;
    248         }
    249       }
    250 
    251       var doubleValue = parameter.Value as ValueTypeValue<double>;
    252       if (doubleValue != null) {
    253         double value;
    254         if (!double.TryParse(((TextBox)sender).Text, NumberStyles.Float, CultureInfo.CurrentCulture.NumberFormat, out value)) {
    255           errorProvider.SetError(((TextBox)sender), "Please enter a valid number.");
    256           e.Cancel = true;
    257         } else {
    258           var before = doubleParameters[parameter];
    259           var after = default(Tuple<double, double, double>);
    260           if (sender == minimumTextBox) after = new Tuple<double, double, double>(value, before.Item2, before.Item3);
    261           else if (sender == maximumTextBox) after = new Tuple<double, double, double>(before.Item1, value, before.Item3);
    262           else if (sender == stepSizeTextBox) after = new Tuple<double, double, double>(before.Item1, before.Item2, value);
    263           doubleParameters[parameter] = after;
    264         }
    265       }
    266 
     219      if (multipleChoiceParameters.ContainsKey(parameter)) {
     220        if (e.Item.Checked) {
     221          multipleChoiceParameters[parameter].Add((IItem)e.Item.Tag);
     222        } else multipleChoiceParameters[parameter].Remove((IItem)e.Item.Tag);
     223
     224        UpdateVariationsLabel();
     225      }
     226    }
     227
     228    private void generateButton_Click(object sender, EventArgs e) {
     229      var parameter = (IValueParameter)generateButton.Tag;
     230      bool integerOnly = intParameters.ContainsKey(parameter);
     231      double min = 0, max = 1, step = 1;
     232      #region Try to calculate some meaningful values
     233      if (integerOnly) {
     234        int len = intParameters[parameter].Length;
     235        if (len > 0) {
     236          min = intParameters[parameter].Min();
     237          max = intParameters[parameter].Max();
     238          step = len >= 2 ? Math.Abs((intParameters[parameter][len - 1] - intParameters[parameter][len - 2])) : 1;
     239        }
     240      } else {
     241        int len = doubleParameters[parameter].Length;
     242        if (len > 0) {
     243          min = doubleParameters[parameter].Min();
     244          max = doubleParameters[parameter].Max();
     245          step = len >= 2 ? Math.Abs((doubleParameters[parameter][len - 1] - doubleParameters[parameter][len - 2])) : 1;
     246        }
     247      }
     248      #endregion
     249      using (var dialog = new DefineArithmeticProgressionDialog(integerOnly, min, max, step)) {
     250        if (dialog.ShowDialog() == DialogResult.OK) {
     251          var values = dialog.Values;
     252          if (integerOnly) {
     253            intParameters[parameter].Reset -= new EventHandler(ValuesArray_Reset);
     254            intParameters[parameter] = new IntArray(values.Select(x => (int)x).ToArray());
     255            intParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
     256            stringConvertibleArrayView.Content = intParameters[parameter];
     257          } else {
     258            doubleParameters[parameter].Reset -= new EventHandler(ValuesArray_Reset);
     259            doubleParameters[parameter] = new DoubleArray(values.ToArray());
     260            doubleParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
     261            stringConvertibleArrayView.Content = doubleParameters[parameter];
     262          }
     263          UpdateVariationsLabel();
     264        }
     265      }
     266    }
     267
     268    private void ValuesArray_Reset(object sender, EventArgs e) {
    267269      UpdateVariationsLabel();
    268270    }
     
    459461      int intParameterVariations = 1;
    460462      foreach (var intParam in intParameters.Values) {
    461         if (intParam.Item3 == 0) continue;
    462         intParameterVariations *= (intParam.Item2 - intParam.Item1) / intParam.Item3 + 1;
     463        intParameterVariations *= Math.Max(intParam.Length, 1);
    463464      }
    464465      int doubleParameterVariations = 1;
    465466      foreach (var doubleParam in doubleParameters.Values) {
    466         if (doubleParam.Item3 == 0) continue;
    467         doubleParameterVariations *= (int)Math.Floor((doubleParam.Item2 - doubleParam.Item1) / doubleParam.Item3) + 1;
     467        doubleParameterVariations *= Math.Max(doubleParam.Length, 1);
    468468      }
    469469      int boolParameterVariations = 1;
     
    480480
    481481    private void SetMode(DialogMode mode) {
    482       createBatchRunCheckBox.Enabled = mode == DialogMode.Normal;
    483       repetitionsNumericUpDown.Enabled = mode == DialogMode.Normal;
    484       parametersSplitContainer.Enabled = mode == DialogMode.Normal || mode == DialogMode.DiscoveringInstances;
    485       selectAllCheckBox.Enabled = mode == DialogMode.Normal;
    486       selectNoneCheckBox.Enabled = mode == DialogMode.Normal;
    487       instancesTreeView.Enabled = mode == DialogMode.Normal;
    488       instancesTreeView.Visible = mode == DialogMode.Normal || mode == DialogMode.CreatingExperiment || mode == DialogMode.PreparingExperiment;
    489       okButton.Enabled = mode == DialogMode.Normal;
    490       okButton.Visible = mode != DialogMode.CreatingExperiment && mode != DialogMode.PreparingExperiment;
    491       cancelButton.Enabled = mode != DialogMode.PreparingExperiment;
    492       instanceDiscoveryProgressLabel.Visible = mode == DialogMode.DiscoveringInstances;
    493       instanceDiscoveryProgressBar.Visible = mode == DialogMode.DiscoveringInstances;
    494       experimentCreationProgressBar.Visible = mode == DialogMode.CreatingExperiment || mode == DialogMode.PreparingExperiment;
     482      if (InvokeRequired) Invoke((Action<DialogMode>)SetMode, mode);
     483      else {
     484        createBatchRunCheckBox.Enabled = mode == DialogMode.Normal;
     485        repetitionsNumericUpDown.Enabled = mode == DialogMode.Normal;
     486        parametersSplitContainer.Enabled = mode == DialogMode.Normal || mode == DialogMode.DiscoveringInstances;
     487        selectAllCheckBox.Enabled = mode == DialogMode.Normal;
     488        selectNoneCheckBox.Enabled = mode == DialogMode.Normal;
     489        instancesTreeView.Enabled = mode == DialogMode.Normal;
     490        instancesTreeView.Visible = mode == DialogMode.Normal || mode == DialogMode.CreatingExperiment || mode == DialogMode.PreparingExperiment;
     491        okButton.Enabled = mode == DialogMode.Normal;
     492        okButton.Visible = mode != DialogMode.CreatingExperiment && mode != DialogMode.PreparingExperiment;
     493        cancelButton.Enabled = mode != DialogMode.PreparingExperiment;
     494        instanceDiscoveryProgressLabel.Visible = mode == DialogMode.DiscoveringInstances;
     495        instanceDiscoveryProgressBar.Visible = mode == DialogMode.DiscoveringInstances;
     496        experimentCreationProgressBar.Visible = mode == DialogMode.CreatingExperiment || mode == DialogMode.PreparingExperiment;
     497      }
    495498    }
    496499
    497500    private void ClearDetailsView() {
    498       minimumLabel.Visible = false;
    499       minimumTextBox.Text = string.Empty;
    500       minimumTextBox.Enabled = false;
    501       minimumTextBox.Visible = false;
    502       maximumLabel.Visible = false;
    503       maximumTextBox.Text = string.Empty;
    504       maximumTextBox.Enabled = false;
    505       maximumTextBox.Visible = false;
    506       stepSizeLabel.Visible = false;
    507       stepSizeTextBox.Text = string.Empty;
    508       stepSizeTextBox.Enabled = false;
    509       stepSizeTextBox.Visible = false;
     501      stringConvertibleArrayView.Visible = false;
     502      stringConvertibleArrayView.Content = null;
     503      stringConvertibleArrayView.ReadOnly = true;
     504      generateButton.Visible = false;
     505      detailsTypeLabel.Visible = false;
    510506      choicesListView.Items.Clear();
    511507      choicesListView.Enabled = false;
     
    513509    }
    514510
    515     private void UpdateMinMaxStepSize(IValueParameter parameter, string min, string max, string step) {
    516       minimumLabel.Visible = true;
    517       minimumTextBox.Text = min;
    518       minimumTextBox.Enabled = true;
    519       minimumTextBox.Visible = true;
    520       minimumTextBox.Tag = parameter;
    521       maximumLabel.Visible = true;
    522       maximumTextBox.Text = max;
    523       maximumTextBox.Enabled = true;
    524       maximumTextBox.Visible = true;
    525       maximumTextBox.Tag = parameter;
    526       stepSizeLabel.Visible = true;
    527       stepSizeTextBox.Text = step;
    528       stepSizeTextBox.Enabled = true;
    529       stepSizeTextBox.Visible = true;
    530       stepSizeTextBox.Tag = parameter;
    531     }
    532 
    533511    private void UpdateVariationsLabel() {
    534512      variationsLabel.Text = GetNumberOfVariations().ToString("#,#", CultureInfo.CurrentCulture);
     
    538516    private IEnumerable<Dictionary<IValueParameter, int>> GetIntParameterConfigurations() {
    539517      var configuration = new Dictionary<IValueParameter, int>();
    540       var indices = new Dictionary<IValueParameter, int>();
     518      var enumerators = new Dictionary<IValueParameter, IEnumerator<int>>();
    541519      bool finished;
    542520      do {
    543521        foreach (var p in intParameters) {
    544           if (!indices.ContainsKey(p.Key)) indices.Add(p.Key, 0);
    545           var value = p.Value.Item1 + p.Value.Item3 * indices[p.Key];
    546           configuration[p.Key] = value;
     522          if (!enumerators.ContainsKey(p.Key)) {
     523            enumerators[p.Key] = p.Value.GetEnumerator();
     524            enumerators[p.Key].MoveNext();
     525          }
     526          configuration[p.Key] = enumerators[p.Key].Current;
    547527        }
    548528        yield return configuration;
    549529
    550530        finished = true;
    551         foreach (var p in intParameters.Keys) {
    552           var newValue = intParameters[p].Item1 + intParameters[p].Item3 * (indices[p] + 1);
    553           if (newValue > intParameters[p].Item2 || intParameters[p].Item3 == 0)
    554             indices[p] = 0;
    555           else {
    556             indices[p]++;
     531        foreach (var p in intParameters) {
     532          if (!enumerators[p.Key].MoveNext()) {
     533            enumerators[p.Key] = p.Value.GetEnumerator();
     534            enumerators[p.Key].MoveNext();
     535          } else {
    557536            finished = false;
    558537            break;
     
    564543    private IEnumerable<Dictionary<IValueParameter, double>> GetDoubleParameterConfigurations() {
    565544      var configuration = new Dictionary<IValueParameter, double>();
    566       var indices = new Dictionary<IValueParameter, int>();
     545      var enumerators = new Dictionary<IValueParameter, IEnumerator<double>>();
    567546      bool finished;
    568547      do {
    569548        foreach (var p in doubleParameters) {
    570           if (!indices.ContainsKey(p.Key)) indices.Add(p.Key, 0);
    571           var value = p.Value.Item1 + p.Value.Item3 * indices[p.Key];
    572           configuration[p.Key] = value;
     549          if (!enumerators.ContainsKey(p.Key)) {
     550            enumerators[p.Key] = p.Value.GetEnumerator();
     551            enumerators[p.Key].MoveNext();
     552          }
     553          configuration[p.Key] = enumerators[p.Key].Current;
    573554        }
    574555        yield return configuration;
    575556
    576557        finished = true;
    577         foreach (var p in doubleParameters.Keys) {
    578           var newValue = doubleParameters[p].Item1 + doubleParameters[p].Item3 * (indices[p] + 1);
    579           if (newValue > doubleParameters[p].Item2 || doubleParameters[p].Item3 == 0)
    580             indices[p] = 0;
    581           else {
    582             indices[p]++;
     558        foreach (var p in doubleParameters) {
     559          if (!enumerators[p.Key].MoveNext()) {
     560            enumerators[p.Key] = p.Value.GetEnumerator();
     561            enumerators[p.Key].MoveNext();
     562          } else {
    583563            finished = false;
    584564            break;
     
    732712      }
    733713      if (localExperiment != null) {
    734         // don't do GUI stuff in do_work
    735714        // this step can take some time
     715        SetMode(DialogMode.PreparingExperiment);
    736716        experimentCreationBackgroundWorker.ReportProgress(-1);
    737717        localExperiment.Prepare(true);
     
    844824        experimentCreationProgressBar.Value = e.ProgressPercentage;
    845825      } else {
    846         SetMode(DialogMode.PreparingExperiment);
    847 
    848826        experimentCreationProgressBar.Style = ProgressBarStyle.Marquee;
    849827      }
  • trunk/sources/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj

    r7957 r7985  
    125125    <EmbeddedResource Include="Documents\PSO_Schwefel.hl" />
    126126    <None Include="Plugin.cs.frame" />
     127    <Compile Include="DefineArithmeticProgressionDialog.cs">
     128      <SubType>Form</SubType>
     129    </Compile>
     130    <Compile Include="DefineArithmeticProgressionDialog.Designer.cs">
     131      <DependentUpon>DefineArithmeticProgressionDialog.cs</DependentUpon>
     132    </Compile>
    127133    <Compile Include="OptimizerSingleDocumentMainForm.cs">
    128134      <SubType>Form</SubType>
     
    238244      <Name>HeuristicLab.Core-3.3</Name>
    239245      <Private>False</Private>
     246    </ProjectReference>
     247    <ProjectReference Include="..\..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj">
     248      <Project>{72104A0B-90E7-42F3-9ABE-9BBBADD4B943}</Project>
     249      <Name>HeuristicLab.Data.Views-3.3</Name>
    240250    </ProjectReference>
    241251    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
  • trunk/sources/HeuristicLab.Optimizer/3.3/Plugin.cs.frame

    r7908 r7985  
    3434  [PluginDependency("HeuristicLab.Core.Views", "3.3")]
    3535  [PluginDependency("HeuristicLab.Data", "3.3")]
     36  [PluginDependency("HeuristicLab.Data.Views", "3.3")]
    3637  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3738  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
Note: See TracChangeset for help on using the changeset viewer.