Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CloningRefactorBranch/HeuristicLab.ES/ES.cs @ 887

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

Refactored cloning in all plugins except: HL.Communication, HL.Hive, HL.GP, HL.Routing, HL.Scheduling, HL.SimOpt, HL.Visualization

#285 (Cloning could be improved by creating objects at the bottom of the cloning chain with 'new' instead of the top with Activator.CreateInstance())

File size: 22.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Xml;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.SequentialEngine;
29using HeuristicLab.Operators;
30using HeuristicLab.Random;
31using HeuristicLab.Logging;
32using HeuristicLab.Selection;
33using HeuristicLab.Selection.OffspringSelection;
34using HeuristicLab.Evolutionary;
35
36namespace HeuristicLab.ES {
37  public class ES : ItemBase, IEditable {
38    #region Create Operators
39    public static void Create(IEngine engine) {
40      engine.OperatorGraph.Clear();
41
42      CombinedOperator co = CreateES();
43      co.Name = "ES";
44      engine.OperatorGraph.AddOperator(co);
45      engine.OperatorGraph.InitialOperator = co;
46
47      engine.Reset();
48    }
49    private static CombinedOperator CreateES() {
50      CombinedOperator op = new CombinedOperator();
51      SequentialProcessor sp = new SequentialProcessor();
52      op.OperatorGraph.AddOperator(sp);
53      op.OperatorGraph.InitialOperator = sp;
54
55      CombinedOperator co1 = CreateVariableInjection();
56      co1.Name = "Variable Injection";
57      op.OperatorGraph.AddOperator(co1);
58      sp.AddSubOperator(co1);
59
60      // place holder for ProblemInjector
61      EmptyOperator eo1 = new EmptyOperator();
62      eo1.Name = "ProblemInjector";
63      op.OperatorGraph.AddOperator(eo1);
64      co1.AddSubOperator(eo1);
65
66      CombinedOperator co2 = CreatePopulationInitialization();
67      co2.Name = "Population Initialization";
68      op.OperatorGraph.AddOperator(co2);
69      sp.AddSubOperator(co2);
70
71      // place holder for SolutionGenerator
72      EmptyOperator eo2 = new EmptyOperator();
73      eo2.Name = "SolutionGenerator";
74      op.OperatorGraph.AddOperator(eo2);
75      co2.AddSubOperator(eo2);
76
77      // place holder for Evaluator
78      EmptyOperator eo3 = new EmptyOperator();
79      eo3.Name = "Evaluator";
80      op.OperatorGraph.AddOperator(eo3);
81      co2.AddSubOperator(eo3);
82
83      CombinedOperator co3 = CreateESMain();
84      co3.Name = "ES Main";
85      op.OperatorGraph.AddOperator(co3);
86      sp.AddSubOperator(co3);
87
88      // place holder for Mutator
89      EmptyOperator eo4 = new EmptyOperator();
90      eo4.Name = "Mutator";
91      op.OperatorGraph.AddOperator(eo4);
92      co3.AddSubOperator(eo4);
93
94      // place holder for Evaluator
95      co3.AddSubOperator(eo3);
96
97      // place holder for Recombinator
98      EmptyOperator eo5 = new EmptyOperator();
99      eo5.Name = "Recombinator";
100      op.OperatorGraph.AddOperator(eo5);
101      co3.AddSubOperator(eo5);
102
103      return op;
104    }
105    private static CombinedOperator CreateVariableInjection() {
106      CombinedOperator op = new CombinedOperator();
107      SequentialProcessor sp = new SequentialProcessor();
108      op.OperatorGraph.AddOperator(sp);
109      op.OperatorGraph.InitialOperator = sp;
110
111      RandomInjector ri = new RandomInjector();
112      op.OperatorGraph.AddOperator(ri);
113      sp.AddSubOperator(ri);
114
115      OperatorExtractor oe = new OperatorExtractor();
116      oe.Name = "ProblemInjector";
117      oe.GetVariableInfo("Operator").ActualName = "ProblemInjector";
118      op.OperatorGraph.AddOperator(oe);
119      sp.AddSubOperator(oe);
120
121      VariableInjector vi = new VariableInjector();
122      vi.AddVariable(new Variable("ESmu", new IntData(1)));
123      vi.AddVariable(new Variable("ESrho", new IntData(1)));
124      vi.AddVariable(new Variable("ESlambda", new IntData(1)));
125      vi.AddVariable(new Variable("EvaluatedSolutions", new IntData()));
126      vi.AddVariable(new Variable("PlusNotation", new BoolData(true)));
127      vi.AddVariable(new Variable("Generations", new IntData()));
128      vi.AddVariable(new Variable("MaximumGenerations", new IntData(1000)));
129      vi.AddVariable(new Variable("LearningRate", new DoubleData(0.1)));
130      vi.AddVariable(new Variable("DampeningFactor", new DoubleData(10.0)));
131      vi.AddVariable(new Variable("ShakingFactor", new DoubleData(5.0)));
132      vi.AddVariable(new Variable("TargetSuccessProbability", new DoubleData(0.2)));
133      vi.AddVariable(new Variable("SuccessProbability", new DoubleData(0.2)));
134      vi.AddVariable(new Variable("UseSuccessRule", new BoolData(true)));
135      op.OperatorGraph.AddOperator(vi);
136      sp.AddSubOperator(vi);
137
138      return op;
139    }
140    private static CombinedOperator CreatePopulationInitialization() {
141      CombinedOperator op = new CombinedOperator();
142      SequentialProcessor sp1 = new SequentialProcessor();
143      op.OperatorGraph.AddOperator(sp1);
144      op.OperatorGraph.InitialOperator = sp1;
145
146      SubScopesCreater ssc = new SubScopesCreater();
147      ssc.GetVariableInfo("SubScopes").ActualName = "ESmu";
148      op.OperatorGraph.AddOperator(ssc);
149      sp1.AddSubOperator(ssc);
150
151      UniformSequentialSubScopesProcessor ussp = new UniformSequentialSubScopesProcessor();
152      op.OperatorGraph.AddOperator(ussp);
153      sp1.AddSubOperator(ussp);
154
155      SequentialProcessor sp2 = new SequentialProcessor();
156      op.OperatorGraph.AddOperator(sp2);
157      ussp.AddSubOperator(sp2);
158
159      OperatorExtractor oe1 = new OperatorExtractor();
160      oe1.Name = "SolutionGenerator";
161      oe1.GetVariableInfo("Operator").ActualName = "SolutionGenerator";
162      op.OperatorGraph.AddOperator(oe1);
163      sp2.AddSubOperator(oe1);
164
165      OperatorExtractor oe2 = new OperatorExtractor();
166      oe2.Name = "Evaluator";
167      oe2.GetVariableInfo("Operator").ActualName = "Evaluator";
168      op.OperatorGraph.AddOperator(oe2);
169      sp2.AddSubOperator(oe2);
170
171      Counter c = new Counter();
172      c.GetVariableInfo("Value").ActualName = "EvaluatedSolutions";
173      op.OperatorGraph.AddOperator(c);
174      sp2.AddSubOperator(c);
175
176      Sorter s = new Sorter();
177      s.GetVariableInfo("Descending").ActualName = "Maximization";
178      s.GetVariableInfo("Value").ActualName = "Quality";
179      op.OperatorGraph.AddOperator(s);
180      sp1.AddSubOperator(s);
181
182      return op;
183    }
184    private static CombinedOperator CreateESMain() {
185      CombinedOperator op = new CombinedOperator();
186      SequentialProcessor sp = new SequentialProcessor();
187      op.OperatorGraph.AddOperator(sp);
188      op.OperatorGraph.InitialOperator = sp;
189
190      ESRandomSelector rs = new ESRandomSelector();
191      rs.Name = "Child Selector";
192      rs.GetVariableInfo("Lambda").ActualName = "ESlambda";
193      rs.GetVariableInfo("Rho").ActualName = "ESrho";
194      op.OperatorGraph.AddOperator(rs);
195      sp.AddSubOperator(rs);
196
197      SequentialSubScopesProcessor ssp = new SequentialSubScopesProcessor();
198      op.OperatorGraph.AddOperator(ssp);
199      sp.AddSubOperator(ssp);
200
201      EmptyOperator eo = new EmptyOperator();
202      op.OperatorGraph.AddOperator(eo);
203      ssp.AddSubOperator(eo);
204
205      CombinedOperator co1 = CreateCreateChildren();
206      co1.Name = "Create Children";
207      op.OperatorGraph.AddOperator(co1);
208      ssp.AddSubOperator(co1);
209
210      ConditionalBranch cb1 = new ConditionalBranch();
211      cb1.Name = "Plus or Comma Replacement";
212      cb1.GetVariableInfo("Condition").ActualName = "PlusNotation";
213      op.OperatorGraph.AddOperator(cb1);
214      sp.AddSubOperator(cb1);
215
216      MergingReducer mr = new MergingReducer();
217      mr.Name = "Plus Replacement";
218      op.OperatorGraph.AddOperator(mr);
219      cb1.AddSubOperator(mr);
220
221      RightReducer rr = new RightReducer();
222      rr.Name = "Comma Replacement";
223      op.OperatorGraph.AddOperator(rr);
224      cb1.AddSubOperator(rr);
225
226      CombinedOperator co2 = CreateReplacement();
227      co2.Name = "Parents Selection";
228      op.OperatorGraph.AddOperator(co2);
229      sp.AddSubOperator(co2);
230
231      QualityLogger ql = new QualityLogger();
232      op.OperatorGraph.AddOperator(ql);
233      sp.AddSubOperator(ql);
234
235      BestAverageWorstQualityCalculator bawqc = new BestAverageWorstQualityCalculator();
236      op.OperatorGraph.AddOperator(bawqc);
237      sp.AddSubOperator(bawqc);
238
239      DataCollector dc = new DataCollector();
240      ItemList<StringData> names = dc.GetVariable("VariableNames").GetValue<ItemList<StringData>>();
241      names.Add(new StringData("BestQuality"));
242      names.Add(new StringData("AverageQuality"));
243      names.Add(new StringData("WorstQuality"));
244      op.OperatorGraph.AddOperator(dc);
245      sp.AddSubOperator(dc);
246
247      LinechartInjector lci = new LinechartInjector();
248      lci.GetVariableInfo("Linechart").ActualName = "Quality Linechart";
249      lci.GetVariable("NumberOfLines").GetValue<IntData>().Data = 3;
250      op.OperatorGraph.AddOperator(lci);
251      sp.AddSubOperator(lci);
252
253      Counter c = new Counter();
254      c.GetVariableInfo("Value").ActualName = "Generations";
255      op.OperatorGraph.AddOperator(c);
256      sp.AddSubOperator(c);
257
258      LessThanComparator ltc = new LessThanComparator();
259      ltc.GetVariableInfo("LeftSide").ActualName = "Generations";
260      ltc.GetVariableInfo("RightSide").ActualName = "MaximumGenerations";
261      ltc.GetVariableInfo("Result").ActualName = "GenerationsCondition";
262      op.OperatorGraph.AddOperator(ltc);
263      sp.AddSubOperator(ltc);
264
265      ConditionalBranch cb2 = new ConditionalBranch();
266      cb2.GetVariableInfo("Condition").ActualName = "GenerationsCondition";
267      op.OperatorGraph.AddOperator(cb2);
268      sp.AddSubOperator(cb2);
269
270      cb2.AddSubOperator(sp);
271
272      return op;
273    }
274    private static CombinedOperator CreateCreateChildren() {
275      CombinedOperator op = new CombinedOperator();
276      SequentialProcessor sp1 = new SequentialProcessor();
277      op.OperatorGraph.AddOperator(sp1);
278      op.OperatorGraph.InitialOperator = sp1;
279
280      ConditionalBranch cb = new ConditionalBranch();
281      cb.GetVariableInfo("Condition").ActualName = "UseSuccessRule";
282      op.OperatorGraph.AddOperator(cb);
283      sp1.AddSubOperator(cb);
284
285      SequentialProcessor sp2 = new SequentialProcessor();
286      op.OperatorGraph.AddOperator(sp2);
287      cb.AddSubOperator(sp2);
288
289      OffspringAnalyzer oa = new OffspringAnalyzer();
290      oa.Name = "Offspring Analyzer";
291      oa.GetVariable("ParentsCount").Value = new IntData(1);
292      oa.GetVariable("ComparisonFactor").Value = new DoubleData(0.0);
293      op.OperatorGraph.AddOperator(oa);
294      sp2.AddSubOperator(oa);
295
296      SequentialProcessor sp3 = new SequentialProcessor();
297      op.OperatorGraph.AddOperator(sp3);
298      oa.AddSubOperator(sp3);
299      cb.AddSubOperator(sp3);
300
301      OperatorExtractor oe1 = new OperatorExtractor();
302      oe1.Name = "Recombinator";
303      oe1.GetVariableInfo("Operator").ActualName = "Recombinator";
304      op.OperatorGraph.AddOperator(oe1);
305      sp3.AddSubOperator(oe1);
306
307      UniformSequentialSubScopesProcessor ussp = new UniformSequentialSubScopesProcessor();
308      op.OperatorGraph.AddOperator(ussp);
309      sp3.AddSubOperator(ussp);
310
311      SequentialProcessor sp4 = new SequentialProcessor();
312      op.OperatorGraph.AddOperator(sp4);
313      ussp.AddSubOperator(sp4);
314
315      OperatorExtractor oe2 = new OperatorExtractor();
316      oe2.Name = "Mutator";
317      oe2.GetVariableInfo("Operator").ActualName = "Mutator";
318      op.OperatorGraph.AddOperator(oe2);
319      sp4.AddSubOperator(oe2);
320
321      OperatorExtractor oe3 = new OperatorExtractor();
322      oe3.Name = "Evaluator";
323      oe3.GetVariableInfo("Operator").ActualName = "Evaluator";
324      op.OperatorGraph.AddOperator(oe3);
325      sp4.AddSubOperator(oe3);
326
327      Counter c = new Counter();
328      c.GetVariableInfo("Value").ActualName = "EvaluatedSolutions";
329      op.OperatorGraph.AddOperator(c);
330      sp4.AddSubOperator(c);
331
332      SuccessRuleMutationStrengthAdjuster srmsa = new SuccessRuleMutationStrengthAdjuster();
333      srmsa.Name = "SuccessRuleMutationStrengthAdjuster";
334      op.OperatorGraph.AddOperator(srmsa);
335      sp2.AddSubOperator(srmsa);
336
337      Sorter s = new Sorter();
338      s.GetVariableInfo("Value").ActualName = "Quality";
339      s.GetVariableInfo("Descending").ActualName = "Maximization";
340      op.OperatorGraph.AddOperator(s);
341      sp1.AddSubOperator(s);
342
343      return op;
344    }
345    private static CombinedOperator CreateReplacement() {
346      CombinedOperator op = new CombinedOperator();
347      SequentialProcessor sp1 = new SequentialProcessor();
348      op.OperatorGraph.AddOperator(sp1);
349      op.OperatorGraph.InitialOperator = sp1;
350
351      Sorter s = new Sorter();
352      s.GetVariableInfo("Descending").ActualName = "Maximization";
353      s.GetVariableInfo("Value").ActualName = "Quality";
354      op.OperatorGraph.AddOperator(s);
355      sp1.AddSubOperator(s);
356
357      LeftSelector ls = new LeftSelector();
358      ls.Name = "Parents Selector";
359      ls.GetVariableInfo("Selected").ActualName = "ESmu";
360      ls.GetVariable("CopySelected").Value = new BoolData(false);
361      op.OperatorGraph.AddOperator(ls);
362      sp1.AddSubOperator(ls);
363
364      RightReducer rr = new RightReducer();
365      rr.Name = "RightReducer";
366      op.OperatorGraph.AddOperator(rr);
367      sp1.AddSubOperator(rr);
368
369      return op;
370    }
371    #endregion
372
373    #region Properties
374    private IEngine myEngine;
375    public IEngine Engine {
376      get { return myEngine; }
377    }
378    private BoolData mySetSeedRandomly;
379    public bool SetSeedRandomly {
380      get { return mySetSeedRandomly.Data; }
381      set { mySetSeedRandomly.Data = value; }
382    }
383    private IntData mySeed;
384    public int Seed {
385      get { return mySeed.Data; }
386      set {
387        mySeed.Data = value;
388        OnChanged();
389      }
390    }
391    private IntData myMu;
392    public int Mu {
393      get { return myMu.Data; }
394      set {
395        if (value > 0) {
396          myMu.Data = value;
397          if (!PlusNotation && value >= Lambda) myLambda.Data = value + 1;
398          if (value < Rho) myRho.Data = value;
399          OnChanged();
400        }
401      }
402    }
403    private IntData myRho;
404    public int Rho {
405      get { return myRho.Data; }
406      set {
407        if (value > 0) {
408          myRho.Data = value;
409          if (value > Mu) Mu = value;
410          OnChanged();
411        }
412      }
413    }
414    private IntData myLambda;
415    public int Lambda {
416      get { return myLambda.Data; }
417      set {
418        if (value > 0) {
419          if (PlusNotation) myLambda.Data = value;
420          else {
421            if (value > 1 && value < Mu) {
422              myLambda.Data = value;
423              myMu.Data = value - 1;
424            } else if (value == 1) {
425              myMu.Data = 1;
426              myLambda.Data = 2;
427            } else if (value > Mu) {
428              myLambda.Data = value;
429            }
430          }
431          OnChanged();
432        }
433      }
434    }
435    private BoolData myPlusNotation;
436    public bool PlusNotation {
437      get { return myPlusNotation.Data; }
438      set {
439        if (!value && myPlusNotation.Data) { // from plus to point
440          if (Lambda <= Mu) {
441            myLambda.Data = Mu + 1;
442          }
443        }
444        myPlusNotation.Data = value;
445        OnChanged();
446      }
447    }
448    private DoubleData myShakingFactor;
449    public double ShakingFactor {
450      get { return myShakingFactor.Data; }
451      set { myShakingFactor.Data = value; }
452    }
453    private DoubleData mySuccessProbability;
454    private DoubleData myTargetSuccessProbability;
455    public double SuccessProbability {
456      get { return myTargetSuccessProbability.Data; }
457      set {
458        myTargetSuccessProbability.Data = value;
459        mySuccessProbability.Data = value;
460      }
461    }
462    private DoubleData myLearningRate;
463    public double LearningRate {
464      get { return myLearningRate.Data; }
465      set {
466        if (value > 0.0 && value <= 1.0) {
467          myLearningRate.Data = value;
468          OnChanged();
469        }
470      }
471    }
472    private DoubleData myDampeningFactor;
473    public double DampeningFactor {
474      get { return myDampeningFactor.Data; }
475      set {
476        if (value >= 1.0) {
477          myDampeningFactor.Data = value;
478          OnChanged();
479        }
480      }
481    }
482    private IntData myMaximumGenerations;
483    public int MaximumGenerations {
484      get { return myMaximumGenerations.Data; }
485      set { myMaximumGenerations.Data = value; }
486    }
487    private BoolData myUseSuccessRule;
488    public bool UseSuccessRule {
489      get { return myUseSuccessRule.Data; }
490      set { myUseSuccessRule.Data = value; }
491    }
492    private CombinedOperator myES;
493    private IOperator myESMain;
494    private IOperator myVariableInjection;
495    public IOperator ProblemInjector {
496      get { return myVariableInjection.SubOperators[0]; }
497      set {
498        value.Name = "ProblemInjector";
499        myES.OperatorGraph.RemoveOperator(ProblemInjector.Guid);
500        myES.OperatorGraph.AddOperator(value);
501        myVariableInjection.AddSubOperator(value, 0);
502      }
503    }
504    private IOperator myPopulationInitialization;
505    public IOperator SolutionGenerator {
506      get { return myPopulationInitialization.SubOperators[0]; }
507      set {
508        value.Name = "SolutionGenerator";
509        myES.OperatorGraph.RemoveOperator(SolutionGenerator.Guid);
510        myES.OperatorGraph.AddOperator(value);
511        myPopulationInitialization.AddSubOperator(value, 0);
512      }
513    }
514    public IOperator Evaluator {
515      get { return myPopulationInitialization.SubOperators[1]; }
516      set {
517        value.Name = "Evaluator";
518        myES.OperatorGraph.RemoveOperator(Evaluator.Guid);
519        myES.OperatorGraph.AddOperator(value);
520        myPopulationInitialization.AddSubOperator(value, 1);
521        myESMain.AddSubOperator(value, 1);
522      }
523    }
524    public IOperator Mutator {
525      get { return myESMain.SubOperators[0]; }
526      set {
527        value.Name = "Mutator";
528        myES.OperatorGraph.RemoveOperator(Mutator.Guid);
529        myES.OperatorGraph.AddOperator(value);
530        myESMain.AddSubOperator(value, 0);
531      }
532    }
533    public IOperator Recombinator {
534      get { return myESMain.SubOperators[2]; }
535      set {
536        value.Name = "Recombinator";
537        myES.OperatorGraph.RemoveOperator(Recombinator.Guid);
538        myES.OperatorGraph.AddOperator(value);
539        myESMain.AddSubOperator(value, 2);
540      }
541    }
542    #endregion
543
544    public ES() {
545      myEngine = new SequentialEngine.SequentialEngine();
546      Create(myEngine);
547      SetReferences();
548    }
549
550    public ES(ES original) : this(original, new Dictionary<Guid, object>()) { }
551    protected ES(ES original, IDictionary<Guid, object> clonedObjects)
552      : base(original, clonedObjects) {
553      this.myEngine = (IEngine)Auxiliary.Clone(original.Engine, clonedObjects);
554    }
555
556    public override IView CreateView() {
557      return new ESEditor(this);
558    }
559    public virtual IEditor CreateEditor() {
560      return new ESEditor(this);
561    }
562
563    public override object Clone(IDictionary<Guid, object> clonedObjects) {
564      return new ES(this, clonedObjects);
565    }
566
567    #region SetReferences Method
568    private void SetReferences() {
569      // ES
570      CombinedOperator co1 = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
571      myES = co1;
572      // SequentialProcessor in ES
573      SequentialProcessor sp1 = (SequentialProcessor)co1.OperatorGraph.InitialOperator;
574      // Variable Injection
575      CombinedOperator co2 = (CombinedOperator)sp1.SubOperators[0];
576      myVariableInjection = co2;
577      // SequentialProcessor in Variable Injection
578      SequentialProcessor sp2 = (SequentialProcessor)co2.OperatorGraph.InitialOperator;
579      // RandomInjector
580      RandomInjector ri = (RandomInjector)sp2.SubOperators[0];
581      mySetSeedRandomly = ri.GetVariable("SetSeedRandomly").GetValue<BoolData>();
582      mySeed = ri.GetVariable("Seed").GetValue<IntData>();
583      // VariableInjector
584      VariableInjector vi = (VariableInjector)sp2.SubOperators[2];
585      myMu = vi.GetVariable("ESmu").GetValue<IntData>();
586      myRho = vi.GetVariable("ESrho").GetValue<IntData>();
587      myLambda = vi.GetVariable("ESlambda").GetValue<IntData>();
588      myMaximumGenerations = vi.GetVariable("MaximumGenerations").GetValue<IntData>();
589      myPlusNotation = vi.GetVariable("PlusNotation").GetValue<BoolData>();
590      myShakingFactor = vi.GetVariable("ShakingFactor").GetValue<DoubleData>();
591      myTargetSuccessProbability = vi.GetVariable("TargetSuccessProbability").GetValue<DoubleData>();
592      mySuccessProbability = vi.GetVariable("SuccessProbability").GetValue<DoubleData>();
593      myLearningRate = vi.GetVariable("LearningRate").GetValue<DoubleData>();
594      myDampeningFactor = vi.GetVariable("DampeningFactor").GetValue<DoubleData>();
595      myUseSuccessRule = vi.GetVariable("UseSuccessRule").GetValue<BoolData>();
596      // Population Initialization
597      CombinedOperator co3 = (CombinedOperator)sp1.SubOperators[1];
598      myPopulationInitialization = co3;
599      // ES Main
600      CombinedOperator co4 = (CombinedOperator)sp1.SubOperators[2];
601      myESMain = co4;
602    }
603    #endregion
604
605    #region Persistence Methods
606    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
607      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
608      node.AppendChild(PersistenceManager.Persist("Engine", Engine, document, persistedObjects));
609      return node;
610    }
611    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
612      base.Populate(node, restoredObjects);
613      myEngine = (IEngine)PersistenceManager.Restore(node.SelectSingleNode("Engine"), restoredObjects);
614      SetReferences();
615    }
616    #endregion
617  }
618}
Note: See TracBrowser for help on using the repository browser.