[12198] | 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();
|
---|
[12229] | 37 | var pd = ((IRegressionProblem)alg.Problem).ProblemData;
|
---|
[12198] | 38 |
|
---|
| 39 | // check all input variables
|
---|
| 40 | foreach(var v in pd.InputVariables)
|
---|
| 41 | pd.InputVariables.SetItemCheckedState(v, true);
|
---|
| 42 |
|
---|
| 43 | // set target to false
|
---|
| 44 | pd.InputVariables.SetItemCheckedState(pd.InputVariables[i], false);
|
---|
| 45 |
|
---|
| 46 | pd.TargetVariable = pd.InputVariables[i].Value;
|
---|
| 47 | alg.Name += "{Target variable=" + pd.TargetVariable + "}";
|
---|
[12229] | 48 |
|
---|
[12198] | 49 | var batchrun = new BatchRun("Batchrun" + i)
|
---|
| 50 | {
|
---|
| 51 | Repetitions = 10,
|
---|
| 52 | Optimizer = alg
|
---|
| 53 | };
|
---|
| 54 |
|
---|
| 55 | experiment.Optimizers.Add(batchrun);
|
---|
| 56 | }
|
---|
| 57 | return experiment;
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | } |
---|