Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/01/17 11:07:48 (7 years ago)
Author:
mkommend
Message:

#2815: Corrected cloning and serializing of P3 and associated classes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/Population.cs

    r14185 r15301  
    2222
    2323using System.Collections.Generic;
     24using System.Linq;
     25using HeuristicLab.Common;
    2426using HeuristicLab.Core;
    2527using HeuristicLab.Encodings.BinaryVectorEncoding;
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2629
    2730namespace HeuristicLab.Algorithms.ParameterlessPopulationPyramid {
     
    2932  // B. W. Goldman and W. F. Punch, "Parameter-less Population Pyramid," GECCO, pp. 785–792, 2014
    3033  // and the original source code in C++11 available from: https://github.com/brianwgoldman/Parameter-less_Population_Pyramid
    31   public class Population {
     34  [StorableClass]
     35  public class Population : DeepCloneable {
     36    [Storable]
    3237    public List<BinaryVector> Solutions {
    3338      get;
    3439      private set;
    3540    }
    36 
     41    [Storable]
    3742    public LinkageTree Tree {
    3843      get;
    3944      private set;
     45    }
     46
     47
     48    [StorableConstructor]
     49    protected Population(bool deserializing) : base() { }
     50
     51
     52    protected Population(Population original, Cloner cloner) : base(original, cloner) {
     53      Solutions = original.Solutions.Select(cloner.Clone).ToList();
     54      Tree = cloner.Clone(original.Tree);
     55    }
     56
     57    public override IDeepCloneable Clone(Cloner cloner) {
     58      return new Population(this, cloner);
    4059    }
    4160
Note: See TracChangeset for help on using the changeset viewer.