1 | using System;
|
---|
2 | using System.CodeDom;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 | using System.Windows.Forms;
|
---|
8 | using HeuristicLab.Data;
|
---|
9 | using HeuristicLab.Optimization;
|
---|
10 | using HeuristicLab.Persistence;
|
---|
11 | using HeuristicLab.Persistence.Default.Xml;
|
---|
12 | using HeuristicLab.Problems.DataAnalysis;
|
---|
13 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
14 | using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
|
---|
15 |
|
---|
16 | namespace HeuristicLab.VariableInteractionNetworks {
|
---|
17 | class TargetVariation
|
---|
18 | {
|
---|
19 | public static Experiment CreateVariableCombinations(IAlgorithm algorithm)
|
---|
20 | {
|
---|
21 | var experiment = new Experiment("Target Variation Experiment");
|
---|
22 |
|
---|
23 | if (algorithm == null)
|
---|
24 | throw new InvalidOperationException("Null algorithm!");
|
---|
25 |
|
---|
26 | var problem = algorithm.Problem;
|
---|
27 | var regressionProblem = problem as IRegressionProblem;
|
---|
28 | if (regressionProblem == null)
|
---|
29 | throw new Exception();
|
---|
30 |
|
---|
31 | var problemData = regressionProblem.ProblemData;
|
---|
32 | var variables = problemData.InputVariables.ToList();
|
---|
33 |
|
---|
34 | for (int i = 0; i < variables.Count; i++)
|
---|
35 | {
|
---|
36 | var alg = (IAlgorithm)algorithm.Clone();
|
---|
37 | var rp = (IRegressionProblem) alg.Problem;
|
---|
38 | var pd = rp.ProblemData;
|
---|
39 |
|
---|
40 | // check all input variables
|
---|
41 | foreach(var v in pd.InputVariables)
|
---|
42 | pd.InputVariables.SetItemCheckedState(v, true);
|
---|
43 |
|
---|
44 | // set target to false
|
---|
45 | pd.InputVariables.SetItemCheckedState(pd.InputVariables[i], false);
|
---|
46 |
|
---|
47 | pd.TargetVariable = pd.InputVariables[i].Value;
|
---|
48 | alg.Name += "{Target variable=" + pd.TargetVariable + "}";
|
---|
49 |
|
---|
50 |
|
---|
51 | var batchrun = new BatchRun("Batchrun" + i)
|
---|
52 | {
|
---|
53 | Repetitions = 10,
|
---|
54 | Optimizer = alg
|
---|
55 | };
|
---|
56 |
|
---|
57 | experiment.Optimizers.Add(batchrun);
|
---|
58 | }
|
---|
59 | return experiment;
|
---|
60 | }
|
---|
61 | }
|
---|
62 | } |
---|