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:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs

    r4477 r4722  
    192192    [StorableConstructor]
    193193    private GeneticAlgorithm(bool deserializing) : base(deserializing) { }
    194 
     194    [StorableHook(HookType.AfterDeserialization)]
     195    private void AfterDeserialization() {
     196      Initialize();
     197    }
     198
     199    private GeneticAlgorithm(GeneticAlgorithm original, Cloner cloner)
     200      : base(original, cloner) {
     201      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
     202      Initialize();
     203    }
    195204    public override IDeepCloneable Clone(Cloner cloner) {
    196       GeneticAlgorithm clone = (GeneticAlgorithm)base.Clone(cloner);
    197       clone.qualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(qualityAnalyzer);
    198       clone.Initialize();
    199       return clone;
     205      return new GeneticAlgorithm(this, cloner);
    200206    }
    201207
     
    265271
    266272    #region Helpers
    267     [StorableHook(HookType.AfterDeserialization)]
    268273    private void Initialize() {
    269274      PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithmMainLoop.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    8283
    8384    [StorableConstructor]
    84     private GeneticAlgorithmMainLoop(bool deserializing) : base() { }
     85    private GeneticAlgorithmMainLoop(bool deserializing) : base(deserializing) { }
     86    private GeneticAlgorithmMainLoop(GeneticAlgorithmMainLoop original, Cloner cloner)
     87      : base(original, cloner) {
     88    }
     89    public override IDeepCloneable Clone(Cloner cloner) {
     90      return new GeneticAlgorithmMainLoop(this, cloner);
     91    }
    8592    public GeneticAlgorithmMainLoop()
    8693      : base() {
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs

    r4437 r4722  
    197197    [StorableConstructor]
    198198    private IslandGeneticAlgorithm(bool deserializing) : base(deserializing) { }
     199    [StorableHook(HookType.AfterDeserialization)]
     200    private void AfterDeserialization() {
     201      Initialize();
     202    }
     203    private IslandGeneticAlgorithm(IslandGeneticAlgorithm original, Cloner cloner)
     204      : base(original, cloner) {
     205      islandQualityAnalyzer = cloner.Clone(original.islandQualityAnalyzer);
     206      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
     207      Initialize();
     208    }
     209    public override IDeepCloneable Clone(Cloner cloner) {
     210      return new IslandGeneticAlgorithm(this, cloner);
     211    }
     212
    199213    public IslandGeneticAlgorithm()
    200214      : base() {
     
    282296    }
    283297
    284     public override IDeepCloneable Clone(Cloner cloner) {
    285       IslandGeneticAlgorithm clone = (IslandGeneticAlgorithm)base.Clone(cloner);
    286       clone.islandQualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(islandQualityAnalyzer);
    287       clone.qualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(qualityAnalyzer);
    288       clone.Initialize();
    289       return clone;
    290     }
    291 
    292298    public override void Prepare() {
    293299      if (Problem != null) base.Prepare();
     
    362368
    363369    #region Helpers
    364     [StorableHook(HookType.AfterDeserialization)]
    365370    private void Initialize() {
    366371      PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs

    r4068 r4722  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Data;
     
    103104
    104105    [StorableConstructor]
    105     private IslandGeneticAlgorithmMainLoop(bool deserializing) : base() { }
     106    private IslandGeneticAlgorithmMainLoop(bool deserializing) : base(deserializing) { }
     107    private IslandGeneticAlgorithmMainLoop(IslandGeneticAlgorithmMainLoop original, Cloner cloner)
     108      : base(original, cloner) {
     109    }
     110    public override IDeepCloneable Clone(Cloner cloner) {
     111      return new IslandGeneticAlgorithmMainLoop(this, cloner);
     112    }
    106113    public IslandGeneticAlgorithmMainLoop()
    107114      : base() {
Note: See TracChangeset for help on using the changeset viewer.