Changeset 17700
- Timestamp:
- 07/27/20 14:38:37 (4 years ago)
- Location:
- branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/NSGA3.cs
r17693 r17700 210 210 public NSGA3(NSGA3 original, Cloner cloner) : base(original, cloner) 211 211 { 212 // todo: don't forget to clone storable fields213 212 random = cloner.Clone(original.random); 214 213 solutions = original.solutions?.Select(cloner.Clone).ToList(); 215 referencePoints = original.referencePoints?.Select(r => 216 { 217 var refPoint = new ReferencePoint(random, r.NumberOfDimensions); 218 r.Values.CopyTo(refPoint.Values, 0); 219 return refPoint; 220 }).ToList(); 214 referencePoints = original.referencePoints?.Select(cloner.Clone).ToList(); 221 215 } 222 216 … … 344 338 if (referencePoints == null) return null; 345 339 346 List<ReferencePoint> referencePointsCopy = new List<ReferencePoint>(); 347 foreach (var referencePoint in referencePoints) 348 referencePointsCopy.Add(new ReferencePoint(referencePoint)); 349 350 return referencePointsCopy; 340 return referencePoints.Select(rp => (ReferencePoint)rp.Clone()).ToList(); 351 341 } 352 342 -
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/ReferencePoint.cs
r17693 r17700 28 28 this.random = random; 29 29 Values = new double[numberOfDimensions]; 30 }31 32 public ReferencePoint(ReferencePoint other)33 {34 random = other.random;35 Values = new double[other.NumberOfDimensions];36 other.Values.CopyTo(Values, 0);37 30 } 38 31 … … 216 209 { 217 210 refPoint.Values[element] = ((double)left) / total; 218 var newRefPoint = new ReferencePoint(refPoint);211 var newRefPoint = (ReferencePoint)refPoint.Clone(); 219 212 referencePoints.Add(newRefPoint); 220 213 }
Note: See TracChangeset
for help on using the changeset viewer.