Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/AlgorithmBase.cs @ 2115

Last change on this file since 2115 was 2057, checked in by gkronber, 16 years ago

Improved stability of hive backend for CEDMA. #642 (Hive backend for CEDMA)

File size: 22.3 KB
RevLine 
[1230]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.Operators;
31using HeuristicLab.Random;
32using HeuristicLab.Selection;
33using HeuristicLab.Logging;
34using HeuristicLab.Data;
35using HeuristicLab.Operators.Programmable;
[1335]36using HeuristicLab.Evolutionary;
[1857]37using HeuristicLab.Modeling;
[1230]38
39namespace HeuristicLab.GP.StructureIdentification {
[1857]40  public abstract class AlgorithmBase : ItemBase, IAlgorithm, IStochasticAlgorithm {
41    public virtual string Name { get { return "GP"; } }
42    public virtual string Description { get { return "TODO"; } }
43
[1922]44    public abstract Dataset Dataset { get; set; }
45    public abstract int TargetVariable { get; set; }
46
[1231]47    public virtual double MutationRate {
[1287]48      get { return GetVariableInjector().GetVariable("MutationRate").GetValue<DoubleData>().Data; }
49      set { GetVariableInjector().GetVariable("MutationRate").GetValue<DoubleData>().Data = value; }
[1230]50    }
[1231]51    public virtual int PopulationSize {
[1287]52      get { return GetVariableInjector().GetVariable("PopulationSize").GetValue<IntData>().Data; }
53      set { GetVariableInjector().GetVariable("PopulationSize").GetValue<IntData>().Data = value; }
[1230]54    }
55
[1231]56    public virtual bool SetSeedRandomly {
[1287]57      get { return GetRandomInjector().GetVariable("SetSeedRandomly").GetValue<BoolData>().Data; }
58      set { GetRandomInjector().GetVariable("SetSeedRandomly").GetValue<BoolData>().Data = value; }
[1230]59    }
60
[1857]61    public virtual int RandomSeed {
[1287]62      get { return GetRandomInjector().GetVariable("Seed").GetValue<IntData>().Data; }
63      set { GetRandomInjector().GetVariable("Seed").GetValue<IntData>().Data = value; }
[1230]64    }
65
[1231]66    public virtual IOperator ProblemInjector {
[1230]67      get { return algorithm.SubOperators[0]; }
68      set {
69        value.Name = "ProblemInjector";
70        algorithm.RemoveSubOperator(0);
71        algorithm.AddSubOperator(value, 0);
72      }
73    }
74
[1906]75    public virtual IModel Model {
76      get {
77        if (!engine.Terminated) throw new InvalidOperationException("The algorithm is still running. Wait until the algorithm is terminated to retrieve the result.");
78        IScope bestModelScope = engine.GlobalScope.GetVariableValue<IScope>("BestValidationSolution", false);
79        return CreateGPModel(bestModelScope);
80      }
81    }
82
[1231]83    public virtual int Elites {
[1287]84      get { return GetVariableInjector().GetVariable("Elites").GetValue<IntData>().Data; }
85      set { GetVariableInjector().GetVariable("Elites").GetValue<IntData>().Data = value; }
[1230]86    }
87
[1231]88    public virtual int MaxTreeSize {
[1287]89      get { return GetVariableInjector().GetVariable("MaxTreeSize").GetValue<IntData>().Data; }
90      set { GetVariableInjector().GetVariable("MaxTreeSize").GetValue<IntData>().Data = value; }
[1230]91    }
92
[1231]93    public virtual int MaxTreeHeight {
[1287]94      get { return GetVariableInjector().GetVariable("MaxTreeHeight").GetValue<IntData>().Data; }
95      set { GetVariableInjector().GetVariable("MaxTreeHeight").GetValue<IntData>().Data = value; }
[1230]96    }
97
[1231]98    public virtual int Parents {
[1287]99      get { return GetVariableInjector().GetVariable("Parents").GetValue<IntData>().Data; }
100      set { GetVariableInjector().GetVariable("Parents").GetValue<IntData>().Data = value; }
[1231]101    }
102
[1287]103    public virtual double PunishmentFactor {
104      get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; }
105      set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; }
106    }
107
108    public virtual bool UseEstimatedTargetValue {
109      get { return GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data; }
110      set { GetVariableInjector().GetVariable("UseEstimatedTargetValue").GetValue<BoolData>().Data = value; }
111    }
112
[1230]113    private IOperator algorithm;
114
115    private SequentialEngine.SequentialEngine engine;
116    public IEngine Engine {
117      get { return engine; }
[1231]118      protected set { engine = (SequentialEngine.SequentialEngine)value; }
[1230]119    }
120
121    public AlgorithmBase() {
122      engine = new SequentialEngine.SequentialEngine();
123      CombinedOperator algo = CreateAlgorithm();
124      engine.OperatorGraph.AddOperator(algo);
125      engine.OperatorGraph.InitialOperator = algo;
[1287]126      SetSeedRandomly = true;
127      Elites = 1;
128      MutationRate = 0.15;
129      PopulationSize = 1000;
130      MaxTreeSize = 100;
131      MaxTreeHeight = 10;
132      Parents = 2000;
133      PunishmentFactor = 10;
134      UseEstimatedTargetValue = false;
[1230]135    }
136
[1287]137    protected internal virtual CombinedOperator CreateAlgorithm() {
[1230]138      CombinedOperator algo = new CombinedOperator();
139      algo.Name = "GP";
140      SequentialProcessor seq = new SequentialProcessor();
[1287]141      IOperator problemInjector = CreateProblemInjector();
[1230]142
143      RandomInjector randomInjector = new RandomInjector();
144      randomInjector.Name = "Random Injector";
145
146      IOperator globalInjector = CreateGlobalInjector();
147      IOperator initialization = CreateInitialization();
[1287]148      IOperator funLibInjector = CreateFunctionLibraryInjector();
[1873]149
[1230]150      IOperator mainLoop = CreateMainLoop();
151      mainLoop.Name = "Main loop";
152
153      IOperator treeCreator = CreateTreeCreator();
[1287]154
[1230]155      MeanSquaredErrorEvaluator evaluator = new MeanSquaredErrorEvaluator();
156      evaluator.GetVariableInfo("MSE").ActualName = "Quality";
157      evaluator.GetVariableInfo("SamplesStart").ActualName = "TrainingSamplesStart";
158      evaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
159      evaluator.Name = "Evaluator";
[1287]160
[1230]161      IOperator crossover = CreateCrossover();
162      IOperator manipulator = CreateManipulator();
163
164      IOperator selector = CreateSelector();
165      LeftReducer cleanUp = new LeftReducer();
166
[1287]167      seq.AddSubOperator(problemInjector);
[1230]168      seq.AddSubOperator(randomInjector);
169      seq.AddSubOperator(globalInjector);
170      seq.AddSubOperator(funLibInjector);
171      seq.AddSubOperator(initialization);
172      seq.AddSubOperator(mainLoop);
173      seq.AddSubOperator(cleanUp);
174
175      initialization.AddSubOperator(treeCreator);
176      initialization.AddSubOperator(evaluator);
177
178      mainLoop.AddSubOperator(selector);
179      mainLoop.AddSubOperator(crossover);
180      mainLoop.AddSubOperator(manipulator);
181      mainLoop.AddSubOperator(evaluator);
182      algo.OperatorGraph.AddOperator(seq);
183      algo.OperatorGraph.InitialOperator = seq;
184      this.algorithm = seq;
185      return algo;
186    }
187
[1287]188    protected internal virtual IOperator CreateProblemInjector() {
189      return new EmptyOperator();
190    }
[1230]191
[1287]192    protected internal abstract IOperator CreateSelector();
[1230]193
[1287]194    protected internal abstract IOperator CreateCrossover();
[1230]195
[1287]196    protected internal abstract IOperator CreateTreeCreator();
[1230]197
[1287]198    protected internal abstract IOperator CreateFunctionLibraryInjector();
199
200    protected internal virtual IOperator CreateGlobalInjector() {
[1230]201      VariableInjector injector = new VariableInjector();
202      injector.Name = "Global Injector";
203      injector.AddVariable(new HeuristicLab.Core.Variable("Generations", new IntData(0)));
[1287]204      injector.AddVariable(new HeuristicLab.Core.Variable("MutationRate", new DoubleData()));
205      injector.AddVariable(new HeuristicLab.Core.Variable("PopulationSize", new IntData()));
206      injector.AddVariable(new HeuristicLab.Core.Variable("Elites", new IntData()));
[1230]207      injector.AddVariable(new HeuristicLab.Core.Variable("Maximization", new BoolData(false)));
[1287]208      injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeHeight", new IntData()));
209      injector.AddVariable(new HeuristicLab.Core.Variable("MaxTreeSize", new IntData()));
[1230]210      injector.AddVariable(new HeuristicLab.Core.Variable("EvaluatedSolutions", new IntData(0)));
211      injector.AddVariable(new HeuristicLab.Core.Variable("TotalEvaluatedNodes", new DoubleData(0)));
[1287]212      injector.AddVariable(new HeuristicLab.Core.Variable("Parents", new IntData()));
213      injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData()));
214      injector.AddVariable(new HeuristicLab.Core.Variable("UseEstimatedTargetValue", new BoolData()));
[2034]215      injector.AddVariable(new HeuristicLab.Core.Variable("TreeEvaluator", new HL2TreeEvaluator()));
[1230]216      return injector;
217    }
218
[1287]219    protected internal abstract IOperator CreateManipulator();
[1230]220
[1287]221    protected internal virtual IOperator CreateInitialization() {
[1230]222      CombinedOperator init = new CombinedOperator();
223      init.Name = "Initialization";
224      SequentialProcessor seq = new SequentialProcessor();
225      SubScopesCreater subScopesCreater = new SubScopesCreater();
226      subScopesCreater.GetVariableInfo("SubScopes").ActualName = "PopulationSize";
227      UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
228      SequentialProcessor individualSeq = new SequentialProcessor();
229      OperatorExtractor treeCreater = new OperatorExtractor();
230      treeCreater.Name = "Tree generator (extr.)";
231      treeCreater.GetVariableInfo("Operator").ActualName = "Tree generator";
232      OperatorExtractor evaluator = new OperatorExtractor();
233      evaluator.Name = "Evaluator (extr.)";
234      evaluator.GetVariableInfo("Operator").ActualName = "Evaluator";
235      MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();
236      validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
237      validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
238      validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
239      Counter evalCounter = new Counter();
240      evalCounter.GetVariableInfo("Value").ActualName = "EvaluatedSolutions";
241      Sorter sorter = new Sorter();
242      sorter.GetVariableInfo("Descending").ActualName = "Maximization";
243      sorter.GetVariableInfo("Value").ActualName = "Quality";
244
245      seq.AddSubOperator(subScopesCreater);
246      seq.AddSubOperator(subScopesProc);
247      seq.AddSubOperator(sorter);
248
249      subScopesProc.AddSubOperator(individualSeq);
250      individualSeq.AddSubOperator(treeCreater);
251      individualSeq.AddSubOperator(evaluator);
252      individualSeq.AddSubOperator(validationEvaluator);
253      individualSeq.AddSubOperator(evalCounter);
254
255      init.OperatorGraph.AddOperator(seq);
256      init.OperatorGraph.InitialOperator = seq;
257      return init;
258    }
259
[1287]260    protected internal virtual IOperator CreateMainLoop() {
[1230]261      CombinedOperator main = new CombinedOperator();
262      SequentialProcessor seq = new SequentialProcessor();
263      IOperator childCreater = CreateChildCreater();
264      IOperator replacement = CreateReplacement();
265
266      BestSolutionStorer solutionStorer = new BestSolutionStorer();
267      solutionStorer.GetVariableInfo("Quality").ActualName = "ValidationQuality";
268      solutionStorer.GetVariableInfo("BestSolution").ActualName = "BestValidationSolution";
269      solutionStorer.AddSubOperator(CreateBestSolutionProcessor());
270
271      BestAverageWorstQualityCalculator qualityCalculator = new BestAverageWorstQualityCalculator();
272      BestAverageWorstQualityCalculator validationQualityCalculator = new BestAverageWorstQualityCalculator();
[1287]273      validationQualityCalculator.Name = "BestAverageWorstValidationQualityCalculator";
274      validationQualityCalculator.GetVariableInfo("Quality").ActualName = "ValidationQuality";
[1230]275      validationQualityCalculator.GetVariableInfo("BestQuality").ActualName = "BestValidationQuality";
276      validationQualityCalculator.GetVariableInfo("AverageQuality").ActualName = "AverageValidationQuality";
277      validationQualityCalculator.GetVariableInfo("WorstQuality").ActualName = "WorstValidationQuality";
[1287]278      IOperator loggingOperator = CreateLoggingOperator();
[1230]279      Counter counter = new Counter();
280      counter.GetVariableInfo("Value").ActualName = "Generations";
[1287]281      IOperator loopCondition = CreateLoopCondition(seq);
[1230]282
283      seq.AddSubOperator(childCreater);
284      seq.AddSubOperator(replacement);
285      seq.AddSubOperator(solutionStorer);
286      seq.AddSubOperator(qualityCalculator);
287      seq.AddSubOperator(validationQualityCalculator);
[1287]288      seq.AddSubOperator(loggingOperator);
[1230]289      seq.AddSubOperator(counter);
[1287]290      seq.AddSubOperator(loopCondition);
[1230]291
292      main.OperatorGraph.AddOperator(seq);
293      main.OperatorGraph.InitialOperator = seq;
294      return main;
295    }
296
[1287]297    protected internal virtual IOperator CreateLoggingOperator() {
[1230]298      return new EmptyOperator();
299    }
300
[1287]301    protected internal virtual IOperator CreateLoopCondition(IOperator loop) {
302      SequentialProcessor seq = new SequentialProcessor();
303      seq.Name = "Loop Condition";
304      LessThanComparator comparator = new LessThanComparator();
305      comparator.GetVariableInfo("LeftSide").ActualName = "Generations";
306      comparator.GetVariableInfo("RightSide").ActualName = "MaxGenerations";
307      comparator.GetVariableInfo("Result").ActualName = "GenerationsCondition";
308      ConditionalBranch cond = new ConditionalBranch();
309      cond.GetVariableInfo("Condition").ActualName = "GenerationsCondition";
310
311      seq.AddSubOperator(comparator);
312      seq.AddSubOperator(cond);
313
314      cond.AddSubOperator(loop);
315      return seq;
316    }
317
318    protected internal virtual IOperator CreateBestSolutionProcessor() {
319      return new EmptyOperator();
320    }
321
322    protected internal virtual IOperator CreateReplacement() {
[1230]323      CombinedOperator replacement = new CombinedOperator();
324      replacement.Name = "Replacement";
325      SequentialProcessor seq = new SequentialProcessor();
326      SequentialSubScopesProcessor seqScopeProc = new SequentialSubScopesProcessor();
327      SequentialProcessor selectedProc = new SequentialProcessor();
328      LeftSelector leftSelector = new LeftSelector();
329      leftSelector.GetVariableInfo("Selected").ActualName = "Elites";
330      RightReducer rightReducer = new RightReducer();
331
332      SequentialProcessor remainingProc = new SequentialProcessor();
333      RightSelector rightSelector = new RightSelector();
334      rightSelector.GetVariableInfo("Selected").ActualName = "Elites";
335      LeftReducer leftReducer = new LeftReducer();
336      MergingReducer mergingReducer = new MergingReducer();
337      Sorter sorter = new Sorter();
338      sorter.GetVariableInfo("Descending").ActualName = "Maximization";
339      sorter.GetVariableInfo("Value").ActualName = "Quality";
340
341      seq.AddSubOperator(seqScopeProc);
342      seqScopeProc.AddSubOperator(selectedProc);
343      selectedProc.AddSubOperator(leftSelector);
344      selectedProc.AddSubOperator(rightReducer);
345
346      seqScopeProc.AddSubOperator(remainingProc);
347      remainingProc.AddSubOperator(rightSelector);
348      remainingProc.AddSubOperator(leftReducer);
349      seq.AddSubOperator(mergingReducer);
350      seq.AddSubOperator(sorter);
351      replacement.OperatorGraph.AddOperator(seq);
352      replacement.OperatorGraph.InitialOperator = seq;
353      return replacement;
354    }
355
[1287]356    protected internal virtual IOperator CreateChildCreater() {
[1230]357      CombinedOperator childCreater = new CombinedOperator();
358      childCreater.Name = "Create children";
359      SequentialProcessor seq = new SequentialProcessor();
360      OperatorExtractor selector = new OperatorExtractor();
361      selector.Name = "Selector (extr.)";
362      selector.GetVariableInfo("Operator").ActualName = "Selector";
[1335]363
[1230]364      SequentialSubScopesProcessor seqScopesProc = new SequentialSubScopesProcessor();
365      EmptyOperator emptyOpt = new EmptyOperator();
366      SequentialProcessor selectedProc = new SequentialProcessor();
[1335]367      ChildrenInitializer childInitializer = new ChildrenInitializer();
368      ((IntData)childInitializer.GetVariable("ParentsPerChild").Value).Data = 2;
369
[1230]370      OperatorExtractor crossover = new OperatorExtractor();
371      crossover.Name = "Crossover (extr.)";
372      crossover.GetVariableInfo("Operator").ActualName = "Crossover";
373      UniformSequentialSubScopesProcessor individualProc = new UniformSequentialSubScopesProcessor();
374      SequentialProcessor individualSeqProc = new SequentialProcessor();
375      StochasticBranch cond = new StochasticBranch();
376      cond.GetVariableInfo("Probability").ActualName = "MutationRate";
377      OperatorExtractor manipulator = new OperatorExtractor();
378      manipulator.Name = "Manipulator (extr.)";
379      manipulator.GetVariableInfo("Operator").ActualName = "Manipulator";
380      OperatorExtractor evaluator = new OperatorExtractor();
381      evaluator.Name = "Evaluator (extr.)";
382      evaluator.GetVariableInfo("Operator").ActualName = "Evaluator";
383      MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();
384      validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
385      validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
386      validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
387      Counter evalCounter = new Counter();
388      evalCounter.GetVariableInfo("Value").ActualName = "EvaluatedSolutions";
[1335]389      SubScopesRemover parentRefRemover = new SubScopesRemover();
[1230]390
391      Sorter sorter = new Sorter();
392      sorter.GetVariableInfo("Descending").ActualName = "Maximization";
393      sorter.GetVariableInfo("Value").ActualName = "Quality";
394
395
396      seq.AddSubOperator(selector);
397      seq.AddSubOperator(seqScopesProc);
398      seqScopesProc.AddSubOperator(emptyOpt);
399      seqScopesProc.AddSubOperator(selectedProc);
[1335]400      selectedProc.AddSubOperator(childInitializer);
[1230]401      selectedProc.AddSubOperator(individualProc);
402      individualProc.AddSubOperator(individualSeqProc);
[1335]403      individualSeqProc.AddSubOperator(crossover);
[1230]404      individualSeqProc.AddSubOperator(cond);
405      cond.AddSubOperator(manipulator);
406      individualSeqProc.AddSubOperator(evaluator);
407      individualSeqProc.AddSubOperator(validationEvaluator);
408      individualSeqProc.AddSubOperator(evalCounter);
[1335]409      individualSeqProc.AddSubOperator(parentRefRemover);
[1230]410      selectedProc.AddSubOperator(sorter);
411
412      childCreater.OperatorGraph.AddOperator(seq);
413      childCreater.OperatorGraph.InitialOperator = seq;
414      return childCreater;
415    }
416
[1906]417    protected internal virtual Model CreateGPModel(IScope bestModelScope) {
[2057]418      Engine.GlobalScope.AddSubScope(bestModelScope);
[1906]419      Model model = new Model();
420      Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true);
421      model.Data = bestModelScope.GetVariableValue<IFunctionTree>("FunctionTree", false);
422      model.Dataset = ds;
423      model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data);
424      model.TrainingMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("Quality", false).Data;
425      model.ValidationMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("ValidationQuality", false).Data;
[2041]426      // calculate and set variable impacts
427      VariableEvaluationImpactCalculator evaluationImpactCalculator = new VariableEvaluationImpactCalculator();
428      VariableQualityImpactCalculator qualityImpactCalculator = new VariableQualityImpactCalculator();
429
430      evaluationImpactCalculator.Apply(bestModelScope);
431      qualityImpactCalculator.Apply(bestModelScope);
432
433      ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false);
434      ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false);
435      foreach (ItemList row in evaluationImpacts) {
436        string variableName = ((StringData)row[0]).Data;
[2051]437        double impact = ((DoubleData)row[1]).Data;
[2041]438        model.SetVariableEvaluationImpact(variableName, impact);
439      }
440      foreach (ItemList row in qualityImpacts) {
441        string variableName = ((StringData)row[0]).Data;
[2051]442        double impact = ((DoubleData)row[1]).Data;
[2041]443        model.SetVariableQualityImpact(variableName, impact);
444      }
[2057]445      Engine.GlobalScope.RemoveSubScope(bestModelScope);
[1906]446      return model;
447    }
448
[1230]449    public override object Clone(IDictionary<Guid, object> clonedObjects) {
450      AlgorithmBase clone = (AlgorithmBase)base.Clone(clonedObjects);
451      clonedObjects.Add(Guid, clone);
452      clone.engine = (SequentialEngine.SequentialEngine)Auxiliary.Clone(Engine, clonedObjects);
453      return clone;
454    }
455
[1287]456    protected VariableInjector GetVariableInjector() {
[1230]457      CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
[1287]458      // SequentialProcessor in GP
[1230]459      algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
[1287]460      return (VariableInjector)algorithm.SubOperators[2];
[1230]461    }
462
[1287]463    protected RandomInjector GetRandomInjector() {
464      CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
465      // SequentialProcessor in GP
466      algorithm = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
467      return (RandomInjector)algorithm.SubOperators[1];
468    }
469
[1230]470    #region Persistence Methods
471    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
472      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
473      node.AppendChild(PersistenceManager.Persist("Engine", Engine, document, persistedObjects));
474      return node;
475    }
476    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
477      base.Populate(node, restoredObjects);
478      engine = (SequentialEngine.SequentialEngine)PersistenceManager.Restore(node.SelectSingleNode("Engine"), restoredObjects);
479    }
480    #endregion
[1857]481
[1922]482
[1230]483  }
484}
Note: See TracBrowser for help on using the repository browser.