Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/24/16 20:30:20 (9 years ago)
Author:
bburlacu
Message:

#2288: Improve the CreateTargetVariationExperimentDialog to produce combinations of inputs and target according to a user-provided binomial coefficient.

Location:
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.Designer.cs

    r12320 r13788  
    2929        private void InitializeComponent()
    3030        {
    31             this.repetitionsNumericUpDown = new System.Windows.Forms.NumericUpDown();
    32             this.repetitionsLabel = new System.Windows.Forms.Label();
    33             this.cancelButton = new System.Windows.Forms.Button();
    34             this.okButton = new System.Windows.Forms.Button();
    35             ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
    36             this.SuspendLayout();
    37             //
    38             // repetitionsNumericUpDown
    39             //
    40             this.repetitionsNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     31      this.repetitionsNumericUpDown = new System.Windows.Forms.NumericUpDown();
     32      this.repetitionsLabel = new System.Windows.Forms.Label();
     33      this.cancelButton = new System.Windows.Forms.Button();
     34      this.okButton = new System.Windows.Forms.Button();
     35      this.binomialCoeffNumericUpDown = new System.Windows.Forms.NumericUpDown();
     36      this.label1 = new System.Windows.Forms.Label();
     37      this.label2 = new System.Windows.Forms.Label();
     38      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
     39      ((System.ComponentModel.ISupportInitialize)(this.binomialCoeffNumericUpDown)).BeginInit();
     40      this.SuspendLayout();
     41      //
     42      // repetitionsNumericUpDown
     43      //
     44      this.repetitionsNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    4145            | System.Windows.Forms.AnchorStyles.Right)));
    42             this.repetitionsNumericUpDown.Location = new System.Drawing.Point(108, 12);
    43             this.repetitionsNumericUpDown.Maximum = new decimal(new int[] {
     46      this.repetitionsNumericUpDown.Location = new System.Drawing.Point(128, 12);
     47      this.repetitionsNumericUpDown.Maximum = new decimal(new int[] {
    4448            1000000,
    4549            0,
    4650            0,
    4751            0});
    48             this.repetitionsNumericUpDown.Minimum = new decimal(new int[] {
     52      this.repetitionsNumericUpDown.Minimum = new decimal(new int[] {
    4953            1,
    5054            0,
    5155            0,
    5256            0});
    53             this.repetitionsNumericUpDown.Name = "repetitionsNumericUpDown";
    54             this.repetitionsNumericUpDown.Size = new System.Drawing.Size(185, 20);
    55             this.repetitionsNumericUpDown.TabIndex = 4;
    56             this.repetitionsNumericUpDown.ThousandsSeparator = true;
    57             this.repetitionsNumericUpDown.Value = new decimal(new int[] {
     57      this.repetitionsNumericUpDown.Name = "repetitionsNumericUpDown";
     58      this.repetitionsNumericUpDown.Size = new System.Drawing.Size(185, 20);
     59      this.repetitionsNumericUpDown.TabIndex = 4;
     60      this.repetitionsNumericUpDown.ThousandsSeparator = true;
     61      this.repetitionsNumericUpDown.Value = new decimal(new int[] {
    5862            10,
    5963            0,
    6064            0,
    6165            0});
    62             this.repetitionsNumericUpDown.Validated += new System.EventHandler(this.repetitionsNumericUpDown_Validated);
    63             //
    64             // repetitionsLabel
    65             //
    66             this.repetitionsLabel.AutoSize = true;
    67             this.repetitionsLabel.Location = new System.Drawing.Point(26, 14);
    68             this.repetitionsLabel.Name = "repetitionsLabel";
    69             this.repetitionsLabel.Size = new System.Drawing.Size(63, 13);
    70             this.repetitionsLabel.TabIndex = 5;
    71             this.repetitionsLabel.Text = "&Repetitions:";
    72             //
    73             // cancelButton
    74             //
    75             this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    76             this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    77             this.cancelButton.Location = new System.Drawing.Point(177, 48);
    78             this.cancelButton.Name = "cancelButton";
    79             this.cancelButton.Size = new System.Drawing.Size(75, 23);
    80             this.cancelButton.TabIndex = 9;
    81             this.cancelButton.Text = "&Cancel";
    82             this.cancelButton.UseVisualStyleBackColor = true;
    83             //
    84             // okButton
    85             //
    86             this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    87             this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    88             this.okButton.Location = new System.Drawing.Point(80, 48);
    89             this.okButton.Name = "okButton";
    90             this.okButton.Size = new System.Drawing.Size(75, 23);
    91             this.okButton.TabIndex = 10;
    92             this.okButton.Text = "&Ok";
    93             this.okButton.UseVisualStyleBackColor = true;
    94             this.okButton.Click += new System.EventHandler(this.okButton_Click);
    95             //
    96             // CreateTargetVariationExperimentDialog
    97             //
    98             this.AcceptButton = this.okButton;
    99             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    100             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    101             this.CancelButton = this.cancelButton;
    102             this.ClientSize = new System.Drawing.Size(349, 83);
    103             this.Controls.Add(this.okButton);
    104             this.Controls.Add(this.cancelButton);
    105             this.Controls.Add(this.repetitionsLabel);
    106             this.Controls.Add(this.repetitionsNumericUpDown);
    107             this.Name = "CreateTargetVariationExperimentDialog";
    108             this.Text = "Create Target Variation Experiment";
    109             ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
    110             this.ResumeLayout(false);
    111             this.PerformLayout();
     66      this.repetitionsNumericUpDown.Validated += new System.EventHandler(this.repetitionsNumericUpDown_Validated);
     67      //
     68      // repetitionsLabel
     69      //
     70      this.repetitionsLabel.AutoSize = true;
     71      this.repetitionsLabel.Location = new System.Drawing.Point(26, 14);
     72      this.repetitionsLabel.Name = "repetitionsLabel";
     73      this.repetitionsLabel.Size = new System.Drawing.Size(63, 13);
     74      this.repetitionsLabel.TabIndex = 5;
     75      this.repetitionsLabel.Text = "&Repetitions:";
     76      //
     77      // cancelButton
     78      //
     79      this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     80      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     81      this.cancelButton.Location = new System.Drawing.Point(177, 130);
     82      this.cancelButton.Name = "cancelButton";
     83      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     84      this.cancelButton.TabIndex = 9;
     85      this.cancelButton.Text = "&Cancel";
     86      this.cancelButton.UseVisualStyleBackColor = true;
     87      //
     88      // okButton
     89      //
     90      this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     91      this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     92      this.okButton.Location = new System.Drawing.Point(80, 130);
     93      this.okButton.Name = "okButton";
     94      this.okButton.Size = new System.Drawing.Size(75, 23);
     95      this.okButton.TabIndex = 10;
     96      this.okButton.Text = "&Ok";
     97      this.okButton.UseVisualStyleBackColor = true;
     98      this.okButton.Click += new System.EventHandler(this.okButton_Click);
     99      //
     100      // binomialCoeffNumericUpDown
     101      //
     102      this.binomialCoeffNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     103            | System.Windows.Forms.AnchorStyles.Right)));
     104      this.binomialCoeffNumericUpDown.Location = new System.Drawing.Point(128, 38);
     105      this.binomialCoeffNumericUpDown.Maximum = new decimal(new int[] {
     106            1000000,
     107            0,
     108            0,
     109            0});
     110      this.binomialCoeffNumericUpDown.Minimum = new decimal(new int[] {
     111            1,
     112            0,
     113            0,
     114            0});
     115      this.binomialCoeffNumericUpDown.Name = "binomialCoeffNumericUpDown";
     116      this.binomialCoeffNumericUpDown.Size = new System.Drawing.Size(185, 20);
     117      this.binomialCoeffNumericUpDown.TabIndex = 4;
     118      this.binomialCoeffNumericUpDown.ThousandsSeparator = true;
     119      this.binomialCoeffNumericUpDown.Value = new decimal(new int[] {
     120            10,
     121            0,
     122            0,
     123            0});
     124      this.binomialCoeffNumericUpDown.Validated += new System.EventHandler(this.binomialCoefficientNumericUpDown_Validated);
     125      //
     126      // label1
     127      //
     128      this.label1.AutoSize = true;
     129      this.label1.Location = new System.Drawing.Point(26, 40);
     130      this.label1.Name = "label1";
     131      this.label1.Size = new System.Drawing.Size(79, 13);
     132      this.label1.TabIndex = 5;
     133      this.label1.Text = "&Binomial coeff.:";
     134      //
     135      // label2
     136      //
     137      this.label2.ForeColor = System.Drawing.Color.Red;
     138      this.label2.Location = new System.Drawing.Point(26, 67);
     139      this.label2.Name = "label2";
     140      this.label2.Size = new System.Drawing.Size(287, 50);
     141      this.label2.TabIndex = 5;
     142      this.label2.Text = "Warning: depending on the binomial coefficient and the number of variables, this " +
     143    "can create very large experiments. ";
     144      //
     145      // CreateTargetVariationExperimentDialog
     146      //
     147      this.AcceptButton = this.okButton;
     148      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     149      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     150      this.CancelButton = this.cancelButton;
     151      this.ClientSize = new System.Drawing.Size(349, 165);
     152      this.Controls.Add(this.okButton);
     153      this.Controls.Add(this.cancelButton);
     154      this.Controls.Add(this.label2);
     155      this.Controls.Add(this.label1);
     156      this.Controls.Add(this.repetitionsLabel);
     157      this.Controls.Add(this.binomialCoeffNumericUpDown);
     158      this.Controls.Add(this.repetitionsNumericUpDown);
     159      this.Name = "CreateTargetVariationExperimentDialog";
     160      this.Text = "Create Target Variation Experiment";
     161      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
     162      ((System.ComponentModel.ISupportInitialize)(this.binomialCoeffNumericUpDown)).EndInit();
     163      this.ResumeLayout(false);
     164      this.PerformLayout();
    112165
    113166        }
     
    119172        private System.Windows.Forms.Button cancelButton;
    120173        private System.Windows.Forms.Button okButton;
    121     }
     174    private System.Windows.Forms.NumericUpDown binomialCoeffNumericUpDown;
     175    private System.Windows.Forms.Label label1;
     176    private System.Windows.Forms.Label label2;
     177  }
    122178}
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.cs

    r13664 r13788  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Windows.Forms;
     
    3132    public Experiment Experiment { get; private set; }
    3233    private int repetitions;
     34    private int binomialCoefficient;
    3335
    3436    public CreateTargetVariationExperimentDialog() : this(null) { }
     
    4749    }
    4850
     51    private void binomialCoefficientNumericUpDown_Validated(object sender, EventArgs e) {
     52      if (binomialCoeffNumericUpDown.Text == string.Empty)
     53        binomialCoeffNumericUpDown.Text = binomialCoeffNumericUpDown.Value.ToString();
     54      binomialCoefficient = (int)binomialCoeffNumericUpDown.Value;
     55    }
     56
    4957    public Experiment CreateVariableCombinations(IAlgorithm algorithm) {
    5058      var experiment = new Experiment("Target Variation Experiment");
     
    6169
    6270      for (int i = 0; i < variables.Count; i++) {
    63         var alg = (IAlgorithm)algorithm.Clone();
    64         var pd = ((IRegressionProblem)alg.Problem).ProblemData;
     71        var target = variables[i];
     72        var inputs = variables.Where(x => x != target).ToList();
     73        var combinations = Util.Combinations(inputs, binomialCoefficient);
    6574
    66         for (int j = 0; j < variables.Count; ++j)
    67           pd.InputVariables.SetItemCheckedState(pd.InputVariables[j], true);
     75        foreach (var combination in combinations) {
     76          var h = new HashSet<string>(combination);
     77          var alg = (IAlgorithm)algorithm.Clone();
     78          var pd = ((IRegressionProblem)alg.Problem).ProblemData;
     79          pd.TargetVariable = target;
     80          alg.Name += "{Target = " + target + ", Inputs = (" + combination.Aggregate((a, b) => a + "," + b) + ")}";
    6881
    69         pd.InputVariables.SetItemCheckedState(pd.InputVariables[i], false);
    70         pd.TargetVariable = pd.InputVariables[i].Value;
     82          foreach (var item in pd.InputVariables) {
     83            pd.InputVariables.SetItemCheckedState(item, h.Contains(item.Value));
     84          }
    7185
    72         alg.Name += "{Target = " + pd.TargetVariable + "}";
     86          var batchrun = new BatchRun(string.Format("Batchrun {0}", i + 1)) {
     87            Repetitions = repetitions,
     88            Optimizer = alg
     89          };
    7390
    74         var batchrun = new BatchRun(string.Format("Batchrun {0}", i + 1)) {
    75           Repetitions = repetitions,
    76           Optimizer = alg
    77         };
    78 
    79         experiment.Optimizers.Add(batchrun);
     91          experiment.Optimizers.Add(batchrun);
     92        }
    8093      }
    8194      return experiment;
Note: See TracChangeset for help on using the changeset viewer.