[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;
|
---|
| 35 |
|
---|
| 36 | namespace HeuristicLab.GP.StructureIdentification {
|
---|
[1051] | 37 | public class StandardGP : ItemBase, IEditable {
|
---|
[1050] | 38 | private IntData maxGenerations = new IntData();
|
---|
| 39 | public int MaxGenerations {
|
---|
| 40 | get { return maxGenerations.Data; }
|
---|
| 41 | set { maxGenerations.Data = value; }
|
---|
| 42 | }
|
---|
[1051] | 43 |
|
---|
[1050] | 44 | private IntData tournamentSize = new IntData();
|
---|
| 45 | public int TournamentSize {
|
---|
| 46 | get { return tournamentSize.Data; }
|
---|
| 47 | set { tournamentSize.Data = value; }
|
---|
| 48 | }
|
---|
| 49 | private DoubleData mutationRate = new DoubleData();
|
---|
| 50 | public double MutationRate {
|
---|
| 51 | get { return mutationRate.Data; }
|
---|
| 52 | set { mutationRate.Data = value; }
|
---|
| 53 | }
|
---|
| 54 | private IntData parents = new IntData();
|
---|
| 55 | private IntData populationSize = new IntData();
|
---|
| 56 | public int PopulationSize {
|
---|
| 57 | get { return populationSize.Data; }
|
---|
| 58 | set {
|
---|
| 59 | populationSize.Data = value;
|
---|
| 60 | parents.Data = value * 2;
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
[1051] | 64 | private BoolData setSeedRandomly = new BoolData();
|
---|
| 65 | public bool SetSeedRandomly {
|
---|
| 66 | get { return setSeedRandomly.Data; }
|
---|
| 67 | set { setSeedRandomly.Data = value; }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | private IntData seed = new IntData();
|
---|
| 71 | public int Seed {
|
---|
| 72 | get { return seed.Data; }
|
---|
| 73 | set { seed.Data = value; }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | public IOperator ProblemInjector {
|
---|
| 77 | get { return algorithm.SubOperators[0]; }
|
---|
| 78 | set {
|
---|
| 79 | value.Name = "ProblemInjector";
|
---|
| 80 | algorithm.RemoveSubOperator(0);
|
---|
| 81 | algorithm.AddSubOperator(value, 0);
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | private IntData elites = new IntData();
|
---|
| 86 | public int Elites {
|
---|
| 87 | get { return elites.Data; }
|
---|
| 88 | set { elites.Data = value; }
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[1050] | 91 | private int maxTreeSize = 50;
|
---|
| 92 | private int maxTreeHeight = 8;
|
---|
| 93 | private double punishmentFactor = 10.0;
|
---|
| 94 | private bool useEstimatedTargetValue = false;
|
---|
| 95 | private double fullTreeShakingFactor = 0.1;
|
---|
| 96 | private double onepointShakingFactor = 1.0;
|
---|
[1051] | 97 | private IOperator algorithm;
|
---|
[1050] | 98 | private SequentialEngine.SequentialEngine engine;
|
---|
| 99 |
|
---|
[1051] | 100 | public IEngine Engine {
|
---|
| 101 | get { return engine; }
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[1050] | 104 | public StandardGP() {
|
---|
[1051] | 105 | PopulationSize = 100;
|
---|
[1050] | 106 | MaxGenerations = 100;
|
---|
| 107 | TournamentSize = 7;
|
---|
| 108 | MutationRate = 0.15;
|
---|
| 109 | engine = new SequentialEngine.SequentialEngine();
|
---|
[1051] | 110 | CombinedOperator algo = CreateAlgorithm();
|
---|
| 111 | engine.OperatorGraph.AddOperator(algo);
|
---|
| 112 | engine.OperatorGraph.InitialOperator = algo;
|
---|
[1050] | 113 | }
|
---|
| 114 |
|
---|
[1051] | 115 | private CombinedOperator CreateAlgorithm() {
|
---|
| 116 | CombinedOperator algo = new CombinedOperator();
|
---|
| 117 | algo.Name = "StandardGP";
|
---|
[1050] | 118 | SequentialProcessor seq = new SequentialProcessor();
|
---|
[1051] | 119 | EmptyOperator problemInjectorPlaceholder = new EmptyOperator();
|
---|
[1050] | 120 | RandomInjector randomInjector = new RandomInjector();
|
---|
[1051] | 121 | randomInjector.GetVariable("SetSeedRandomly").Value = setSeedRandomly;
|
---|
| 122 | randomInjector.GetVariable("Seed").Value = seed;
|
---|
[1050] | 123 | randomInjector.Name = "Random Injector";
|
---|
| 124 | VariableInjector globalInjector = CreateGlobalInjector();
|
---|
| 125 | VariableInjector problemInjector = new VariableInjector();
|
---|
| 126 | problemInjector.Name = "Problem Injector";
|
---|
| 127 | CombinedOperator initialization = CreateInialization();
|
---|
| 128 | initialization.Name = "Initialization";
|
---|
| 129 | FunctionLibraryInjector funLibInjector = new FunctionLibraryInjector();
|
---|
| 130 | CombinedOperator mainLoop = CreateMainLoop();
|
---|
| 131 | mainLoop.Name = "Main loop";
|
---|
| 132 |
|
---|
| 133 | ProbabilisticTreeCreator treeCreator = new ProbabilisticTreeCreator();
|
---|
| 134 | treeCreator.Name = "Tree generator";
|
---|
| 135 | treeCreator.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
[1051] | 136 | treeCreator.GetVariableInfo("MinTreeSize").Local = true;
|
---|
| 137 | treeCreator.AddVariable(new HeuristicLab.Core.Variable("MinTreeSize", new IntData(3)));
|
---|
[1050] | 138 | MeanSquaredErrorEvaluator evaluator = new MeanSquaredErrorEvaluator();
|
---|
| 139 | evaluator.GetVariableInfo("MSE").ActualName = "Quality";
|
---|
| 140 | evaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
|
---|
| 141 | evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
|
---|
| 142 | evaluator.Name = "Evaluator";
|
---|
| 143 | StandardCrossOver crossover = new StandardCrossOver();
|
---|
| 144 | crossover.Name = "Crossover";
|
---|
| 145 | crossover.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 146 | CombinedOperator manipulator = CreateManipulator();
|
---|
| 147 | manipulator.Name = "Manipulator";
|
---|
| 148 | TournamentSelector selector = new TournamentSelector();
|
---|
| 149 | selector.Name = "Selector";
|
---|
| 150 | selector.GetVariableInfo("Selected").ActualName = "Parents";
|
---|
| 151 | selector.GetVariableInfo("GroupSize").Local = false;
|
---|
| 152 | selector.RemoveVariable("GroupSize");
|
---|
| 153 | selector.GetVariableInfo("GroupSize").ActualName = "TournamentSize";
|
---|
| 154 |
|
---|
[1051] | 155 | seq.AddSubOperator(problemInjectorPlaceholder);
|
---|
[1050] | 156 | seq.AddSubOperator(randomInjector);
|
---|
| 157 | seq.AddSubOperator(globalInjector);
|
---|
| 158 | seq.AddSubOperator(problemInjector);
|
---|
| 159 | seq.AddSubOperator(funLibInjector);
|
---|
| 160 | seq.AddSubOperator(initialization);
|
---|
| 161 | seq.AddSubOperator(mainLoop);
|
---|
| 162 |
|
---|
| 163 | initialization.AddSubOperator(treeCreator);
|
---|
| 164 | initialization.AddSubOperator(evaluator);
|
---|
| 165 |
|
---|
| 166 | mainLoop.AddSubOperator(selector);
|
---|
| 167 | mainLoop.AddSubOperator(crossover);
|
---|
| 168 | mainLoop.AddSubOperator(manipulator);
|
---|
| 169 | mainLoop.AddSubOperator(evaluator);
|
---|
[1051] | 170 | algo.OperatorGraph.AddOperator(seq);
|
---|
| 171 | algo.OperatorGraph.InitialOperator = seq;
|
---|
| 172 | this.algorithm = seq;
|
---|
| 173 | return algo;
|
---|
[1050] | 174 | }
|
---|
| 175 |
|
---|
| 176 | private VariableInjector CreateGlobalInjector() {
|
---|
| 177 | VariableInjector injector = new VariableInjector();
|
---|
| 178 | injector.Name = "Global Injector";
|
---|
| 179 | injector.AddVariable(new HeuristicLab.Core.Variable("Generations", new IntData(0)));
|
---|
| 180 | injector.AddVariable(new HeuristicLab.Core.Variable("MaxGenerations", maxGenerations));
|
---|
| 181 | injector.AddVariable(new HeuristicLab.Core.Variable("MutationRate", mutationRate));
|
---|
| 182 | injector.AddVariable(new HeuristicLab.Core.Variable("PopulationSize", populationSize));
|
---|
| 183 | injector.AddVariable(new HeuristicLab.Core.Variable("Parents", parents));
|
---|
[1051] | 184 | injector.AddVariable(new HeuristicLab.Core.Variable("Elites", elites));
|
---|
| 185 | injector.AddVariable(new HeuristicLab.Core.Variable("TournamentSize", tournamentSize));
|
---|
[1050] | 186 | injector.AddVariable(new HeuristicLab.Core.Variable("Maximization", new BoolData(false)));
|
---|
| 187 | injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeHeight", new IntData(maxTreeHeight)));
|
---|
| 188 | injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeSize", new IntData(maxTreeSize)));
|
---|
| 189 | injector.AddVariable(new HeuristicLab.Core.Variable("TotalEvaluatedNodes", new DoubleData(0)));
|
---|
| 190 | injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(punishmentFactor)));
|
---|
| 191 | injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData(useEstimatedTargetValue)));
|
---|
| 192 | return injector;
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | private CombinedOperator CreateManipulator() {
|
---|
| 196 | CombinedOperator manipulator = new CombinedOperator();
|
---|
| 197 | StochasticMultiBranch multibranch = new StochasticMultiBranch();
|
---|
| 198 | FullTreeShaker fullTreeShaker = new FullTreeShaker();
|
---|
| 199 | fullTreeShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 200 | fullTreeShaker.GetVariableInfo("ShakingFactor").Local = true;
|
---|
| 201 | fullTreeShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", new DoubleData(fullTreeShakingFactor)));
|
---|
| 202 |
|
---|
| 203 | OnePointShaker onepointShaker = new OnePointShaker();
|
---|
| 204 | onepointShaker.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 205 | onepointShaker.GetVariableInfo("ShakingFactor").Local = true;
|
---|
| 206 | onepointShaker.AddVariable(new HeuristicLab.Core.Variable("ShakingFactor", new DoubleData(onepointShakingFactor)));
|
---|
| 207 | ChangeNodeTypeManipulation changeNodeTypeManipulation = new ChangeNodeTypeManipulation();
|
---|
| 208 | changeNodeTypeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 209 | CutOutNodeManipulation cutOutNodeManipulation = new CutOutNodeManipulation();
|
---|
| 210 | cutOutNodeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 211 | DeleteSubTreeManipulation deleteSubTreeManipulation = new DeleteSubTreeManipulation();
|
---|
| 212 | deleteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 213 | SubstituteSubTreeManipulation substituteSubTreeManipulation = new SubstituteSubTreeManipulation();
|
---|
| 214 | substituteSubTreeManipulation.GetVariableInfo("OperatorLibrary").ActualName = "FunctionLibrary";
|
---|
| 215 |
|
---|
[1051] | 216 | IOperator[] manipulators = new IOperator[] {
|
---|
| 217 | onepointShaker, fullTreeShaker,
|
---|
| 218 | changeNodeTypeManipulation,
|
---|
| 219 | cutOutNodeManipulation,
|
---|
| 220 | deleteSubTreeManipulation,
|
---|
| 221 | substituteSubTreeManipulation};
|
---|
| 222 |
|
---|
| 223 | DoubleArrayData probabilities = new DoubleArrayData(new double[manipulators.Length]);
|
---|
| 224 | for(int i=0;i<manipulators.Length;i++) {
|
---|
| 225 | probabilities.Data[i] = 1.0;
|
---|
| 226 | multibranch.AddSubOperator(manipulators[i]);
|
---|
| 227 | }
|
---|
| 228 | multibranch.GetVariableInfo("Probabilities").Local = true;
|
---|
| 229 | multibranch.AddVariable(new HeuristicLab.Core.Variable("Probabilities", probabilities));
|
---|
| 230 |
|
---|
[1050] | 231 | manipulator.OperatorGraph.AddOperator(multibranch);
|
---|
| 232 | manipulator.OperatorGraph.InitialOperator = multibranch;
|
---|
| 233 | return manipulator;
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | private CombinedOperator CreateInialization() {
|
---|
| 237 | CombinedOperator init = new CombinedOperator();
|
---|
| 238 | SequentialProcessor seq = new SequentialProcessor();
|
---|
| 239 | SubScopesCreater subScopesCreater = new SubScopesCreater();
|
---|
[1051] | 240 | subScopesCreater.GetVariableInfo("SubScopes").ActualName = "PopulationSize";
|
---|
[1050] | 241 | UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
|
---|
| 242 | SequentialProcessor individualSeq = new SequentialProcessor();
|
---|
| 243 | OperatorExtractor treeCreater = new OperatorExtractor();
|
---|
| 244 | treeCreater.Name = "Tree generator (extr.)";
|
---|
| 245 | treeCreater.GetVariableInfo("Operator").ActualName = "Tree generator";
|
---|
| 246 | OperatorExtractor evaluator = new OperatorExtractor();
|
---|
| 247 | evaluator.Name = "Evaluator (extr.)";
|
---|
| 248 | evaluator.GetVariableInfo("Operator").ActualName = "Evaluator";
|
---|
[1051] | 249 |
|
---|
[1050] | 250 | seq.AddSubOperator(subScopesCreater);
|
---|
| 251 | seq.AddSubOperator(subScopesProc);
|
---|
| 252 | subScopesProc.AddSubOperator(individualSeq);
|
---|
| 253 | individualSeq.AddSubOperator(treeCreater);
|
---|
| 254 | individualSeq.AddSubOperator(evaluator);
|
---|
| 255 |
|
---|
| 256 | init.OperatorGraph.AddOperator(seq);
|
---|
| 257 | init.OperatorGraph.InitialOperator = seq;
|
---|
| 258 | return init;
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | private CombinedOperator CreateMainLoop() {
|
---|
| 262 | CombinedOperator main = new CombinedOperator();
|
---|
| 263 | SequentialProcessor seq = new SequentialProcessor();
|
---|
| 264 | CombinedOperator childCreater = CreateChildCreater();
|
---|
| 265 | childCreater.Name = "Create children";
|
---|
| 266 | CombinedOperator replacement = CreateReplacement();
|
---|
| 267 | replacement.Name = "Replacement";
|
---|
| 268 | BestAverageWorstQualityCalculator qualityCalculator = new BestAverageWorstQualityCalculator();
|
---|
| 269 | DataCollector collector = new DataCollector();
|
---|
| 270 | ItemList<StringData> names = collector.GetVariable("VariableNames").GetValue<ItemList<StringData>>();
|
---|
| 271 | names.Add(new StringData("BestQuality"));
|
---|
| 272 | names.Add(new StringData("AverageQuality"));
|
---|
| 273 | names.Add(new StringData("WorstQuality"));
|
---|
| 274 | LinechartInjector lineChartInjector = new LinechartInjector();
|
---|
| 275 | lineChartInjector.GetVariableInfo("Linechart").ActualName = "Quality Linechart";
|
---|
| 276 | lineChartInjector.GetVariable("NumberOfLines").GetValue<IntData>().Data = 3;
|
---|
| 277 | QualityLogger qualityLogger = new QualityLogger();
|
---|
| 278 | Counter counter = new Counter();
|
---|
| 279 | counter.GetVariableInfo("Value").ActualName = "Generations";
|
---|
| 280 | LessThanComparator comparator = new LessThanComparator();
|
---|
| 281 | comparator.GetVariableInfo("LeftSide").ActualName = "Generations";
|
---|
| 282 | comparator.GetVariableInfo("RightSide").ActualName = "MaxGenerations";
|
---|
| 283 | comparator.GetVariableInfo("Result").ActualName = "GenerationsCondition";
|
---|
| 284 | ConditionalBranch cond = new ConditionalBranch();
|
---|
| 285 | cond.GetVariableInfo("Condition").ActualName = "GenerationsCondition";
|
---|
[1051] | 286 |
|
---|
| 287 | seq.AddSubOperator(childCreater);
|
---|
| 288 | seq.AddSubOperator(replacement);
|
---|
| 289 | seq.AddSubOperator(qualityCalculator);
|
---|
| 290 | seq.AddSubOperator(collector);
|
---|
| 291 | seq.AddSubOperator(lineChartInjector);
|
---|
| 292 | seq.AddSubOperator(qualityLogger);
|
---|
| 293 | seq.AddSubOperator(counter);
|
---|
| 294 | seq.AddSubOperator(comparator);
|
---|
| 295 | seq.AddSubOperator(cond);
|
---|
| 296 | cond.AddSubOperator(seq);
|
---|
| 297 |
|
---|
[1050] | 298 | main.OperatorGraph.AddOperator(seq);
|
---|
| 299 | main.OperatorGraph.InitialOperator = seq;
|
---|
| 300 | return main;
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | private CombinedOperator CreateReplacement() {
|
---|
| 304 | CombinedOperator replacement = new CombinedOperator();
|
---|
| 305 | SequentialProcessor seq = new SequentialProcessor();
|
---|
| 306 | SequentialSubScopesProcessor seqScopeProc = new SequentialSubScopesProcessor();
|
---|
| 307 | SequentialProcessor selectedProc = new SequentialProcessor();
|
---|
| 308 | LeftSelector leftSelector = new LeftSelector();
|
---|
| 309 | leftSelector.GetVariableInfo("Selected").ActualName = "Elites";
|
---|
| 310 | RightReducer rightReducer = new RightReducer();
|
---|
[1051] | 311 |
|
---|
[1050] | 312 | SequentialProcessor remainingProc = new SequentialProcessor();
|
---|
| 313 | RightSelector rightSelector = new RightSelector();
|
---|
| 314 | rightSelector.GetVariableInfo("Selected").ActualName = "Elites";
|
---|
| 315 | LeftReducer leftReducer = new LeftReducer();
|
---|
| 316 | MergingReducer mergingReducer = new MergingReducer();
|
---|
| 317 | Sorter sorter = new Sorter();
|
---|
| 318 | sorter.GetVariableInfo("Descending").ActualName = "Maximization";
|
---|
| 319 | sorter.GetVariableInfo("Value").ActualName = "Quality";
|
---|
| 320 |
|
---|
| 321 | seq.AddSubOperator(seqScopeProc);
|
---|
| 322 | seqScopeProc.AddSubOperator(selectedProc);
|
---|
| 323 | selectedProc.AddSubOperator(leftSelector);
|
---|
| 324 | selectedProc.AddSubOperator(rightReducer);
|
---|
| 325 |
|
---|
| 326 | seqScopeProc.AddSubOperator(remainingProc);
|
---|
| 327 | remainingProc.AddSubOperator(rightSelector);
|
---|
| 328 | remainingProc.AddSubOperator(leftReducer);
|
---|
| 329 | seq.AddSubOperator(mergingReducer);
|
---|
| 330 | seq.AddSubOperator(sorter);
|
---|
| 331 | replacement.OperatorGraph.AddOperator(seq);
|
---|
| 332 | replacement.OperatorGraph.InitialOperator = seq;
|
---|
| 333 | return replacement;
|
---|
| 334 | }
|
---|
| 335 |
|
---|
| 336 | private CombinedOperator CreateChildCreater() {
|
---|
| 337 | CombinedOperator childCreater = new CombinedOperator();
|
---|
| 338 | SequentialProcessor seq = new SequentialProcessor();
|
---|
| 339 | OperatorExtractor selector = new OperatorExtractor();
|
---|
| 340 | selector.Name = "Selector (extr.)";
|
---|
| 341 | selector.GetVariableInfo("Operator").ActualName = "Selector";
|
---|
| 342 | SequentialSubScopesProcessor seqScopesProc = new SequentialSubScopesProcessor();
|
---|
| 343 | EmptyOperator emptyOpt = new EmptyOperator();
|
---|
| 344 | SequentialProcessor selectedProc = new SequentialProcessor();
|
---|
| 345 | OperatorExtractor crossover = new OperatorExtractor();
|
---|
| 346 | crossover.Name = "Crossover (extr.)";
|
---|
| 347 | crossover.GetVariableInfo("Operator").ActualName = "Crossover";
|
---|
| 348 | UniformSequentialSubScopesProcessor individualProc = new UniformSequentialSubScopesProcessor();
|
---|
| 349 | SequentialProcessor individualSeqProc = new SequentialProcessor();
|
---|
| 350 | StochasticBranch cond = new StochasticBranch();
|
---|
| 351 | cond.GetVariableInfo("Probability").ActualName = "MutationRate";
|
---|
| 352 | OperatorExtractor manipulator = new OperatorExtractor();
|
---|
| 353 | manipulator.Name = "Manipulator (extr.)";
|
---|
| 354 | manipulator.GetVariableInfo("Operator").ActualName = "Manipulator";
|
---|
| 355 | OperatorExtractor evaluator = new OperatorExtractor();
|
---|
| 356 | evaluator.Name = "Evaluator (extr.)";
|
---|
| 357 | evaluator.GetVariableInfo("Operator").ActualName = "Evaluator";
|
---|
| 358 | Sorter sorter = new Sorter();
|
---|
| 359 | sorter.GetVariableInfo("Descending").ActualName = "Maximization";
|
---|
| 360 | sorter.GetVariableInfo("Value").ActualName = "Quality";
|
---|
| 361 |
|
---|
[1051] | 362 |
|
---|
[1050] | 363 | seq.AddSubOperator(selector);
|
---|
| 364 | seq.AddSubOperator(seqScopesProc);
|
---|
| 365 | seqScopesProc.AddSubOperator(emptyOpt);
|
---|
| 366 | seqScopesProc.AddSubOperator(selectedProc);
|
---|
| 367 | selectedProc.AddSubOperator(crossover);
|
---|
| 368 | selectedProc.AddSubOperator(individualProc);
|
---|
| 369 | individualProc.AddSubOperator(individualSeqProc);
|
---|
| 370 | individualSeqProc.AddSubOperator(cond);
|
---|
| 371 | cond.AddSubOperator(manipulator);
|
---|
| 372 | individualSeqProc.AddSubOperator(evaluator);
|
---|
| 373 | selectedProc.AddSubOperator(sorter);
|
---|
| 374 |
|
---|
| 375 | childCreater.OperatorGraph.AddOperator(seq);
|
---|
| 376 | childCreater.OperatorGraph.InitialOperator = seq;
|
---|
| 377 | return childCreater;
|
---|
| 378 | }
|
---|
[1051] | 379 |
|
---|
| 380 | public IEditor CreateEditor() {
|
---|
| 381 | return new StandardGpEditor(this);
|
---|
| 382 | }
|
---|
| 383 |
|
---|
| 384 | public IView CreateView() {
|
---|
| 385 | return new StandardGpEditor(this);
|
---|
| 386 | }
|
---|
[1050] | 387 | }
|
---|
| 388 | }
|
---|