[1050] | 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.Operators;
|
---|
| 31 | using HeuristicLab.Random;
|
---|
| 32 | using HeuristicLab.Selection;
|
---|
| 33 | using HeuristicLab.Logging;
|
---|
| 34 | using HeuristicLab.Data;
|
---|
[1052] | 35 | using HeuristicLab.Operators.Programmable;
|
---|
[1856] | 36 | using HeuristicLab.Modeling;
|
---|
[1050] | 37 |
|
---|
| 38 | namespace HeuristicLab.GP.StructureIdentification {
|
---|
[1287] | 39 | public class StandardGP : AlgorithmBase, IEditable {
|
---|
| 40 |
|
---|
[1857] | 41 | public override string Name { get { return "StandardGP"; } }
|
---|
| 42 |
|
---|
[1922] | 43 | public override int TargetVariable {
|
---|
| 44 | get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; }
|
---|
| 45 | set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | public override Dataset Dataset {
|
---|
| 49 | get { return ProblemInjector.GetVariableValue<Dataset>("Dataset", null, false); }
|
---|
| 50 | set { ProblemInjector.GetVariable("Dataset").Value = value; }
|
---|
| 51 | }
|
---|
| 52 |
|
---|
[1287] | 53 | public virtual int MaxGenerations {
|
---|
| 54 | get { return GetVariableInjector().GetVariable("MaxGenerations").GetValue<IntData>().Data; }
|
---|
| 55 | set { GetVariableInjector().GetVariable("MaxGenerations").GetValue<IntData>().Data = value; }
|
---|
[1050] | 56 | }
|
---|
[1051] | 57 |
|
---|
[1287] | 58 | public virtual int TournamentSize {
|
---|
| 59 | get { return GetVariableInjector().GetVariable("TournamentSize").GetValue<IntData>().Data; }
|
---|
| 60 | set { GetVariableInjector().GetVariable("TournamentSize").GetValue<IntData>().Data = value; }
|
---|
[1050] | 61 | }
|
---|
[1287] | 62 |
|
---|
| 63 | public double FullTreeShakingFactor {
|
---|
| 64 | get { return GetVariableInjector().GetVariable("FullTreeShakingFactor").GetValue<DoubleData>().Data; }
|
---|
| 65 | set { GetVariableInjector().GetVariable("FullTreeShakingFactor").GetValue<DoubleData>().Data = value; }
|
---|
[1050] | 66 | }
|
---|
| 67 |
|
---|
[1287] | 68 | public double OnePointShakingFactor {
|
---|
| 69 | get { return GetVariableInjector().GetVariable("OnePointShakingFactor").GetValue<DoubleData>().Data; }
|
---|
| 70 | set { GetVariableInjector().GetVariable("OnePointShakingFactor").GetValue<DoubleData>().Data = value; }
|
---|
[1051] | 71 | }
|
---|
| 72 |
|
---|
[1287] | 73 | public int MinInitialTreeSize {
|
---|
| 74 | get { return GetVariableInjector().GetVariable("MinInitialTreeSize").GetValue<IntData>().Data; }
|
---|
| 75 | set { GetVariableInjector().GetVariable("MinInitialTreeSize").GetValue<IntData>().Data = value; }
|
---|
[1051] | 76 | }
|
---|
| 77 |
|
---|
[1287] | 78 | public override int MaxTreeSize {
|
---|
| 79 | get {
|
---|
| 80 | return base.MaxTreeSize;
|
---|
| 81 | }
|
---|
[1051] | 82 | set {
|
---|
[1287] | 83 | base.MaxTreeSize = value;
|
---|
| 84 | MinInitialTreeSize = value / 2;
|
---|
[1051] | 85 | }
|
---|
| 86 | }
|
---|
| 87 |
|
---|
[1287] | 88 | public override int PopulationSize {
|
---|
| 89 | get {
|
---|
| 90 | return base.PopulationSize;
|
---|
| 91 | }
|
---|
| 92 | set {
|
---|
| 93 | base.PopulationSize = value;
|
---|
| 94 | Parents = 2 * value;
|
---|
| 95 | }
|
---|
[1051] | 96 | }
|
---|
| 97 |
|
---|
[1287] | 98 | public StandardGP()
|
---|
| 99 | : base() {
|
---|
| 100 | PopulationSize = 10000;
|
---|
[1050] | 101 | MaxGenerations = 100;
|
---|
| 102 | TournamentSize = 7;
|
---|
| 103 | MutationRate = 0.15;
|
---|
[1052] | 104 | Elites = 1;
|
---|
[1287] | 105 | MaxTreeSize = 100;
|
---|
| 106 | MaxTreeHeight = 10;
|
---|
| 107 | FullTreeShakingFactor = 0.1;
|
---|
| 108 | OnePointShakingFactor = 1.0;
|
---|
| 109 | PunishmentFactor = 10.0;
|
---|
| 110 | UseEstimatedTargetValue = false;
|
---|
| 111 | SetSeedRandomly = true;
|
---|
[1050] | 112 | }
|
---|
| 113 |
|
---|
[1287] | 114 | protected internal override IOperator CreateProblemInjector() {
|
---|
| 115 | return new ProblemInjector();
|
---|
| 116 | }
|
---|
[1050] | 117 |
|
---|
[1287] | 118 | protected internal override IOperator CreateSelector() {
|
---|
[1050] | 119 | TournamentSelector selector = new TournamentSelector();
|
---|
| 120 | selector.Name = "Selector";
|
---|
| 121 | selector.GetVariableInfo("Selected").ActualName = "Parents";
|
---|
| 122 | selector.GetVariableInfo("GroupSize").Local = false;
|
---|
| 123 | selector.RemoveVariable("GroupSize");
|
---|
| 124 | selector.GetVariableInfo("GroupSize").ActualName = "TournamentSize";
|
---|
[1287] | 125 | return selector;
|
---|
| 126 | }
|
---|
[1050] | 127 |
|
---|
[1287] | 128 | protected internal override IOperator CreateGlobalInjector() {
|
---|
| 129 | VariableInjector globalInjector = (VariableInjector)base.CreateGlobalInjector();
|
---|
| 130 | globalInjector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", new IntData()));
|
---|
| 131 | globalInjector.AddVariable(new HeuristicLab.Core.Variable("MaxGenerations", new IntData()));
|
---|
| 132 | globalInjector.AddVariable(new HeuristicLab.Core.Variable("FullTreeShakingFactor", new DoubleData()));
|
---|
| 133 | globalInjector.AddVariable(new HeuristicLab.Core.Variable("OnePointShakingFactor", new DoubleData()));
|
---|
| 134 | globalInjector.AddVariable(new HeuristicLab.Core.Variable("MinInitialTreeSize", new IntData()));
|
---|
| 135 | return globalInjector;
|
---|
| 136 | }
|
---|
[1050] | 137 |
|
---|
[1287] | 138 | protected internal override IOperator CreateCrossover() {
|
---|
| 139 | StandardCrossOver crossover = new StandardCrossOver();
|
---|
| 140 | crossover.Name = "Crossover";
|
---|
| 141 | crossover.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 142 | return crossover;
|
---|
| 143 | }
|
---|
[1050] | 144 |
|
---|
[1287] | 145 | protected internal override IOperator CreateTreeCreator() {
|
---|
| 146 | ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator();
|
---|
| 147 | treeCreator.Name = "Tree generator";
|
---|
| 148 | treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 149 | treeCreator.GetVariableInfo("MinTreeSize").ActualName = "MinInitialTreeSize";
|
---|
| 150 | return treeCreator;
|
---|
[1050] | 151 | }
|
---|
| 152 |
|
---|
[1287] | 153 | protected internal override IOperator CreateFunctionLibraryInjector() {
|
---|
[1908] | 154 | FunctionLibraryInjector funLibInjector = new FunctionLibraryInjector();
|
---|
[1873] | 155 | funLibInjector.GetVariableValue<BoolData>("Xor", null, false).Data = false;
|
---|
| 156 | funLibInjector.GetVariableValue<BoolData>("Average", null, false).Data = false;
|
---|
| 157 | return funLibInjector;
|
---|
[1050] | 158 | }
|
---|
| 159 |
|
---|
[1287] | 160 | protected internal override IOperator CreateManipulator() {
|
---|
[1050] | 161 | CombinedOperator manipulator = new CombinedOperator();
|
---|
[1287] | 162 | manipulator.Name = "Manipulator";
|
---|
[1050] | 163 | StochasticMultiBranch multibranch = new StochasticMultiBranch();
|
---|
| 164 | FullTreeShaker fullTreeShaker = new FullTreeShaker();
|
---|
| 165 | fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
[1287] | 166 | fullTreeShaker.GetVariableInfo("ShakingFactor").ActualName = "FullTreeShakingFactor";
|
---|
[1050] | 167 |
|
---|
| 168 | OnePointShaker onepointShaker = new OnePointShaker();
|
---|
| 169 | onepointShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
[1287] | 170 | onepointShaker.GetVariableInfo("ShakingFactor").ActualName = "OnePointShakingFactor";
|
---|
[1050] | 171 | ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation();
|
---|
| 172 | changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 173 | CutOutNodeManipulation cutOutNodeManipulation = new CutOutNodeManipulation();
|
---|
| 174 | cutOutNodeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 175 | DeleteSubTreeManipulation deleteSubTreeManipulation = new DeleteSubTreeManipulation();
|
---|
| 176 | deleteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 177 | SubstituteSubTreeManipulation substituteSubTreeManipulation = new SubstituteSubTreeManipulation();
|
---|
| 178 | substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 179 |
|
---|
[1051] | 180 | IOperator[] manipulators = new IOperator[] {
|
---|
| 181 | onepointShaker, fullTreeShaker,
|
---|
| 182 | changeNodeTypeManipulation,
|
---|
| 183 | cutOutNodeManipulation,
|
---|
| 184 | deleteSubTreeManipulation,
|
---|
| 185 | substituteSubTreeManipulation};
|
---|
| 186 |
|
---|
| 187 | DoubleArrayData probabilities = new DoubleArrayData(new double[manipulators.Length]);
|
---|
[1287] | 188 | for (int i = 0; i < manipulators.Length; i++) {
|
---|
[1051] | 189 | probabilities.Data[i] = 1.0;
|
---|
| 190 | multibranch.AddSubOperator(manipulators[i]);
|
---|
| 191 | }
|
---|
| 192 | multibranch.GetVariableInfo("Probabilities").Local = true;
|
---|
| 193 | multibranch.AddVariable(new HeuristicLab.Core.Variable("Probabilities", probabilities));
|
---|
| 194 |
|
---|
[1050] | 195 | manipulator.OperatorGraph.AddOperator(multibranch);
|
---|
| 196 | manipulator.OperatorGraph.InitialOperator = multibranch;
|
---|
| 197 | return manipulator;
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[1287] | 200 | protected internal override IOperator CreateBestSolutionProcessor() {
|
---|
| 201 | SequentialProcessor bestSolutionProcessor = new SequentialProcessor();
|
---|
| 202 | MeanSquaredErrorEvaluator testMseEvaluator = new MeanSquaredErrorEvaluator();
|
---|
| 203 | testMseEvaluator.Name = "TestMeanSquaredErrorEvaluator";
|
---|
| 204 | testMseEvaluator.GetVariableInfo("MSE").ActualName = "TestQuality";
|
---|
| 205 | testMseEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
|
---|
| 206 | testMseEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
|
---|
| 207 | MeanAbsolutePercentageErrorEvaluator trainingMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
|
---|
| 208 | trainingMapeEvaluator.Name = "TrainingMapeEvaluator";
|
---|
| 209 | trainingMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TrainingMAPE";
|
---|
| 210 | trainingMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
|
---|
| 211 | trainingMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
|
---|
| 212 | MeanAbsolutePercentageErrorEvaluator validationMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
|
---|
| 213 | validationMapeEvaluator.Name = "ValidationMapeEvaluator";
|
---|
| 214 | validationMapeEvaluator.GetVariableInfo("MAPE").ActualName = "ValidationMAPE";
|
---|
| 215 | validationMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
|
---|
| 216 | validationMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
|
---|
| 217 | MeanAbsolutePercentageErrorEvaluator testMapeEvaluator = new MeanAbsolutePercentageErrorEvaluator();
|
---|
| 218 | testMapeEvaluator.Name = "TestMapeEvaluator";
|
---|
| 219 | testMapeEvaluator.GetVariableInfo("MAPE").ActualName = "TestMAPE";
|
---|
| 220 | testMapeEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
|
---|
| 221 | testMapeEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
|
---|
| 222 | MeanAbsolutePercentageOfRangeErrorEvaluator trainingMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator();
|
---|
| 223 | trainingMapreEvaluator.Name = "TrainingMapreEvaluator";
|
---|
| 224 | trainingMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TrainingMAPRE";
|
---|
| 225 | trainingMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
|
---|
| 226 | trainingMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
|
---|
| 227 | MeanAbsolutePercentageOfRangeErrorEvaluator validationMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator();
|
---|
| 228 | validationMapreEvaluator.Name = "ValidationMapreEvaluator";
|
---|
| 229 | validationMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "ValidationMAPRE";
|
---|
| 230 | validationMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
|
---|
| 231 | validationMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
|
---|
| 232 | MeanAbsolutePercentageOfRangeErrorEvaluator testMapreEvaluator = new MeanAbsolutePercentageOfRangeErrorEvaluator();
|
---|
| 233 | testMapreEvaluator.Name = "TestMapreEvaluator";
|
---|
| 234 | testMapreEvaluator.GetVariableInfo("MAPRE").ActualName = "TestMAPRE";
|
---|
| 235 | testMapreEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
|
---|
| 236 | testMapreEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
|
---|
| 237 | CoefficientOfDeterminationEvaluator trainingR2Evaluator = new CoefficientOfDeterminationEvaluator();
|
---|
| 238 | trainingR2Evaluator.Name = "TrainingR2Evaluator";
|
---|
| 239 | trainingR2Evaluator.GetVariableInfo("R2").ActualName = "TrainingR2";
|
---|
| 240 | trainingR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
|
---|
| 241 | trainingR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
|
---|
| 242 | CoefficientOfDeterminationEvaluator validationR2Evaluator = new CoefficientOfDeterminationEvaluator();
|
---|
| 243 | validationR2Evaluator.Name = "ValidationR2Evaluator";
|
---|
| 244 | validationR2Evaluator.GetVariableInfo("R2").ActualName = "ValidationR2";
|
---|
| 245 | validationR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
|
---|
| 246 | validationR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
|
---|
| 247 | CoefficientOfDeterminationEvaluator testR2Evaluator = new CoefficientOfDeterminationEvaluator();
|
---|
| 248 | testR2Evaluator.Name = "TestR2Evaluator";
|
---|
| 249 | testR2Evaluator.GetVariableInfo("R2").ActualName = "TestR2";
|
---|
| 250 | testR2Evaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
|
---|
| 251 | testR2Evaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
|
---|
[1890] | 252 | VarianceAccountedForEvaluator trainingVAFEvaluator = new VarianceAccountedForEvaluator();
|
---|
| 253 | trainingVAFEvaluator.Name = "TrainingVAFEvaluator";
|
---|
| 254 | trainingVAFEvaluator.GetVariableInfo("VAF").ActualName = "TrainingVAF";
|
---|
| 255 | trainingVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
|
---|
| 256 | trainingVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
|
---|
| 257 | VarianceAccountedForEvaluator validationVAFEvaluator = new VarianceAccountedForEvaluator();
|
---|
| 258 | validationVAFEvaluator.Name = "ValidationVAFEvaluator";
|
---|
| 259 | validationVAFEvaluator.GetVariableInfo("VAF").ActualName = "ValidationVAF";
|
---|
| 260 | validationVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
|
---|
| 261 | validationVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
|
---|
| 262 | VarianceAccountedForEvaluator testVAFEvaluator = new VarianceAccountedForEvaluator();
|
---|
| 263 | testVAFEvaluator.Name = "TestVAFEvaluator";
|
---|
| 264 | testVAFEvaluator.GetVariableInfo("VAF").ActualName = "TestVAF";
|
---|
| 265 | testVAFEvaluator.GetVariableInfo("SamplesStart").ActualName = "TestSamplesStart";
|
---|
| 266 | testVAFEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
|
---|
| 267 |
|
---|
[1287] | 268 | ProgrammableOperator progOperator = new ProgrammableOperator();
|
---|
| 269 | progOperator.RemoveVariableInfo("Result");
|
---|
| 270 | progOperator.AddVariableInfo(new HeuristicLab.Core.VariableInfo("EvaluatedSolutions", "", typeof(IntData), VariableKind.In));
|
---|
| 271 | progOperator.Code = @"
|
---|
| 272 | int evalSolutions = EvaluatedSolutions.Data;
|
---|
| 273 | scope.AddVariable(new Variable(""EvaluatedSolutions"", new IntData(evalSolutions)));
|
---|
| 274 | ";
|
---|
| 275 | bestSolutionProcessor.AddSubOperator(testMseEvaluator);
|
---|
| 276 | bestSolutionProcessor.AddSubOperator(trainingMapeEvaluator);
|
---|
| 277 | bestSolutionProcessor.AddSubOperator(validationMapeEvaluator);
|
---|
| 278 | bestSolutionProcessor.AddSubOperator(testMapeEvaluator);
|
---|
| 279 | bestSolutionProcessor.AddSubOperator(trainingMapreEvaluator);
|
---|
| 280 | bestSolutionProcessor.AddSubOperator(validationMapreEvaluator);
|
---|
| 281 | bestSolutionProcessor.AddSubOperator(testMapreEvaluator);
|
---|
| 282 | bestSolutionProcessor.AddSubOperator(trainingR2Evaluator);
|
---|
| 283 | bestSolutionProcessor.AddSubOperator(validationR2Evaluator);
|
---|
| 284 | bestSolutionProcessor.AddSubOperator(testR2Evaluator);
|
---|
[1890] | 285 | bestSolutionProcessor.AddSubOperator(trainingVAFEvaluator);
|
---|
| 286 | bestSolutionProcessor.AddSubOperator(validationVAFEvaluator);
|
---|
| 287 | bestSolutionProcessor.AddSubOperator(testVAFEvaluator);
|
---|
[1287] | 288 | bestSolutionProcessor.AddSubOperator(progOperator);
|
---|
| 289 | return bestSolutionProcessor;
|
---|
[1050] | 290 | }
|
---|
| 291 |
|
---|
[1287] | 292 | protected internal override IOperator CreateLoggingOperator() {
|
---|
| 293 | CombinedOperator loggingOperator = new CombinedOperator();
|
---|
| 294 | loggingOperator.Name = "Logging";
|
---|
[1050] | 295 | SequentialProcessor seq = new SequentialProcessor();
|
---|
[1287] | 296 |
|
---|
[1050] | 297 | DataCollector collector = new DataCollector();
|
---|
| 298 | ItemList<StringData> names = collector.GetVariable("VariableNames").GetValue<ItemList<StringData>>();
|
---|
| 299 | names.Add(new StringData("BestQuality"));
|
---|
| 300 | names.Add(new StringData("AverageQuality"));
|
---|
| 301 | names.Add(new StringData("WorstQuality"));
|
---|
[1052] | 302 | names.Add(new StringData("BestValidationQuality"));
|
---|
| 303 | names.Add(new StringData("AverageValidationQuality"));
|
---|
| 304 | names.Add(new StringData("WorstValidationQuality"));
|
---|
[1050] | 305 | LinechartInjector lineChartInjector = new LinechartInjector();
|
---|
| 306 | lineChartInjector.GetVariableInfo("Linechart").ActualName = "Quality Linechart";
|
---|
[1052] | 307 | lineChartInjector.GetVariable("NumberOfLines").GetValue<IntData>().Data = 6;
|
---|
[1050] | 308 | QualityLogger qualityLogger = new QualityLogger();
|
---|
[1052] | 309 | QualityLogger validationQualityLogger = new QualityLogger();
|
---|
[1287] | 310 | validationQualityLogger.Name = "ValidationQualityLogger";
|
---|
[1052] | 311 | validationQualityLogger.GetVariableInfo("Quality").ActualName = "ValidationQuality";
|
---|
| 312 | validationQualityLogger.GetVariableInfo("QualityLog").ActualName = "ValidationQualityLog";
|
---|
[1051] | 313 |
|
---|
| 314 | seq.AddSubOperator(collector);
|
---|
| 315 | seq.AddSubOperator(lineChartInjector);
|
---|
| 316 | seq.AddSubOperator(qualityLogger);
|
---|
[1052] | 317 | seq.AddSubOperator(validationQualityLogger);
|
---|
[1051] | 318 |
|
---|
[1287] | 319 | loggingOperator.OperatorGraph.AddOperator(seq);
|
---|
| 320 | loggingOperator.OperatorGraph.InitialOperator = seq;
|
---|
| 321 | return loggingOperator;
|
---|
[1050] | 322 | }
|
---|
| 323 |
|
---|
[1906] | 324 | protected internal override Model CreateGPModel(IScope bestModelScope) {
|
---|
| 325 | Model model = base.CreateGPModel(bestModelScope);
|
---|
| 326 | model.TestMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("TestQuality", false).Data;
|
---|
[1922] | 327 | model.TrainingCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TrainingR2", false).Data;
|
---|
| 328 | model.ValidationCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data;
|
---|
| 329 | model.TestCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TestR2", false).Data;
|
---|
| 330 | model.TrainingMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TrainingMAPE", false).Data;
|
---|
| 331 | model.ValidationMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data;
|
---|
| 332 | model.TestMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data;
|
---|
| 333 | model.TrainingMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TrainingMAPRE", false).Data;
|
---|
| 334 | model.ValidationMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data;
|
---|
| 335 | model.TestMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data;
|
---|
| 336 | model.TrainingVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TrainingVAF", false).Data;
|
---|
| 337 | model.ValidationVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data;
|
---|
| 338 | model.TestVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data;
|
---|
| 339 |
|
---|
[1906] | 340 | return model;
|
---|
| 341 | }
|
---|
| 342 |
|
---|
[1287] | 343 | public virtual IEditor CreateEditor() {
|
---|
[1051] | 344 | return new StandardGpEditor(this);
|
---|
| 345 | }
|
---|
| 346 |
|
---|
[1052] | 347 | public override IView CreateView() {
|
---|
[1051] | 348 | return new StandardGpEditor(this);
|
---|
| 349 | }
|
---|
[1050] | 350 | }
|
---|
| 351 | }
|
---|