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/ParameterlessPopulationPyramid.cs

    r14527 r15301  
    2323using System;
    2424using System.Collections.Generic;
     25using System.Linq;
    2526using System.Threading;
    2627using HeuristicLab.Analysis;
     
    5152    }
    5253
     54    [Storable]
    5355    private readonly IRandom random = new MersenneTwister();
    54     private List<Population> pyramid;
     56    [Storable]
     57    private List<Population> pyramid = new List<Population>();
     58    [Storable]
    5559    private EvaluationTracker tracker;
    5660
    5761    // Tracks all solutions in Pyramid for quick membership checks
    58     private readonly HashSet<BinaryVector> seen = new HashSet<BinaryVector>(new EnumerableBoolEqualityComparer());
     62
     63    private HashSet<BinaryVector> seen = new HashSet<BinaryVector>(new EnumerableBoolEqualityComparer());
     64    [Storable]
     65    private IEnumerable<BinaryVector> StorableSeen {
     66      get { return seen; }
     67      set { seen = new HashSet<BinaryVector>(value, new EnumerableBoolEqualityComparer()); }
     68    }
    5969
    6070    #region ParameterNames
     
    160170    protected ParameterlessPopulationPyramid(ParameterlessPopulationPyramid original, Cloner cloner)
    161171      : base(original, cloner) {
     172      random = cloner.Clone(original.random);
     173      pyramid = original.pyramid.Select(cloner.Clone).ToList();
     174      tracker = cloner.Clone(original.tracker);
     175      seen = new HashSet<BinaryVector>(original.seen.Select(cloner.Clone), new EnumerableBoolEqualityComparer());
    162176    }
    163177
     
    166180    }
    167181
    168     public ParameterlessPopulationPyramid() {
     182    public ParameterlessPopulationPyramid() : base() {
    169183      Parameters.Add(new FixedValueParameter<IntValue>(MaximumIterationsParameterName, "", new IntValue(Int32.MaxValue)));
    170184      Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluationsParameterName, "", new IntValue(Int32.MaxValue)));
     
    256270          ResultsIterations++;
    257271          cancellationToken.ThrowIfCancellationRequested();
    258         } finally {
     272        }
     273        finally {
    259274          ResultsEvaluations = tracker.Evaluations;
    260275          ResultsBestSolution = new BinaryVector(tracker.BestSolution);
Note: See TracChangeset for help on using the changeset viewer.