Changeset 9364


Ignore:
Timestamp:
04/16/13 16:23:59 (6 years ago)
Author:
ascheibe
Message:

#1886 added repetitions for random parameter configurations

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/CreateExperimentDialog.Designer.cs

    r9361 r9364  
    8080      this.combinationsTextBox = new System.Windows.Forms.TextBox();
    8181      this.label2 = new System.Windows.Forms.Label();
     82      this.label3 = new System.Windows.Forms.Label();
     83      this.repetitionsTextBox = new System.Windows.Forms.TextBox();
    8284      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
    8385      this.tabControl.SuspendLayout();
     
    9799      this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    98100      this.okButton.Enabled = false;
    99       this.okButton.Location = new System.Drawing.Point(474, 377);
     101      this.okButton.Location = new System.Drawing.Point(630, 377);
    100102      this.okButton.Name = "okButton";
    101103      this.okButton.Size = new System.Drawing.Size(75, 23);
     
    109111      this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    110112      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    111       this.cancelButton.Location = new System.Drawing.Point(555, 377);
     113      this.cancelButton.Location = new System.Drawing.Point(711, 377);
    112114      this.cancelButton.Name = "cancelButton";
    113115      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     
    163165            0});
    164166      this.repetitionsNumericUpDown.Name = "repetitionsNumericUpDown";
    165       this.repetitionsNumericUpDown.Size = new System.Drawing.Size(517, 20);
     167      this.repetitionsNumericUpDown.Size = new System.Drawing.Size(673, 20);
    166168      this.repetitionsNumericUpDown.TabIndex = 3;
    167169      this.repetitionsNumericUpDown.ThousandsSeparator = true;
     
    244246      this.tabControl.Name = "tabControl";
    245247      this.tabControl.SelectedIndex = 0;
    246       this.tabControl.Size = new System.Drawing.Size(615, 317);
     248      this.tabControl.Size = new System.Drawing.Size(771, 317);
    247249      this.tabControl.TabIndex = 4;
    248250      //
     
    253255      this.parametersTabPage.Name = "parametersTabPage";
    254256      this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3);
    255       this.parametersTabPage.Size = new System.Drawing.Size(607, 291);
     257      this.parametersTabPage.Size = new System.Drawing.Size(763, 291);
    256258      this.parametersTabPage.TabIndex = 1;
    257259      this.parametersTabPage.Text = "Parameter Variations";
     
    275277      this.parametersSplitContainer.Panel2.Controls.Add(this.detailsTypeLabel);
    276278      this.parametersSplitContainer.Panel2.Controls.Add(this.choicesListView);
    277       this.parametersSplitContainer.Size = new System.Drawing.Size(601, 285);
     279      this.parametersSplitContainer.Size = new System.Drawing.Size(757, 285);
    278280      this.parametersSplitContainer.SplitterDistance = 155;
    279281      this.parametersSplitContainer.TabIndex = 1;
     
    320322      this.stringConvertibleArrayView.Name = "stringConvertibleArrayView";
    321323      this.stringConvertibleArrayView.ReadOnly = false;
    322       this.stringConvertibleArrayView.Size = new System.Drawing.Size(411, 233);
     324      this.stringConvertibleArrayView.Size = new System.Drawing.Size(567, 233);
    323325      this.stringConvertibleArrayView.TabIndex = 7;
    324326      //
     
    343345      this.choicesListView.Location = new System.Drawing.Point(16, 34);
    344346      this.choicesListView.Name = "choicesListView";
    345       this.choicesListView.Size = new System.Drawing.Size(411, 238);
     347      this.choicesListView.Size = new System.Drawing.Size(567, 238);
    346348      this.choicesListView.TabIndex = 6;
    347349      this.choicesListView.UseCompatibleStateImageBehavior = false;
     
    426428      this.experimentCreationProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
    427429            | System.Windows.Forms.AnchorStyles.Right)));
    428       this.experimentCreationProgressBar.Location = new System.Drawing.Point(371, 377);
     430      this.experimentCreationProgressBar.Location = new System.Drawing.Point(587, 377);
    429431      this.experimentCreationProgressBar.Name = "experimentCreationProgressBar";
    430       this.experimentCreationProgressBar.Size = new System.Drawing.Size(178, 23);
     432      this.experimentCreationProgressBar.Size = new System.Drawing.Size(118, 23);
    431433      this.experimentCreationProgressBar.TabIndex = 9;
    432434      this.experimentCreationProgressBar.Visible = false;
     
    435437      //
    436438      this.combinationsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    437       this.combinationsTextBox.Location = new System.Drawing.Point(265, 379);
     439      this.combinationsTextBox.Location = new System.Drawing.Point(306, 379);
    438440      this.combinationsTextBox.Name = "combinationsTextBox";
    439441      this.combinationsTextBox.Size = new System.Drawing.Size(100, 20);
     
    445447      this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    446448      this.label2.AutoSize = true;
    447       this.label2.Location = new System.Drawing.Point(173, 382);
     449      this.label2.Location = new System.Drawing.Point(214, 382);
    448450      this.label2.Name = "label2";
    449451      this.label2.Size = new System.Drawing.Size(86, 13);
     
    451453      this.label2.Text = "Var. to generate:";
    452454      //
     455      // label3
     456      //
     457      this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     458      this.label3.AutoSize = true;
     459      this.label3.Location = new System.Drawing.Point(412, 382);
     460      this.label3.Name = "label3";
     461      this.label3.Size = new System.Drawing.Size(63, 13);
     462      this.label3.TabIndex = 12;
     463      this.label3.Text = "Repetitions:";
     464      //
     465      // repetitionsTextBox
     466      //
     467      this.repetitionsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     468      this.repetitionsTextBox.Location = new System.Drawing.Point(481, 379);
     469      this.repetitionsTextBox.Name = "repetitionsTextBox";
     470      this.repetitionsTextBox.Size = new System.Drawing.Size(100, 20);
     471      this.repetitionsTextBox.TabIndex = 13;
     472      this.repetitionsTextBox.Text = "1";
     473      //
    453474      // CreateExperimentDialog
    454475      //
     
    456477      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    457478      this.CancelButton = this.cancelButton;
    458       this.ClientSize = new System.Drawing.Size(642, 412);
     479      this.ClientSize = new System.Drawing.Size(798, 412);
     480      this.Controls.Add(this.repetitionsTextBox);
     481      this.Controls.Add(this.label3);
    459482      this.Controls.Add(this.label2);
    460483      this.Controls.Add(this.combinationsTextBox);
     
    530553    private System.Windows.Forms.Label label2;
    531554    private System.Windows.Forms.TextBox combinationsTextBox;
     555    private System.Windows.Forms.TextBox repetitionsTextBox;
     556    private System.Windows.Forms.Label label3;
    532557
    533558  }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/CreateExperimentDialog.cs

    r9361 r9364  
    4444      set {
    4545        optimizer = value;
    46         Experiment = null;
     46        Experiments = null;
    4747        okButton.Enabled = optimizer != null;
    4848        SetTabControlVisibility();
     
    5252    }
    5353
    54     public Experiment Experiment { get; private set; }
     54    public List<Experiment> Experiments { get; private set; }
    5555
    5656    private bool createBatchRun;
     
    7575      // do not set the Optimizer property here, because we want to delay instance discovery to the time when the form loads
    7676      this.optimizer = optimizer;
    77       Experiment = null;
     77      Experiments = null;
    7878      okButton.Enabled = optimizer != null;
    7979
     
    715715    private void experimentCreationBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
    716716      backgroundWorkerWaitHandle.Set(); // notify the ok button that we're busy now
    717       failedInstances = new StringBuilder();
    718       var localExperiment = new Experiment();
    719 
    720       int counter = 0, totalVariations = GetNumberOfVariations();
    721       int totalInstances = instances.Values.SelectMany(x => x).Count();
    722       if (totalInstances == 0) {
    723         try {
    724           AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations);
    725         }
    726         catch (OperationCanceledException) {
    727           e.Cancel = true;
    728           return;
    729         }
    730         experimentCreationBackgroundWorker.ReportProgress(100, string.Empty);
    731       } else {
    732         foreach (var provider in instances.Keys) {
    733           foreach (var descriptor in instances[provider]) {
    734             var algorithm = (IAlgorithm)Optimizer.Clone();
    735             bool failed = false;
    736             try {
    737               ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem);
    738             }
    739             catch (Exception ex) {
    740               failedInstances.AppendLine(descriptor.Name + ": " + ex.Message);
    741               failed = true;
    742             }
    743             if (!failed) {
     717
     718      int b = int.Parse(repetitionsTextBox.Text);
     719      for (int i = 0; i < b; i++) {
     720        failedInstances = new StringBuilder();
     721        var localExperiment = new Experiment();
     722
     723        int counter = 0, totalVariations = GetNumberOfVariations();
     724        int totalInstances = instances.Values.SelectMany(x => x).Count();
     725        if (totalInstances == 0) {
     726          try {
     727            AddParameterVariations(Optimizer, localExperiment, ref counter, totalVariations);
     728          }
     729          catch (OperationCanceledException) {
     730            e.Cancel = true;
     731            return;
     732          }
     733          experimentCreationBackgroundWorker.ReportProgress(100, string.Empty);
     734        } else {
     735          foreach (var provider in instances.Keys) {
     736            foreach (var descriptor in instances[provider]) {
     737              var algorithm = (IAlgorithm)Optimizer.Clone();
     738              bool failed = false;
    744739              try {
    745                 if (totalInstances > 1 && totalVariations / totalInstances > 1) {
    746                   var experiment = new Experiment(descriptor.Name);
    747                   AddParameterVariations(algorithm, experiment, ref counter, totalVariations);
    748                   localExperiment.Optimizers.Add(experiment);
    749                 } else {
    750                   AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations);
     740                ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem);
     741              }
     742              catch (Exception ex) {
     743                failedInstances.AppendLine(descriptor.Name + ": " + ex.Message);
     744                failed = true;
     745              }
     746              if (!failed) {
     747                try {
     748                  if (totalInstances > 1 && totalVariations / totalInstances > 1) {
     749                    var experiment = new Experiment(descriptor.Name);
     750                    AddParameterVariations(algorithm, experiment, ref counter, totalVariations);
     751                    localExperiment.Optimizers.Add(experiment);
     752                  } else {
     753                    AddParameterVariations(algorithm, localExperiment, ref counter, totalVariations);
     754                  }
    751755                }
    752               }
    753               catch (OperationCanceledException) {
    754                 e.Cancel = true;
    755                 return;
    756               }
    757             } else experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), "Loading failed (" + descriptor.Name + ")");
    758           }
    759         }
    760       }
    761       // this step can take some time
    762       SetMode(DialogMode.PreparingExperiment);
    763       experimentCreationBackgroundWorker.ReportProgress(-1);
    764       localExperiment.Prepare(true);
    765       experimentCreationBackgroundWorker.ReportProgress(100);
    766       Experiment = localExperiment;
     756                catch (OperationCanceledException) {
     757                  e.Cancel = true;
     758                  return;
     759                }
     760              } else experimentCreationBackgroundWorker.ReportProgress((int)Math.Round((100.0 * counter) / totalVariations), "Loading failed (" + descriptor.Name + ")");
     761            }
     762          }
     763        }
     764        // this step can take some time
     765        SetMode(DialogMode.PreparingExperiment);
     766        experimentCreationBackgroundWorker.ReportProgress(-1);
     767        localExperiment.Prepare(true);
     768        experimentCreationBackgroundWorker.ReportProgress(100);
     769        if (Experiments == null) Experiments = new List<Experiment>();
     770        Experiments.Add(localExperiment);
     771      }
    767772    }
    768773
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/CreateExperimentMenuItem.cs

    r9361 r9364  
    5454      if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked) {
    5555        using (CreateExperimentDialog dialog = new CreateExperimentDialog((IOptimizer)activeView.Content)) {
    56           if (dialog.ShowDialog() == DialogResult.OK) MainFormManager.MainForm.ShowContent(dialog.Experiment);
     56          if (dialog.ShowDialog() == DialogResult.OK) {
     57            foreach (var exp in dialog.Experiments) {
     58              MainFormManager.MainForm.ShowContent(exp);
     59            }
     60
     61          }
    5762        }
    5863      }
Note: See TracChangeset for help on using the changeset viewer.