Changeset 13788 for branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.cs
- Timestamp:
- 04/24/16 20:30:20 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/CreateTargetVariationExperimentDialog.cs
r13664 r13788 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using System.Windows.Forms; … … 31 32 public Experiment Experiment { get; private set; } 32 33 private int repetitions; 34 private int binomialCoefficient; 33 35 34 36 public CreateTargetVariationExperimentDialog() : this(null) { } … … 47 49 } 48 50 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 49 57 public Experiment CreateVariableCombinations(IAlgorithm algorithm) { 50 58 var experiment = new Experiment("Target Variation Experiment"); … … 61 69 62 70 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); 65 74 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) + ")}"; 68 81 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 } 71 85 72 alg.Name += "{Target = " + pd.TargetVariable + "}"; 86 var batchrun = new BatchRun(string.Format("Batchrun {0}", i + 1)) { 87 Repetitions = repetitions, 88 Optimizer = alg 89 }; 73 90 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 } 80 93 } 81 94 return experiment;
Note: See TracChangeset
for help on using the changeset viewer.