Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive_Milestone3/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/3.3/StandardGP.cs @ 4695

Last change on this file since 4695 was 1857, checked in by gkronber, 16 years ago

Worked on lose coupling of CEDMA and GP/SVR with plugin HeuristicLab.Modeling as common bridge. #635

File size: 7.2 KB
Line 
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
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Xml;
28using System.Diagnostics;
29using HeuristicLab.DataAnalysis;
30using HeuristicLab.Data;
31using HeuristicLab.Operators;
32using HeuristicLab.Logging;
33using HeuristicLab.Modeling;
34
35namespace HeuristicLab.GP.StructureIdentification.TimeSeries {
36  public class StandardGP : HeuristicLab.GP.StructureIdentification.StandardGP, ITimeSeriesAlgorithm {
37    public bool Autoregressive {
38      get { return ProblemInjector.GetVariable("Autoregressive").GetValue<BoolData>().Data; }
39      set { ProblemInjector.GetVariable("Autoregressive").GetValue<BoolData>().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 CreateBestSolutionProcessor() {
51      IOperator seq = base.CreateBestSolutionProcessor();
52      seq.AddSubOperator(BestSolutionProcessor);
53      return seq;
54    }
55
56    public override IEditor CreateEditor() {
57      return new StandardGpEditor(this);
58    }
59
60    public override IView CreateView() {
61      return new StandardGpEditor(this);
62    }
63
64    internal static IOperator BestSolutionProcessor {
65      get {
66        SequentialProcessor seq = new SequentialProcessor();
67        TheilInequalityCoefficientEvaluator trainingTheil = new TheilInequalityCoefficientEvaluator();
68        trainingTheil.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
69        trainingTheil.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
70        trainingTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TrainingTheilInequalityCoefficient";
71        trainingTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TrainingTheilInequalityCoefficientBias";
72        trainingTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TrainingTheilInequalityCoefficientVariance";
73        trainingTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TrainingTheilInequalityCoefficientCovariance";
74
75        TheilInequalityCoefficientEvaluator validationTheil = new TheilInequalityCoefficientEvaluator();
76        validationTheil.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
77        validationTheil.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
78        validationTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "ValidationTheilInequalityCoefficient";
79        validationTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "ValidationTheilInequalityCoefficientBias";
80        validationTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "ValidationTheilInequalityCoefficientVariance";
81        validationTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "ValidationTheilInequalityCoefficientCovariance";
82
83        TheilInequalityCoefficientEvaluator testTheil = new TheilInequalityCoefficientEvaluator();
84        testTheil.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
85        testTheil.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
86        testTheil.GetVariableInfo("TheilInequalityCoefficient").ActualName = "TestTheilInequalityCoefficient";
87        testTheil.GetVariableInfo("TheilInequalityCoefficientBias").ActualName = "TestTheilInequalityCoefficientBias";
88        testTheil.GetVariableInfo("TheilInequalityCoefficientVariance").ActualName = "TestTheilInequalityCoefficientVariance";
89        testTheil.GetVariableInfo("TheilInequalityCoefficientCovariance").ActualName = "TestTheilInequalityCoefficientCovariance";
90
91        SimpleEvaluator trainingEvaluator = new SimpleEvaluator();
92        trainingEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
93        trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
94        trainingEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTraining";
95
96        SimpleEvaluator validationEvaluator = new SimpleEvaluator();
97        validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
98        validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
99        validationEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesValidation";
100
101        SimpleEvaluator testEvaluator = new SimpleEvaluator();
102        testEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
103        testEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
104        testEvaluator.GetVariableInfo("Values").ActualName = "PredictedValuesTest";
105
106        LinechartInjector trainingChartInjector = new LinechartInjector();
107        trainingChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
108        trainingChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesTraining";
109        trainingChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartTrainingPredictedValues";
110
111        LinechartInjector validationChartInjector = new LinechartInjector();
112        validationChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
113        validationChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesValidation";
114        validationChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartValidationPredictedValues";
115
116        LinechartInjector testChartInjector = new LinechartInjector();
117        testChartInjector.GetVariableValue<IntData>("NumberOfLines", null, false).Data = 2;
118        testChartInjector.GetVariableInfo("Values").ActualName = "PredictedValuesTest";
119        testChartInjector.GetVariableInfo("Linechart").ActualName = "LinechartTestPredictedValues";
120
121        seq.AddSubOperator(trainingTheil);
122        seq.AddSubOperator(validationTheil);
123        seq.AddSubOperator(testTheil);
124        seq.AddSubOperator(trainingEvaluator);
125        seq.AddSubOperator(trainingChartInjector);
126        seq.AddSubOperator(validationEvaluator);
127        seq.AddSubOperator(validationChartInjector);
128        seq.AddSubOperator(testEvaluator);
129        seq.AddSubOperator(testChartInjector);
130
131        return seq;
132      }
133    }
134  }
135}
Note: See TracBrowser for help on using the repository browser.