Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (14 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
44 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/MinAverageMaxSymbolicExpressionTreeSizeAnalyzer.cs

    r4068 r4722  
    6565
    6666    #endregion
     67    [StorableConstructor]
     68    private MinAverageMaxSymbolicExpressionTreeSizeAnalyzer(bool deserializing) : base() { }
     69    private MinAverageMaxSymbolicExpressionTreeSizeAnalyzer(MinAverageMaxSymbolicExpressionTreeSizeAnalyzer original, Cloner cloner)
     70      : base(original, cloner) {
     71      AfterDeserialization();
     72    }
    6773    public MinAverageMaxSymbolicExpressionTreeSizeAnalyzer()
    6874      : base() {
     
    95101      valueAnalyzer.Successor = null;
    96102
    97       Initialize();
     103      AfterDeserialization();
    98104    }
    99105
    100     [StorableConstructor]
    101     private MinAverageMaxSymbolicExpressionTreeSizeAnalyzer(bool deserializing) : base() { }
    102106
    103107    [StorableHook(HookType.AfterDeserialization)]
    104     private void Initialize() {
     108    private void AfterDeserialization() {
    105109      SymbolicExpressionTreeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeParameter_DepthChanged);
    106110      SymbolicExpressionTreeSizeParameter.DepthChanged += new EventHandler(SymbolicExpressionTreeSizeParameter_DepthChanged);
     
    108112
    109113    public override IDeepCloneable Clone(Cloner cloner) {
    110       MinAverageMaxSymbolicExpressionTreeSizeAnalyzer clone = (MinAverageMaxSymbolicExpressionTreeSizeAnalyzer)base.Clone(cloner);
    111       clone.Initialize();
    112       return clone;
     114      return new MinAverageMaxSymbolicExpressionTreeSizeAnalyzer(this, cloner);
    113115    }
    114116
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Analyzers/SymbolicExpressionTreeSizeCalculator.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    5556    #endregion
    5657
     58    [StorableConstructor]
     59    private SymbolicExpressionTreeSizeCalculator(bool deserializing) : base(deserializing) { }
     60    private SymbolicExpressionTreeSizeCalculator(SymbolicExpressionTreeSizeCalculator original, Cloner cloner) : base(original, cloner) { }
    5761    public SymbolicExpressionTreeSizeCalculator()
    5862      : base() {
     
    6670      return base.Apply();
    6771    }
     72
     73    public override IDeepCloneable Clone(Cloner cloner) {
     74      return new SymbolicExpressionTreeSizeCalculator(this, cloner);
     75    }
    6876  }
    6977}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/ArgumentCreater.cs

    r4524 r4722  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     25using HeuristicLab.Common;
    2426using HeuristicLab.Core;
    2527using HeuristicLab.Data;
    2628using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2729using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using System;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators {
     
    3637  [StorableClass]
    3738  public sealed class ArgumentCreater : SymbolicExpressionTreeArchitectureManipulator {
     39    [StorableConstructor]
     40    private ArgumentCreater(bool deserializing) : base(deserializing) { }
     41    private ArgumentCreater(ArgumentCreater original, Cloner cloner) : base(original, cloner) { }
     42    public ArgumentCreater() : base() { }
    3843    public override sealed void ModifyArchitecture(
    3944      IRandom random,
     
    4449      out bool success) {
    4550      success = CreateNewArgument(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     51    }
     52
     53    public override IDeepCloneable Clone(Cloner cloner) {
     54      return new ArgumentCreater(this, cloner);
    4655    }
    4756
     
    91100      }
    92101    }
    93 
    94102
    95103    private static bool CreateNewArgumentForDefun(IRandom random, SymbolicExpressionTree tree, DefunTreeNode defunBranch, ArgumentTreeNode newArgumentNode) {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/ArgumentDeleter.cs

    r4068 r4722  
    2121
    2222using System.Linq;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Data;
     
    3334  [StorableClass]
    3435  public sealed class ArgumentDeleter : SymbolicExpressionTreeArchitectureManipulator {
     36    [StorableConstructor]
     37    private ArgumentDeleter(bool deserializing) : base(deserializing) { }
     38    private ArgumentDeleter(ArgumentDeleter original, Cloner cloner) : base(original, cloner) { }
     39    public ArgumentDeleter() : base() { }
     40
    3541    public override sealed void ModifyArchitecture(
    3642      IRandom random,
     
    4147      out bool success) {
    4248      success = DeleteArgument(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     49    }
     50
     51    public override IDeepCloneable Clone(Cloner cloner) {
     52      return new ArgumentDeleter(this, cloner);
    4353    }
    4454
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/ArgumentDuplicater.cs

    r4524 r4722  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using System.Linq;
     25using HeuristicLab.Common;
    2326using HeuristicLab.Core;
    2427using HeuristicLab.Data;
    2528using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2629using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using System.Collections.Generic;
    28 using System;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators {
     
    3637  [StorableClass]
    3738  public sealed class ArgumentDuplicater : SymbolicExpressionTreeArchitectureManipulator {
     39    [StorableConstructor]
     40    private ArgumentDuplicater(bool deserializing) : base(deserializing) { }
     41    private ArgumentDuplicater(ArgumentDuplicater original, Cloner cloner) : base(original, cloner) { }
     42    public ArgumentDuplicater() : base() { }
     43
    3844    public override sealed void ModifyArchitecture(
    3945      IRandom random,
     
    4450      out bool success) {
    4551      success = DuplicateArgument(random, symbolicExpressionTree, grammar, maxTreeSize.Value, maxTreeHeight.Value, maxFunctionDefiningBranches.Value, maxFunctionArguments.Value);
     52    }
     53
     54    public override IDeepCloneable Clone(Cloner cloner) {
     55      return new ArgumentDuplicater(this, cloner);
    4656    }
    4757
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/MultiSymbolicExpressionTreeArchitectureManipulator.cs

    r4068 r4722  
    2323using System.Linq;
    2424using HeuristicLab.Collections;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
     
    3536  [Item("MultiSymbolicExpressionTreeArchitectureManipulator", "Randomly selects and applies one of its architecture manipulators every time it is called.")]
    3637  [StorableClass]
    37   public class MultiSymbolicExpressionTreeArchitectureManipulator : StochasticMultiBranch<ISymbolicExpressionTreeArchitectureManipulator>, ISymbolicExpressionTreeArchitectureManipulator, IStochasticOperator {
     38  public sealed class MultiSymbolicExpressionTreeArchitectureManipulator : StochasticMultiBranch<ISymbolicExpressionTreeArchitectureManipulator>, ISymbolicExpressionTreeArchitectureManipulator, IStochasticOperator {
    3839    private const string MaxTreeSizeParameterName = "MaxTreeSize";
    3940    private const string MaxTreeHeightParameterName = "MaxTreeHeight";
     
    5859    #endregion
    5960
    60 
    6161    #region ISymbolicExpressionTreeManipulator Members
    6262    public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
     
    8080    [StorableConstructor]
    8181    private MultiSymbolicExpressionTreeArchitectureManipulator(bool deserializing) : base(deserializing) { }
     82    private MultiSymbolicExpressionTreeArchitectureManipulator(MultiSymbolicExpressionTreeArchitectureManipulator original, Cloner cloner) : base(original, cloner) { }
    8283    public MultiSymbolicExpressionTreeArchitectureManipulator()
    8384      : base() {
     
    9394          Operators.Add((ISymbolicExpressionTreeArchitectureManipulator)Activator.CreateInstance(type), true);
    9495      }
     96    }
     97
     98    public override IDeepCloneable Clone(Cloner cloner) {
     99      return new MultiSymbolicExpressionTreeArchitectureManipulator(this, cloner);
    95100    }
    96101
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/SubroutineCreater.cs

    r4249 r4722  
    2424using System.Linq;
    2525using System.Text;
     26using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Data;
     
    3940  public sealed class SubroutineCreater : SymbolicExpressionTreeArchitectureManipulator {
    4041    private const double ARGUMENT_CUTOFF_PROBABILITY = 0.05;
     42
     43    [StorableConstructor]
     44    private SubroutineCreater(bool deserializing) : base(deserializing) { }
     45    private SubroutineCreater(SubroutineCreater original, Cloner cloner) : base(original, cloner) { }
     46    public SubroutineCreater() : base() { }
     47
     48    public override IDeepCloneable Clone(Cloner cloner) {
     49      return new SubroutineCreater(this, cloner);
     50    }
    4151
    4252    public override sealed void ModifyArchitecture(
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/SubroutineDeleter.cs

    r4068 r4722  
    2222using System;
    2323using System.Linq;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
     
    3637  [StorableClass]
    3738  public sealed class SubroutineDeleter : SymbolicExpressionTreeArchitectureManipulator {
     39    [StorableConstructor]
     40    private SubroutineDeleter(bool deserializing) : base(deserializing) { }
     41    private SubroutineDeleter(SubroutineDeleter original, Cloner cloner) : base(original, cloner) { }
     42    public SubroutineDeleter() : base() { }
     43
     44    public override IDeepCloneable Clone(Cloner cloner) {
     45      return new SubroutineDeleter(this, cloner);
     46    }
     47
    3848    public override sealed void ModifyArchitecture(
    3949      IRandom random,
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/SubroutineDuplicater.cs

    r4249 r4722  
    2424using System.Linq;
    2525using System.Text;
     26using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Data;
     
    3738  [StorableClass]
    3839  public sealed class SubroutineDuplicater : SymbolicExpressionTreeArchitectureManipulator {
     40    [StorableConstructor]
     41    private SubroutineDuplicater(bool deserializing) : base(deserializing) { }
     42    private SubroutineDuplicater(SubroutineDuplicater original, Cloner cloner)
     43      : base(original, cloner) {
     44    }
     45    public SubroutineDuplicater() : base() { }
     46
     47    public override IDeepCloneable Clone(Cloner cloner) {
     48      return new SubroutineDuplicater(this, cloner);
     49    }
     50
    3951    public override sealed void ModifyArchitecture(
    4052      IRandom random,
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/SymbolicExpressionTreeArchitectureManipulator.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    5152      get { return MaxFunctionArgumentsParameter.ActualValue; }
    5253    }
     54    [StorableConstructor]
     55    protected SymbolicExpressionTreeArchitectureManipulator(bool deserializing) : base(deserializing) { }
     56    protected SymbolicExpressionTreeArchitectureManipulator(SymbolicExpressionTreeArchitectureManipulator original, Cloner cloner) : base(original, cloner) { }
    5357    public SymbolicExpressionTreeArchitectureManipulator()
    5458      : base() {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Creators/ProbabilisticTreeCreator.cs

    r4477 r4722  
    2424using System.Linq;
    2525using System.Text;
     26using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Data;
     
    3334  [StorableClass]
    3435  [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed size")]
    35   public class ProbabilisticTreeCreator : SymbolicExpressionTreeCreator {
     36  public sealed class ProbabilisticTreeCreator : SymbolicExpressionTreeCreator {
    3637    private const int MAX_TRIES = 100;
    37 
    38     public ProbabilisticTreeCreator()
    39       : base() {
     38    [StorableConstructor]
     39    private ProbabilisticTreeCreator(bool deserializing) : base(deserializing) { }
     40    private ProbabilisticTreeCreator(ProbabilisticTreeCreator original, Cloner cloner) : base(original, cloner) { }
     41    public ProbabilisticTreeCreator() : base() { }
     42
     43    public override IDeepCloneable Clone(Cloner cloner) {
     44      return new ProbabilisticTreeCreator(this, cloner);
    4045    }
    4146
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Creators/SymbolicExpressionTreeCreator.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    6162
    6263    #endregion
     64    [StorableConstructor]
     65    protected SymbolicExpressionTreeCreator(bool deserializing) : base(deserializing) { }
     66    protected SymbolicExpressionTreeCreator(SymbolicExpressionTreeCreator original, Cloner cloner) : base(original, cloner) { }
    6367    protected SymbolicExpressionTreeCreator()
    6468      : base() {
     
    7175      SymbolicExpressionTree = Create(Random, SymbolicExpressionGrammar,
    7276        MaxTreeSize, MaxTreeHeight, MaxFunctionDefinitions, MaxFunctionArguments);
    73       return null;
     77      return base.Apply();
    7478    }
    7579
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Crossovers/SubtreeCrossover.cs

    r4106 r4722  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
     
    3738  [Item("SubtreeCrossover", "An operator which performs subtree swapping crossover.")]
    3839  [StorableClass]
    39   public class SubtreeCrossover : SymbolicExpressionTreeCrossover {
     40  public sealed class SubtreeCrossover : SymbolicExpressionTreeCrossover {
    4041    public IValueLookupParameter<PercentValue> InternalCrossoverPointProbabilityParameter {
    4142      get { return (IValueLookupParameter<PercentValue>)Parameters["InternalCrossoverPointProbability"]; }
    4243    }
    43 
     44    [StorableConstructor]
     45    private SubtreeCrossover(bool deserializing) : base(deserializing) { }
     46    private SubtreeCrossover(SubtreeCrossover original, Cloner cloner) : base(original, cloner) { }
    4447    public SubtreeCrossover()
    4548      : base() {
    4649      Parameters.Add(new ValueLookupParameter<PercentValue>("InternalCrossoverPointProbability", "The probability to select an internal crossover point (instead of a leaf node).", new PercentValue(0.9)));
     50    }
     51
     52    public override IDeepCloneable Clone(Cloner cloner) {
     53      return new SubtreeCrossover(this, cloner);
    4754    }
    4855
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Crossovers/SymbolicExpressionTreeCrossover.cs

    r4123 r4722  
    2121
    2222using System;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Data;
     
    5051      get { return FailedCrossoverEventsParameter.Value; }
    5152    }
     53    [StorableConstructor]
     54    protected SymbolicExpressionTreeCrossover(bool deserializing) : base(deserializing) { }
     55    protected SymbolicExpressionTreeCrossover(SymbolicExpressionTreeCrossover original, Cloner cloner) : base(original, cloner) { }
    5256    protected SymbolicExpressionTreeCrossover()
    5357      : base() {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/DefaultSymbolicExpressionGrammar.cs

    r4262 r4722  
    8888    private Symbol startSymbol;
    8989
     90    [StorableConstructor]
     91    protected DefaultSymbolicExpressionGrammar(bool deserializing)
     92      : base(deserializing) {
     93      cachedMinExpressionLength = new Dictionary<string, int>();
     94      cachedMaxExpressionLength = new Dictionary<string, int>();
     95      cachedMinExpressionDepth = new Dictionary<string, int>();
     96    }
     97    // cloning ctor
     98    protected DefaultSymbolicExpressionGrammar(DefaultSymbolicExpressionGrammar original, Cloner cloner)
     99      : base(original, cloner) {
     100      this.cachedMinExpressionLength = new Dictionary<string, int>();
     101      this.cachedMaxExpressionLength = new Dictionary<string, int>();
     102      this.cachedMinExpressionDepth = new Dictionary<string, int>();
     103      minSubTreeCount = new Dictionary<string, int>(original.minSubTreeCount);
     104      maxSubTreeCount = new Dictionary<string, int>(original.maxSubTreeCount);
     105
     106      allSymbols = new Dictionary<string, Symbol>();
     107      foreach (Symbol symbol in original.allSymbols.Values.Select(s => cloner.Clone(s)))
     108        allSymbols.Add(symbol.Name, symbol);
     109
     110      startSymbol = cloner.Clone<Symbol>(original.startSymbol);
     111      allowedChildSymbols = new Dictionary<string, List<List<string>>>();
     112      foreach (var entry in original.allowedChildSymbols) {
     113        allowedChildSymbols[entry.Key] = new List<List<string>>(entry.Value.Count);
     114        foreach (var set in entry.Value) {
     115          allowedChildSymbols[entry.Key].Add(new List<string>(set));
     116        }
     117      }
     118    }
    90119    protected DefaultSymbolicExpressionGrammar()
    91120      : base() {
     
    136165    }
    137166
    138     [StorableConstructor]
    139     protected DefaultSymbolicExpressionGrammar(bool deserializing)
    140       : base(deserializing) {
    141       cachedMinExpressionLength = new Dictionary<string, int>();
    142       cachedMaxExpressionLength = new Dictionary<string, int>();
    143       cachedMinExpressionDepth = new Dictionary<string, int>();
    144     }
    145 
    146167    public void Clear() {
    147168      minSubTreeCount.Clear();
     
    289310    }
    290311
    291     public override IDeepCloneable Clone(Cloner cloner) {
    292       DefaultSymbolicExpressionGrammar clone = (DefaultSymbolicExpressionGrammar)base.Clone(cloner);
    293 
    294       clone.minSubTreeCount = new Dictionary<string, int>(this.minSubTreeCount);
    295       clone.maxSubTreeCount = new Dictionary<string, int>(this.maxSubTreeCount);
    296 
    297       clone.allSymbols = new Dictionary<string, Symbol>();
    298       foreach (Symbol symbol in this.allSymbols.Values.Select(s => cloner.Clone(s)))
    299         clone.allSymbols.Add(symbol.Name, symbol);
    300 
    301       clone.startSymbol = (Symbol)cloner.Clone(this.startSymbol);
    302       clone.allowedChildSymbols = new Dictionary<string, List<List<string>>>();
    303       foreach (var entry in this.allowedChildSymbols) {
    304         clone.allowedChildSymbols[entry.Key] = new List<List<string>>(entry.Value.Count);
     312    protected void InitializeShallowClone(DefaultSymbolicExpressionGrammar original) {
     313      minSubTreeCount = new Dictionary<string, int>(original.minSubTreeCount);
     314      maxSubTreeCount = new Dictionary<string, int>(original.maxSubTreeCount);
     315
     316      allSymbols = new Dictionary<string, Symbol>(original.allSymbols);
     317      startSymbol = original.startSymbol;
     318      allowedChildSymbols = new Dictionary<string, List<List<string>>>(original.allowedChildSymbols.Count);
     319      foreach (var entry in original.allowedChildSymbols) {
     320        allowedChildSymbols[entry.Key] = new List<List<string>>(entry.Value.Count);
    305321        foreach (var set in entry.Value) {
    306           clone.allowedChildSymbols[entry.Key].Add(new List<string>(set));
    307         }
    308       }
    309 
    310       return clone;
    311     }
    312 
    313     protected void InitializeShallowClone(DefaultSymbolicExpressionGrammar clone) {
    314       clone.minSubTreeCount = new Dictionary<string, int>(this.minSubTreeCount);
    315       clone.maxSubTreeCount = new Dictionary<string, int>(this.maxSubTreeCount);
    316 
    317       clone.allSymbols = new Dictionary<string, Symbol>(this.allSymbols);
    318       clone.startSymbol = this.startSymbol;
    319       clone.allowedChildSymbols = new Dictionary<string, List<List<string>>>(this.allowedChildSymbols.Count);
    320       foreach (var entry in this.allowedChildSymbols) {
    321         clone.allowedChildSymbols[entry.Key] = new List<List<string>>(entry.Value.Count);
    322         foreach (var set in entry.Value) {
    323           clone.allowedChildSymbols[entry.Key].Add(new List<string>(set));
     322          allowedChildSymbols[entry.Key].Add(new List<string>(set));
    324323        }
    325324      }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/GlobalSymbolicExpressionGrammar.cs

    r4262 r4722  
    6969    private Defun defunSymbol;
    7070
     71    [StorableConstructor]
     72    private GlobalSymbolicExpressionGrammar(bool deserializing) : base(deserializing) { }
     73    private GlobalSymbolicExpressionGrammar(GlobalSymbolicExpressionGrammar original, Cloner cloner)
     74      : base(original, cloner) {
     75      defunSymbol = (Defun)cloner.Clone(original.defunSymbol);
     76      maxFunctionArguments = original.maxFunctionArguments;
     77      minFunctionArguments = original.minFunctionArguments;
     78      maxFunctionDefinitions = original.maxFunctionDefinitions;
     79      minFunctionDefinitions = original.minFunctionDefinitions;
     80    }
     81
    7182    public GlobalSymbolicExpressionGrammar(ISymbolicExpressionGrammar mainBranchGrammar)
    7283      : base(mainBranchGrammar) {
     
    100111          SetAllowedChild(defunSymbol, Symbols.Where(s => s.Name == symb.Name).First(), 0);
    101112      }
    102     }
    103 
    104     //ctor for cloning
    105     private GlobalSymbolicExpressionGrammar() : base() { }
    106     [StorableConstructor]
    107     private GlobalSymbolicExpressionGrammar(bool deserializing)
    108       : base(deserializing) {
    109113    }
    110114
     
    171175
    172176    public override IDeepCloneable Clone(Cloner cloner) {
    173       GlobalSymbolicExpressionGrammar clone = (GlobalSymbolicExpressionGrammar)base.Clone(cloner);
    174       clone.defunSymbol = (Defun)cloner.Clone(this.defunSymbol);
    175       clone.maxFunctionArguments = this.maxFunctionArguments;
    176       clone.minFunctionArguments = this.minFunctionArguments;
    177       clone.maxFunctionDefinitions = this.maxFunctionDefinitions;
    178       clone.minFunctionDefinitions = this.minFunctionDefinitions;
    179       return clone;
     177      return new GlobalSymbolicExpressionGrammar(this, cloner);
    180178    }
    181179  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/ChangeNodeTypeManipulation.cs

    r4189 r4722  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
     
    3132  [StorableClass]
    3233  [Item("ChangeNodeTypeManipulation", "Selects a random tree node and changes the symbol.")]
    33   public class ChangeNodeTypeManipulation : SymbolicExpressionTreeManipulator {
     34  public sealed class ChangeNodeTypeManipulation : SymbolicExpressionTreeManipulator {
    3435
    35     public ChangeNodeTypeManipulation()
    36       : base() {
     36    [StorableConstructor]
     37    private ChangeNodeTypeManipulation(bool deserializing) : base(deserializing) { }
     38    private ChangeNodeTypeManipulation(ChangeNodeTypeManipulation original, Cloner cloner) : base(original, cloner) { }
     39    public ChangeNodeTypeManipulation() : base() { }
     40
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new ChangeNodeTypeManipulation(this, cloner);
    3743    }
    3844
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/FullTreeShaker.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    2728  [StorableClass]
    2829  [Item("FullTreeShaker", "Manipulates all nodes that have local parameters.")]
    29   public class FullTreeShaker : SymbolicExpressionTreeManipulator {
     30  public sealed class FullTreeShaker : SymbolicExpressionTreeManipulator {
    3031
    31     public FullTreeShaker()
    32       : base() {
     32    [StorableConstructor]
     33    private FullTreeShaker(bool deserializing) : base(deserializing) { }
     34    private FullTreeShaker(FullTreeShaker original, Cloner cloner) : base(original, cloner) { }
     35    public FullTreeShaker() : base() { }
     36
     37    public override IDeepCloneable Clone(Cloner cloner) {
     38      return new FullTreeShaker(this, cloner);
    3339    }
    3440
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/MultiSymbolicExpressionTreeManipulator.cs

    r4068 r4722  
    2323using System.Linq;
    2424using HeuristicLab.Collections;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
     
    3536  [Item("MultiSymbolicExpressionTreeManipulator", "Randomly selects and applies one of its manipulators every time it is called.")]
    3637  [StorableClass]
    37   public class MultiSymbolicExpressionTreeManipulator : StochasticMultiBranch<ISymbolicExpressionTreeManipulator>, ISymbolicExpressionTreeManipulator, IStochasticOperator {
     38  public sealed class MultiSymbolicExpressionTreeManipulator : StochasticMultiBranch<ISymbolicExpressionTreeManipulator>, ISymbolicExpressionTreeManipulator, IStochasticOperator {
    3839    private const string MaxTreeSizeParameterName = "MaxTreeSize";
    3940    private const string MaxTreeHeightParameterName = "MaxTreeHeight";
     
    6667    #endregion
    6768
    68 
    6969    [StorableConstructor]
    7070    private MultiSymbolicExpressionTreeManipulator(bool deserializing) : base(deserializing) { }
     71    private MultiSymbolicExpressionTreeManipulator(MultiSymbolicExpressionTreeManipulator original, Cloner cloner) : base(original, cloner) { }
    7172    public MultiSymbolicExpressionTreeManipulator()
    7273      : base() {
     
    8081          Operators.Add((ISymbolicExpressionTreeManipulator)Activator.CreateInstance(type), true);
    8182      }
     83    }
     84
     85    public override IDeepCloneable Clone(Cloner cloner) {
     86      return new MultiSymbolicExpressionTreeManipulator(this, cloner);
    8287    }
    8388
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/OnePointShaker.cs

    r4068 r4722  
    2121
    2222using System.Linq;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Data;
     
    2829  [StorableClass]
    2930  [Item("OnePointShaker", "Selects a random node with local parameters and manipulates the selected node.")]
    30   public class OnePointShaker : SymbolicExpressionTreeManipulator {
     31  public sealed class OnePointShaker : SymbolicExpressionTreeManipulator {
     32    [StorableConstructor]
     33    private OnePointShaker(bool deserializing) : base(deserializing) { }
     34    private OnePointShaker(OnePointShaker original, Cloner cloner) : base(original, cloner) { }
     35    public OnePointShaker() : base() { }
    3136
    32     public OnePointShaker()
    33       : base() {
     37    public override IDeepCloneable Clone(Cloner cloner) {
     38      return new OnePointShaker(this, cloner);
    3439    }
    3540
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/ReplaceBranchManipulation.cs

    r4189 r4722  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
     28using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    2729using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2830using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    3031
    3132namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators {
    3233  [StorableClass]
    3334  [Item("ReplaceBranchManipulation", "Selects a branch of the tree randomly and replaces it with a newly initialized branch (using PTC2).")]
    34   public class ReplaceBranchManipulation : SymbolicExpressionTreeManipulator {
     35  public sealed class ReplaceBranchManipulation : SymbolicExpressionTreeManipulator {
     36    [StorableConstructor]
     37    private ReplaceBranchManipulation(bool deserializing) : base(deserializing) { }
     38    private ReplaceBranchManipulation(ReplaceBranchManipulation original, Cloner cloner) : base(original, cloner) { }
     39    public ReplaceBranchManipulation() : base() { }
    3540
    36     public ReplaceBranchManipulation()
    37       : base() {
     41    public override IDeepCloneable Clone(Cloner cloner) {
     42      return new ReplaceBranchManipulation(this, cloner);
    3843    }
    3944
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/SymbolicExpressionTreeManipulator.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    5455    #endregion
    5556
     57    [StorableConstructor]
     58    protected SymbolicExpressionTreeManipulator(bool deserializing) : base(deserializing) { }
     59    protected SymbolicExpressionTreeManipulator(SymbolicExpressionTreeManipulator original, Cloner cloner) : base(original, cloner) { }
    5660    public SymbolicExpressionTreeManipulator()
    5761      : base() {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTree.cs

    r4068 r4722  
    6363    }
    6464
    65     public SymbolicExpressionTree()
    66       : base() {
     65    [StorableConstructor]
     66    protected SymbolicExpressionTree(bool deserializing) : base(deserializing) { }
     67    protected SymbolicExpressionTree(SymbolicExpressionTree original, Cloner cloner)
     68      : base(original, cloner) {
     69      root = cloner.Clone(original.Root);
    6770    }
    68 
     71    public SymbolicExpressionTree() : base() { }
    6972    public SymbolicExpressionTree(SymbolicExpressionTreeNode root)
    7073      : base() {
     
    8487
    8588    public override IDeepCloneable Clone(Cloner cloner) {
    86       SymbolicExpressionTree clone = new SymbolicExpressionTree();
    87       cloner.RegisterClonedObject(this, clone);
    88       if (root != null)
    89         clone.root = (SymbolicExpressionTreeNode)this.root.Clone();
    90       return clone;
     89      return new SymbolicExpressionTree(this, cloner);
    9190    }
    9291  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeGrammar.cs

    r4249 r4722  
    3030    [StorableConstructor]
    3131    private SymbolicExpressionTreeGrammar(bool deserializing) : base(deserializing) { }
    32     //default ctor for cloning
    33     private SymbolicExpressionTreeGrammar() : base(false) { }
     32    // don't call storable ctor of base class to prevent full cloning
     33    // instead use storable ctor to initialize an empty grammar and fill with InizializeShallowClone
     34    private SymbolicExpressionTreeGrammar(SymbolicExpressionTreeGrammar original, Cloner cloner)
     35      : base(false) {
     36      cloner.RegisterClonedObject(original, this);
     37      InitializeShallowClone(original);
     38    }
     39    private SymbolicExpressionTreeGrammar() : base() { }
    3440
    3541    public override IDeepCloneable Clone(Cloner cloner) {
    36       SymbolicExpressionTreeGrammar clone = new SymbolicExpressionTreeGrammar();
    37       cloner.RegisterClonedObject(this, clone);
    38       InitializeShallowClone(clone);
    39       return clone;
     42      return new SymbolicExpressionTreeGrammar(this, cloner);
    4043    }
    4144  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeNode.cs

    r4524 r4722  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2930namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    3031  [StorableClass]
    31   public class SymbolicExpressionTreeNode : ICloneable {
     32  public class SymbolicExpressionTreeNode : DeepCloneable {
    3233    [Storable]
    3334    private IList<SymbolicExpressionTreeNode> subTrees;
     
    5152    }
    5253
    53     internal SymbolicExpressionTreeNode() {
     54    [StorableConstructor]
     55    protected SymbolicExpressionTreeNode(bool deserializing) { }
     56    protected SymbolicExpressionTreeNode(SymbolicExpressionTreeNode original, Cloner cloner)
     57      : base() {
     58      symbol = original.symbol; // symbols are reused
     59      subTrees = new List<SymbolicExpressionTreeNode>(original.SubTrees.Count);
     60      foreach (var subtree in original.SubTrees) {
     61        var clonedSubTree = cloner.Clone(subtree);
     62        subTrees.Add(clonedSubTree);
     63        clonedSubTree.Parent = this;
     64      }
     65    }
     66    public override IDeepCloneable Clone(Cloner cloner) {
     67      return new SymbolicExpressionTreeNode(this, cloner);
     68    }
     69
     70    internal SymbolicExpressionTreeNode()
     71      : base() {
    5472      // don't allocate subtrees list here!
    5573      // because we don't want to allocate it in terminal nodes
    5674    }
    5775
    58     public SymbolicExpressionTreeNode(Symbol symbol) {
     76    public SymbolicExpressionTreeNode(Symbol symbol)
     77      : base() {
    5978      subTrees = new List<SymbolicExpressionTreeNode>(3);
    6079      this.symbol = symbol;
    6180    }
    6281
    63     // copy constructor
    64     protected SymbolicExpressionTreeNode(SymbolicExpressionTreeNode original) {
    65       symbol = original.symbol;
    66       subTrees = new List<SymbolicExpressionTreeNode>(original.SubTrees.Count);
    67       foreach (var subtree in original.SubTrees) {
    68         AddSubTree((SymbolicExpressionTreeNode)subtree.Clone());
    69       }
    70     }
    7182
    7283    [StorableHook(HookType.AfterDeserialization)]
    73     private void AfterDeserializationHook() {
     84    private void AfterDeserialization() {
    7485      foreach (var subtree in SubTrees) {
    7586        subtree.Parent = this;
     
    173184      return Grammar.GetMaxSubtreeCount(Symbol);
    174185    }
    175 
    176     #region ICloneable Members
    177 
    178     public virtual object Clone() {
    179       return new SymbolicExpressionTreeNode(this);
    180     }
    181 
    182     #endregion
    183 
    184186    public override string ToString() {
    185187      return Symbol.Name;
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeOperator.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    7475    #endregion
    7576
     77    [StorableConstructor]
     78    protected SymbolicExpressionTreeOperator(bool deserializing) : base(deserializing) { }
     79    protected SymbolicExpressionTreeOperator(SymbolicExpressionTreeOperator original, Cloner cloner) : base(original, cloner) { }
    7680    protected SymbolicExpressionTreeOperator()
    7781      : base() {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeStringFormatter.cs

    r4068 r4722  
    2121
    2222using System.Text;
    23 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2423
    2524namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    26   [StorableClass]
     25 
    2726  public class SymbolicExpressionTreeStringFormatter {
    28     [Storable]
     27   
    2928    public bool Indent { get; set; }
    30 
     29   
    3130    public SymbolicExpressionTreeStringFormatter()
    3231      : base() {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeTerminalNode.cs

    r4068 r4722  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2930  public abstract class SymbolicExpressionTreeTerminalNode : SymbolicExpressionTreeNode {
    3031    private static List<SymbolicExpressionTreeNode> emptyList = new List<SymbolicExpressionTreeNode>();
     32    public override IList<SymbolicExpressionTreeNode> SubTrees {
     33      get {
     34        return SymbolicExpressionTreeTerminalNode.emptyList;
     35      }
     36    }
    3137
     38    [StorableConstructor]
     39    protected SymbolicExpressionTreeTerminalNode(bool deserializing) : base(deserializing) { }
     40    // don't call storable constructor of base to prevent allocation of sub-trees list in base!
     41    protected SymbolicExpressionTreeTerminalNode(SymbolicExpressionTreeTerminalNode original, Cloner cloner)
     42      : base() {
     43      // symbols are reused
     44      this.Symbol = original.Symbol;
     45    }
    3246    protected SymbolicExpressionTreeTerminalNode() : base() { }
    33     // don't call  base constructors to prevent allocation of sub-trees list in base!
    34     protected SymbolicExpressionTreeTerminalNode(Symbol symbol) {
     47
     48    protected SymbolicExpressionTreeTerminalNode(Symbol symbol)
     49      : base() {
     50      // symbols are reused
    3551      this.Symbol = symbol;
    36     }
    37     // don't call  base constructors to prevent allocation of sub-trees list in base!
    38     protected SymbolicExpressionTreeTerminalNode(SymbolicExpressionTreeTerminalNode original) {
    39       this.Symbol = original.Symbol;
    4052    }
    4153
     
    4961      throw new NotSupportedException();
    5062    }
    51     public override IList<SymbolicExpressionTreeNode> SubTrees {
    52       get {
    53         return SymbolicExpressionTreeTerminalNode.emptyList;
    54       }
    55     }
    5663  }
    5764}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeTopLevelNode.cs

    r4249 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2627  [StorableClass]
    2728  public class SymbolicExpressionTreeTopLevelNode : SymbolicExpressionTreeNode {
    28     public SymbolicExpressionTreeTopLevelNode()
    29       : base() {
    30     }
    31 
    32     public SymbolicExpressionTreeTopLevelNode(Symbol symbol)
    33       : base(symbol) {
    34     }
    35 
    3629    [Storable]
    3730    private ISymbolicExpressionGrammar grammar;
     
    4336    }
    4437
    45     // copy constructor
    46     protected SymbolicExpressionTreeTopLevelNode(SymbolicExpressionTreeTopLevelNode original)
    47       : base(original) {
    48       if (original.Grammar != null)
    49         grammar = (ISymbolicExpressionGrammar)original.Grammar.Clone();
    50       //grammar = original.grammar;
     38    [StorableConstructor]
     39    protected SymbolicExpressionTreeTopLevelNode(bool deserializing) : base(deserializing) { }
     40    protected SymbolicExpressionTreeTopLevelNode(SymbolicExpressionTreeTopLevelNode original, Cloner cloner)
     41      : base(original, cloner) {
     42      grammar = cloner.Clone(original.Grammar);
    5143    }
     44    public SymbolicExpressionTreeTopLevelNode() : base() { }
     45    public SymbolicExpressionTreeTopLevelNode(Symbol symbol) : base(symbol) { }
    5246
    53     public override object Clone() {
    54       return new SymbolicExpressionTreeTopLevelNode(this);
     47
     48    public override IDeepCloneable Clone(Cloner cloner) {
     49      return new SymbolicExpressionTreeTopLevelNode(this, cloner);
    5550    }
    5651  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/Argument.cs

    r4068 r4722  
    4343
    4444    [StorableConstructor]
    45     private Argument() : base() { }
    46 
     45    private Argument(bool deserializing) : base(deserializing) { }
     46    private Argument(Argument original, Cloner cloner)
     47      : base(original, cloner) {
     48      argumentIndex = original.argumentIndex;
     49      name = "ARG" + original.argumentIndex;
     50    }
    4751    public Argument(int argumentIndex)
    4852      : base("ARG" + argumentIndex, Argument.ArgumentDescription) {
     
    5660
    5761    public override IDeepCloneable Clone(Cloner cloner) {
    58       Argument clone = (Argument)base.Clone(cloner);
    59       clone.argumentIndex = argumentIndex;
    60       clone.name = "ARG" + argumentIndex;
    61       return clone;
     62      return new Argument(this, cloner);
    6263    }
    6364  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/ArgumentTreeNode.cs

    r3486 r4722  
    2121
    2222using System;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2425namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols {
     
    3435    }
    3536
    36     private ArgumentTreeNode() : base() { }
    37 
    38     // copy constructor
    39     private ArgumentTreeNode(ArgumentTreeNode original)
    40       : base(original) {
    41     }
    42 
     37    [StorableConstructor]
     38    private ArgumentTreeNode(bool deserializing) : base(deserializing) { }
     39    private ArgumentTreeNode(ArgumentTreeNode original, Cloner cloner) : base(original, cloner) { }
    4340    public ArgumentTreeNode(Argument argSymbol) : base(argSymbol) { }
    4441
    45     public override object Clone() {
    46       return new ArgumentTreeNode(this);
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      return new ArgumentTreeNode(this, cloner);
    4744    }
    4845  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/Defun.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3233    public const string DefunDescription = "Symbol that represents a function defining node.";
    3334
    34     public Defun() : base(Defun.DefunName, Defun.DefunDescription) { }
    3535    [StorableConstructor]
    3636    private Defun(bool deserializing) : base(deserializing) { }
     37    private Defun(Defun original, Cloner cloner) : base(original, cloner) { }
     38    public Defun() : base(Defun.DefunName, Defun.DefunDescription) { }
     39
     40    public override IDeepCloneable Clone(Cloner cloner) {
     41      return new Defun(this, cloner);
     42    }
    3743
    3844    public override SymbolicExpressionTreeNode CreateTreeNode() {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/DefunTreeNode.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2324namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols {
     
    3738    }
    3839
    39     private DefunTreeNode() : base() { }
    40 
    41     // copy constructor
    42     private DefunTreeNode(DefunTreeNode original)
    43       : base(original) {
     40    [StorableConstructor]
     41    private DefunTreeNode(bool deserializing) : base(deserializing) { }
     42    private DefunTreeNode(DefunTreeNode original, Cloner cloner)
     43      : base(original, cloner) {
    4444      functionName = original.functionName;
    4545      numberOfArguments = original.numberOfArguments;
     
    4848    public DefunTreeNode(Defun defunSymbol) : base(defunSymbol) { }
    4949
    50 
    51     public override object Clone() {
    52       return new DefunTreeNode(this);
     50    public override IDeepCloneable Clone(Cloner cloner) {
     51      return new DefunTreeNode(this, cloner);
    5352    }
    5453
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/InvokeFunction.cs

    r4106 r4722  
    5050    [StorableConstructor]
    5151    private InvokeFunction(bool deserializing) : base(deserializing) { }
     52    private InvokeFunction(InvokeFunction original, Cloner cloner)
     53      : base(original, cloner) {
     54      functionName = original.functionName;
     55      name = "Invoke: " + original.functionName;
     56    }
    5257    public InvokeFunction(string functionName)
    5358      : base("Invoke: " + functionName, InvokeFunction.InvokeFunctionDescription) {
     
    6065
    6166    public override IDeepCloneable Clone(Cloner cloner) {
    62       InvokeFunction clone = (InvokeFunction)base.Clone(cloner);
    63       clone.functionName = functionName;
    64       clone.name = "Invoke: " + functionName;
    65       return clone;
     67      return new InvokeFunction(this, cloner);
    6668    }
    6769  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/InvokeFunctionTreeNode.cs

    r3484 r4722  
    2121
    2222using System;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2425namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols {
     
    3435    }
    3536
    36     private InvokeFunctionTreeNode() : base() { }
    37 
    38     // copy constructor
    39     private InvokeFunctionTreeNode(InvokeFunctionTreeNode original)
    40       : base(original) {
    41     }
    42 
     37    [StorableConstructor]
     38    private InvokeFunctionTreeNode(bool deserializing) : base(deserializing) { }
     39    private InvokeFunctionTreeNode(InvokeFunctionTreeNode original, Cloner cloner) : base(original, cloner) { }
    4340    public InvokeFunctionTreeNode(InvokeFunction invokeSymbol) : base(invokeSymbol) { }
    4441
    45     public override object Clone() {
    46       return new InvokeFunctionTreeNode(this);
     42    public override IDeepCloneable Clone(Cloner cloner) {
     43      return new InvokeFunctionTreeNode(this, cloner);
    4744    }
    4845  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/ProgramRootSymbol.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2930    public const string ProgramRootSymbolDescription = "Special symbol that represents the program root node of a symbolic expression tree.";
    3031
    31     public ProgramRootSymbol() : base(ProgramRootSymbol.ProgramRootSymbolName, ProgramRootSymbol.ProgramRootSymbolDescription) { }
    3232    [StorableConstructor]
    3333    private ProgramRootSymbol(bool deserializing) : base(deserializing) { }
     34    private ProgramRootSymbol(ProgramRootSymbol original, Cloner cloner) : base(original, cloner) { }
     35    public ProgramRootSymbol() : base(ProgramRootSymbol.ProgramRootSymbolName, ProgramRootSymbol.ProgramRootSymbolDescription) { }
    3436
     37    public override IDeepCloneable Clone(Cloner cloner) {
     38      return new ProgramRootSymbol(this, cloner);
     39    }
    3540    public override SymbolicExpressionTreeNode CreateTreeNode() {
    3641      return new SymbolicExpressionTreeTopLevelNode(this);
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/ReadOnlySymbol.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2728  [Item("ReadOnlySymbol", "Represents a symbol in a symbolic function tree that cannot be modified.")]
    2829  public abstract class ReadOnlySymbol : Symbol {
    29     //#region Properties
    30     //[Storable]
    31     //private double initialFrequency;
    32     //public double InitialFrequency {
    33     //  get { return initialFrequency; }
    34     //  set { throw new NotSupportedException(); }
    35     //}
    36     //#endregion
    3730
    3831    public override bool CanChangeName {
     
    4336    }
    4437
    45     protected ReadOnlySymbol() : base() { }
    46     protected ReadOnlySymbol(string name, string description) : base(name, description) { }
    4738    [StorableConstructor]
    4839    protected ReadOnlySymbol(bool deserializing) : base(deserializing) { }
     40    protected ReadOnlySymbol(ReadOnlySymbol original, Cloner cloner) : base(original, cloner) { }
     41    protected ReadOnlySymbol(string name, string description) : base(name, description) { }
    4942  }
    5043}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/StartSymbol.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2930    public const string StartSymbolDescription = "Special symbol that represents the starting node of the result producing branch of a symbolic expression tree.";
    3031
    31     public StartSymbol() : base(StartSymbol.StartSymbolName, StartSymbol.StartSymbolDescription) { }
    3232    [StorableConstructor]
    3333    private StartSymbol(bool deserializing) : base(deserializing) { }
     34    private StartSymbol(StartSymbol original, Cloner cloner) : base(original, cloner) { }
     35    public StartSymbol() : base(StartSymbol.StartSymbolName, StartSymbol.StartSymbolDescription) { }
     36
     37    public override IDeepCloneable Clone(Cloner cloner) {
     38      return new StartSymbol(this, cloner);
     39    }
    3440
    3541    public override SymbolicExpressionTreeNode CreateTreeNode() {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Symbols/Symbol.cs

    r4477 r4722  
    4747    #endregion
    4848
     49    [StorableConstructor]
     50    protected Symbol(bool deserializing) : base(deserializing) { }
     51    protected Symbol(Symbol original, Cloner cloner)
     52      : base(original, cloner) {
     53      initialFrequency = original.initialFrequency;
     54    }
    4955    protected Symbol()
    5056      : base() {
     
    5763    }
    5864
    59     [StorableConstructor]
    60     protected Symbol(bool deserializing) : base(deserializing) { }
    6165
    6266    public virtual SymbolicExpressionTreeNode CreateTreeNode() {
    6367      return new SymbolicExpressionTreeNode(this);
    64     }
    65 
    66     public override IDeepCloneable Clone(Cloner cloner) {
    67       Symbol clone = (Symbol)base.Clone(cloner);
    68       clone.initialFrequency = initialFrequency;
    69       return clone;
    7068    }
    7169
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ChangeNodeTypeManipulationTest.cs

    r4189 r4722  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    2625using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
     26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
    2727using HeuristicLab.Random;
    2828using Microsoft.VisualStudio.TestTools.UnitTesting;
    29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
    3029
    3130namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/Grammars.cs

    r4106 r4722  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     
    2627namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
    2728  public static class Grammars {
    28     private class Addition : Symbol { public Addition() : base("Addition", "") { } }
    29     private class Subtraction : Symbol { public Subtraction() : base("Subtraction", "") { } }
    30     private class Multiplication : Symbol { public Multiplication() : base("Multiplication", "") { } }
    31     private class Division : Symbol { public Division() : base("Division", "") { } }
    32     private class Terminal : Symbol { public Terminal() : base("Terminal", "") { } }
     29    private class Addition : Symbol {
     30      protected Addition(Addition original, Cloner cloner) : base(original, cloner) { }
     31      public Addition() : base("Addition", "") { }
     32      public override IDeepCloneable Clone(Cloner cloner) {
     33        return new Addition(this, cloner);
     34      }
     35    }
     36    private class Subtraction : Symbol {
     37      protected Subtraction(Subtraction original, Cloner cloner) : base(original, cloner) { }
     38      public Subtraction() : base("Subtraction", "") { }
     39      public override IDeepCloneable Clone(Cloner cloner) {
     40        return new Subtraction(this, cloner);
     41      }
     42    }
     43    private class Multiplication : Symbol {
     44      protected Multiplication(Multiplication original, Cloner cloner) : base(original, cloner) { }
     45      public Multiplication() : base("Multiplication", "") { }
     46      public override IDeepCloneable Clone(Cloner cloner) {
     47        return new Multiplication(this, cloner);
     48      }
     49    }
     50    private class Division : Symbol {
     51      protected Division(Division original, Cloner cloner) : base(original, cloner) { }
     52      public Division() : base("Division", "") { }
     53      public override IDeepCloneable Clone(Cloner cloner) {
     54        return new Division(this, cloner);
     55      }
     56    }
     57    private class Terminal : Symbol {
     58      protected Terminal(Terminal original, Cloner cloner) : base(original, cloner) { }
     59      public Terminal() : base("Terminal", "") { }
     60      public override IDeepCloneable Clone(Cloner cloner) {
     61        return new Terminal(this, cloner);
     62      }
     63    }
    3364
    3465    private class SimpleArithmeticGrammar : DefaultSymbolicExpressionGrammar {
     66      protected SimpleArithmeticGrammar(SimpleArithmeticGrammar original, Cloner cloner) : base(original, cloner) { }
    3567      public SimpleArithmeticGrammar()
    3668        : base() {
    3769        Initialize();
     70      }
     71
     72      public override IDeepCloneable Clone(Cloner cloner) {
     73        return new SimpleArithmeticGrammar(this, cloner);
    3874      }
    3975
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ReplaceBranchManipulationTest.cs

    r4189 r4722  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
    2625using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
     26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
    2727using HeuristicLab.Random;
    2828using Microsoft.VisualStudio.TestTools.UnitTesting;
    29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
    3029
    3130namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/Util.cs

    r4524 r4722  
    2525using System.Text;
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2728using Microsoft.VisualStudio.TestTools.UnitTesting;
    28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2929
    3030namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
Note: See TracChangeset for help on using the changeset viewer.