Free cookie consent management tool by TermsFeed Policy Generator

source: branches/gp-algorithms-refactoring-#720/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs @ 2337

Last change on this file since 2337 was 2337, checked in by gkronber, 15 years ago

refactoring: pulled common code of OSGP and SGP into static class DefaultStructureIdentificationOperators. #720

File size: 4.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 HeuristicLab.Core;
23using HeuristicLab.DataAnalysis;
24using HeuristicLab.GP.Interfaces;
25using HeuristicLab.Operators;
26using HeuristicLab.Modeling;
27using HeuristicLab.Logging;
28
29namespace HeuristicLab.GP.StructureIdentification {
30  internal static class DefaultStructureIdentificationAlgorithmOperators {
31    internal static IOperator CreateFunctionLibraryInjector() {
32      CombinedOperator op = new CombinedOperator();
33      op.Name = "FunctionLibraryInjector";
34      SequentialProcessor seq = new SequentialProcessor();
35      seq.AddSubOperator(new FunctionLibraryInjector());
36      seq.AddSubOperator(new HL2TreeEvaluatorInjector());
37      op.OperatorGraph.AddOperator(seq);
38      op.OperatorGraph.InitialOperator = seq;
39      return op;
40    }
41
42    internal static IOperator CreateProblemInjector() {
43      return new ProblemInjector();
44    }
45
46    internal static IOperator CreateInitialPopulationEvaluator() {
47      MeanSquaredErrorEvaluator eval = new MeanSquaredErrorEvaluator();
48      eval.Name = "Evaluator";
49      eval.GetVariableInfo("MSE").ActualName = "Quality";
50      eval.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
51      eval.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
52      return eval;
53    }
54
55    internal static IOperator CreateEvaluator() {
56      return CreateInitialPopulationEvaluator();
57    }
58
59    internal static IOperator CreateGenerationStepHook() {
60      CombinedOperator op = new CombinedOperator();
61      SequentialProcessor seq = new SequentialProcessor();
62      UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
63      SequentialProcessor individualProc = new SequentialProcessor();
64      MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();
65      validationEvaluator.Name = "ValidationEvaluator";
66      validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
67      validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
68      validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
69
70      individualProc.AddSubOperator(validationEvaluator);
71
72      BestSolutionStorer solutionStorer = new BestSolutionStorer();
73      solutionStorer.GetVariableInfo("BestSolution").ActualName = "BestValidationSolution";
74      solutionStorer.GetVariableInfo("Quality").ActualName = "ValidationQuality";
75
76      BestAverageWorstQualityCalculator validationQualityCalculator = new BestAverageWorstQualityCalculator();
77      validationQualityCalculator.Name = "BestAverageWorstValidationQualityCalculator";
78      validationQualityCalculator.GetVariableInfo("Quality").ActualName = "ValidationQuality";
79      validationQualityCalculator.GetVariableInfo("BestQuality").ActualName = "BestValidationQuality";
80      validationQualityCalculator.GetVariableInfo("AverageQuality").ActualName = "AverageValidationQuality";
81      validationQualityCalculator.GetVariableInfo("WorstQuality").ActualName = "WorstValidationQuality";
82
83      subScopesProc.AddSubOperator(individualProc);
84
85      seq.AddSubOperator(subScopesProc);
86      seq.AddSubOperator(solutionStorer);
87      seq.AddSubOperator(validationQualityCalculator);
88
89      op.OperatorGraph.AddOperator(seq);
90      op.OperatorGraph.InitialOperator = seq;
91      return op;
92    }
93  }
94}
Note: See TracBrowser for help on using the repository browser.