1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using System.Text;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using System.Xml;
|
---|
28 | using System.Diagnostics;
|
---|
29 | using HeuristicLab.DataAnalysis;
|
---|
30 | using HeuristicLab.Data;
|
---|
31 | using HeuristicLab.Operators;
|
---|
32 | using HeuristicLab.Logging;
|
---|
33 |
|
---|
34 | namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
|
---|
35 | public class OffspringSelectionGP : HeuristicLab.GP.StructureIdentification.OffspringSelectionGP {
|
---|
36 | private BoolData autoregressive = new BoolData();
|
---|
37 | public bool Autoregressive {
|
---|
38 | get { return autoregressive.Data; }
|
---|
39 | set { autoregressive.Data = value; }
|
---|
40 | }
|
---|
41 |
|
---|
42 | protected override IOperator CreateFunctionLibraryInjector() {
|
---|
43 | return new FunctionLibraryInjector();
|
---|
44 | }
|
---|
45 |
|
---|
46 | protected override IOperator CreateProblemInjector() {
|
---|
47 | return new ProblemInjector();
|
---|
48 | }
|
---|
49 |
|
---|
50 | protected override IOperator CreateGlobalInjector() {
|
---|
51 | VariableInjector injector = (VariableInjector)base.CreateGlobalInjector();
|
---|
52 | injector.AddVariable(new HeuristicLab.Core.Variable("Autoregressive", autoregressive));
|
---|
53 | return injector;
|
---|
54 | }
|
---|
55 |
|
---|
56 | protected override IOperator CreateBestSolutionProcessor() {
|
---|
57 | IOperator seq = base.CreateBestSolutionProcessor();
|
---|
58 | TheilInequalityCoefficientEvaluator trainingTheil = new TheilInequalityCoefficientEvaluator();
|
---|
59 | trainingTheil.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
|
---|
60 | trainingTheil.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
|
---|
61 | trainingTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TrainingTheilInequalityCoefficient";
|
---|
62 | trainingTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TrainingTheilInequalityCoefficientBias";
|
---|
63 | trainingTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TrainingTheilInequalityCoefficientVariance";
|
---|
64 | trainingTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TrainingTheilInequalityCoefficientCovariance";
|
---|
65 |
|
---|
66 | TheilInequalityCoefficientEvaluator validationTheil = new TheilInequalityCoefficientEvaluator();
|
---|
67 | validationTheil.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
|
---|
68 | validationTheil.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
|
---|
69 | validationTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "ValidationTheilInequalityCoefficient";
|
---|
70 | validationTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "ValidationTheilInequalityCoefficientBias";
|
---|
71 | validationTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "ValidationTheilInequalityCoefficientVariance";
|
---|
72 | validationTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "ValidationTheilInequalityCoefficientCovariance";
|
---|
73 |
|
---|
74 | TheilInequalityCoefficientEvaluator testTheil = new TheilInequalityCoefficientEvaluator();
|
---|
75 | testTheil.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
|
---|
76 | testTheil.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
|
---|
77 | testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient";
|
---|
78 | testTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TestTheilInequalityCoefficientBias";
|
---|
79 | testTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TestTheilInequalityCoefficientVariance";
|
---|
80 | testTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TestTheilInequalityCoefficientCovariance";
|
---|
81 |
|
---|
82 | SimpleEvaluator trainingEvaluator = new SimpleEvaluator();
|
---|
83 | trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
|
---|
84 | trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
|
---|
85 | trainingEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTraining";
|
---|
86 |
|
---|
87 | SimpleEvaluator validationEvaluator = new SimpleEvaluator();
|
---|
88 | validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
|
---|
89 | validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
|
---|
90 | validationEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesValidation";
|
---|
91 |
|
---|
92 | SimpleEvaluator testEvaluator = new SimpleEvaluator();
|
---|
93 | testEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
|
---|
94 | testEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
|
---|
95 | testEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTest";
|
---|
96 |
|
---|
97 | LinechartInjector trainingChartInjector = new LinechartInjector();
|
---|
98 | trainingChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
|
---|
99 | trainingChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesTraining";
|
---|
100 | trainingChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartTrainingPredictedValues";
|
---|
101 |
|
---|
102 | LinechartInjector validationChartInjector = new LinechartInjector();
|
---|
103 | validationChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
|
---|
104 | validationChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesValidation";
|
---|
105 | validationChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartValidationPredictedValues";
|
---|
106 |
|
---|
107 | LinechartInjector testChartInjector = new LinechartInjector();
|
---|
108 | testChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
|
---|
109 | testChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesTest";
|
---|
110 | testChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartTestPredictedValues";
|
---|
111 |
|
---|
112 | seq.AddSubOperator(trainingTheil);
|
---|
113 | seq.AddSubOperator(validationTheil);
|
---|
114 | seq.AddSubOperator(testTheil);
|
---|
115 | seq.AddSubOperator(trainingEvaluator);
|
---|
116 | seq.AddSubOperator(trainingChartInjector);
|
---|
117 | seq.AddSubOperator(validationEvaluator);
|
---|
118 | seq.AddSubOperator(validationChartInjector);
|
---|
119 | seq.AddSubOperator(testEvaluator);
|
---|
120 | seq.AddSubOperator(testChartInjector);
|
---|
121 |
|
---|
122 | return seq;
|
---|
123 | }
|
---|
124 |
|
---|
125 | public override IEditor CreateEditor() {
|
---|
126 | return new OffspringSelectionGpEditor(this);
|
---|
127 | }
|
---|
128 |
|
---|
129 | public override IView CreateView() {
|
---|
130 | return new OffspringSelectionGpEditor(this);
|
---|
131 | }
|
---|
132 | }
|
---|
133 | }
|
---|