Changeset 4676 for branches/CloningRefactoring
- Timestamp:
- 10/29/10 19:02:32 (14 years ago)
- Location:
- branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/Analyzers/BestAntTrailAnalyzer.cs
r4068 r4676 21 21 22 22 using System.Linq; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 65 66 } 66 67 68 [StorableConstructor] 69 private BestAntTrailAnalyzer(bool deserializing) : base(deserializing) { } 70 private BestAntTrailAnalyzer(BestAntTrailAnalyzer original, Cloner cloner) 71 : base(original, cloner) { 72 } 73 public override IDeepCloneable Clone(Cloner cloner) { 74 return new BestAntTrailAnalyzer(this, cloner); 75 } 76 67 77 public override IOperation Apply() { 68 78 ItemArray<SymbolicExpressionTree> expressions = SymbolicExpressionTreeParameter.ActualValue; -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/AntTrail.cs
r4068 r4676 89 89 Initialize(); 90 90 } 91 91 92 [StorableConstructor] 92 93 private AntTrail(bool deserializing) : base(deserializing) { } 94 [StorableHook(HookType.AfterDeserialization)] 95 private void AfterDeserialization() { 96 Initialize(); 97 } 98 private AntTrail(AntTrail original, Cloner cloner) 99 : base(original, cloner) { 100 expression = cloner.Clone(original.expression); 101 world = cloner.Clone(original.world); 102 maxTimeSteps = cloner.Clone(original.maxTimeSteps); 103 Initialize(); 104 } 105 public override IDeepCloneable Clone(Cloner cloner) { 106 return new AntTrail(this, cloner); 107 } 93 108 94 [StorableHook(HookType.AfterDeserialization)]95 109 private void Initialize() { 96 110 //if (expression != null) RegisterSymbolicExpressionTreeEvents(); … … 99 113 } 100 114 101 public override IDeepCloneable Clone(Cloner cloner) {102 AntTrail clone = new AntTrail();103 cloner.RegisterClonedObject(this, clone);104 clone.expression = (SymbolicExpressionTree)cloner.Clone(expression);105 clone.world = (BoolMatrix)cloner.Clone(world);106 clone.maxTimeSteps = (IntValue)cloner.Clone(maxTimeSteps);107 clone.Initialize();108 return clone;109 }110 111 115 #region Events 112 116 public event EventHandler SymbolicExpressionTreeChanged; 113 117 private void OnSymbolicExpressionTreeChanged() { 114 118 var changed = SymbolicExpressionTreeChanged; 115 if (changed != null) 116 changed(this, EventArgs.Empty); 119 if (changed != null) changed(this, EventArgs.Empty); 117 120 } 118 121 public event EventHandler WorldChanged; 119 122 private void OnWorldChanged() { 120 123 var changed = WorldChanged; 121 if (changed != null) 122 changed(this, EventArgs.Empty); 124 if (changed != null) changed(this, EventArgs.Empty); 123 125 } 124 126 public event EventHandler MaxTimeStepsChanged; 125 127 private void OnMaxTimeStepsChanged() { 126 128 var changed = MaxTimeStepsChanged; 127 if (changed != null) 128 changed(this, EventArgs.Empty); 129 if (changed != null) changed(this, EventArgs.Empty); 129 130 } 130 131 -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/ArtificialAntExpressionGrammar.cs
r4068 r4676 22 22 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 25 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; … … 36 37 [StorableConstructor] 37 38 protected ArtificialAntExpressionGrammar(bool deserializing) : base(deserializing) { } 39 protected ArtificialAntExpressionGrammar(ArtificialAntExpressionGrammar original, Cloner cloner) : base(original, cloner) { } 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new ArtificialAntExpressionGrammar(this, cloner); 42 } 38 43 39 44 private void Initialize() { -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/ArtificialAntProblem.cs
r4419 r4676 196 196 [StorableConstructor] 197 197 private ArtificialAntProblem(bool deserializing) : base(deserializing) { } 198 [StorableHook(HookType.AfterDeserialization)] 199 private void AfterDeserialization() { 200 // BackwardsCompatibility3.3 201 #region Backwards compatible code (remove with 3.4) 202 if (operators == null) InitializeOperators(); 203 #endregion 204 AttachEventHandlers(); 205 } 206 207 private ArtificialAntProblem(ArtificialAntProblem original, Cloner cloner) 208 : base(original, cloner) { 209 operators = original.operators.Select(x => cloner.Clone(x)).ToList(); 210 AttachEventHandlers(); 211 } 212 public override IDeepCloneable Clone(Cloner cloner) { 213 return new ArtificialAntProblem(this, cloner); 214 } 198 215 public ArtificialAntProblem() 199 216 : base() { … … 222 239 } 223 240 224 public override IDeepCloneable Clone(Cloner cloner) {225 ArtificialAntProblem clone = (ArtificialAntProblem)base.Clone(cloner);226 clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();227 clone.AttachEventHandlers();228 return clone;229 }230 231 241 #region Events 232 242 public event EventHandler SolutionCreatorChanged; … … 278 288 279 289 #region Helpers 280 [StorableHook(HookType.AfterDeserialization)]281 private void AfterDeserializationHook() {282 // BackwardsCompatibility3.3283 #region Backwards compatible code (remove with 3.4)284 if (operators == null) InitializeOperators();285 #endregion286 AttachEventHandlers();287 }288 289 290 private void AttachEventHandlers() { 290 291 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/Evaluator.cs
r4477 r4676 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 47 48 } 48 49 50 [StorableConstructor] 51 protected Evaluator(bool deserializing) : base(deserializing) { } 52 protected Evaluator(Evaluator original, Cloner cloner) : base(original, cloner) { } 53 public override IDeepCloneable Clone(Cloner cloner) { return new Evaluator(this, cloner); } 49 54 public Evaluator() 50 55 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/Symbols/IfFoodAhead.cs
r4477 r4676 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; … … 27 28 [Item("IfFoodAhead", "Represents the if-food-ahead symbol in a artificial ant expression.")] 28 29 public sealed class IfFoodAhead : Symbol { 30 [StorableConstructor] 31 private IfFoodAhead(bool deserializing) : base(deserializing) { } 32 private IfFoodAhead(IfFoodAhead original, Cloner cloner) : base(original, cloner) { } 33 public override IDeepCloneable Clone(Cloner cloner) { 34 return new IfFoodAhead(this, cloner); 35 } 36 29 37 public IfFoodAhead() : base("IfFoodAhead", "Represents the if-food-ahead symbol in a artificial ant expression.") { } 30 38 } -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/Symbols/Left.cs
r4477 r4676 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; … … 27 28 [Item("Left", "Represents the turn-left symbol in a artificial ant expression.")] 28 29 public sealed class Left : Symbol { 30 [StorableConstructor] 31 private Left(bool deserializing) : base(deserializing) { } 32 private Left(Left original, Cloner cloner) : base(original, cloner) { } 33 public override IDeepCloneable Clone(Cloner cloner) { 34 return new Left(this, cloner); 35 } 29 36 public Left() : base("Left", "Represents the turn-left symbol in a artificial ant expression.") { } 30 37 } -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/Symbols/Move.cs
r4477 r4676 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; … … 27 28 [Item("Move", "Represents the move-forward symbol in a artificial ant expression.")] 28 29 public sealed class Move : Symbol { 30 [StorableConstructor] 31 private Move(bool deserializing) : base(deserializing) { } 32 private Move(Move original, Cloner cloner) : base(original, cloner) { } 33 public override IDeepCloneable Clone(Cloner cloner) { 34 return new Move(this, cloner); 35 } 29 36 public Move() : base("Move", "Represents the move-forward symbol in a artificial ant expression.") { } 30 37 } -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/Symbols/Prog2.cs
r4477 r4676 21 21 22 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; … … 28 29 [Item("Prog2", "Represents the sequence symbol with 2 sub-trees in a artificial ant expression.")] 29 30 public sealed class Prog2 : Symbol { 31 [StorableConstructor] 32 private Prog2(bool deserializing) : base(deserializing) { } 33 private Prog2(Prog2 original, Cloner cloner) : base(original, cloner) { } 34 public override IDeepCloneable Clone(Cloner cloner) { 35 return new Prog2(this, cloner); 36 } 30 37 public Prog2() : base("Prog2", "Represents the sequence symbol with 2 sub-trees in a artificial ant expression.") { } 31 38 } -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/Symbols/Prog3.cs
r4477 r4676 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; … … 27 28 [Item("Prog3", "Represents the sequence symbol with 3 sub-trees in a artificial ant expression.")] 28 29 public sealed class Prog3 : Symbol { 30 [StorableConstructor] 31 private Prog3(bool deserializing) : base(deserializing) { } 32 private Prog3(Prog3 original, Cloner cloner) : base(original, cloner) { } 33 public override IDeepCloneable Clone(Cloner cloner) { 34 return new Prog3(this, cloner); 35 } 29 36 public Prog3() : base("Prog3", "Represents the sequence symbol with 3 sub-trees in a artificial ant expression.") { } 30 37 } -
branches/CloningRefactoring/HeuristicLab.Problems.ArtificialAnt/3.3/Symbols/Right.cs
r4477 r4676 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols; … … 27 28 [Item("Right", "Represents the turn-right symbol in a artificial ant expression.")] 28 29 public sealed class Right : Symbol { 30 [StorableConstructor] 31 private Right(bool deserializing) : base(deserializing) { } 32 private Right(Right original, Cloner cloner) : base(original, cloner) { } 33 public override IDeepCloneable Clone(Cloner cloner) { 34 return new Right(this, cloner); 35 } 29 36 public Right() : base("Right", "Represents the turn-right symbol in a artificial ant expression.") { } 30 37 }
Note: See TracChangeset
for help on using the changeset viewer.