Changeset 15301 for trunk/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs
- Timestamp:
- 08/01/17 11:07:48 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs
r14527 r15301 23 23 using System; 24 24 using System.Collections.Generic; 25 using System.Linq; 25 26 using System.Threading; 26 27 using HeuristicLab.Analysis; … … 51 52 } 52 53 54 [Storable] 53 55 private readonly IRandom random = new MersenneTwister(); 54 private List<Population> pyramid; 56 [Storable] 57 private List<Population> pyramid = new List<Population>(); 58 [Storable] 55 59 private EvaluationTracker tracker; 56 60 57 61 // 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 } 59 69 60 70 #region ParameterNames … … 160 170 protected ParameterlessPopulationPyramid(ParameterlessPopulationPyramid original, Cloner cloner) 161 171 : 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()); 162 176 } 163 177 … … 166 180 } 167 181 168 public ParameterlessPopulationPyramid() {182 public ParameterlessPopulationPyramid() : base() { 169 183 Parameters.Add(new FixedValueParameter<IntValue>(MaximumIterationsParameterName, "", new IntValue(Int32.MaxValue))); 170 184 Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluationsParameterName, "", new IntValue(Int32.MaxValue))); … … 256 270 ResultsIterations++; 257 271 cancellationToken.ThrowIfCancellationRequested(); 258 } finally { 272 } 273 finally { 259 274 ResultsEvaluations = tracker.Evaluations; 260 275 ResultsBestSolution = new BinaryVector(tracker.BestSolution);
Note: See TracChangeset
for help on using the changeset viewer.