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