- Timestamp:
- 08/06/20 14:36:43 (4 years ago)
- Location:
- branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/NSGA3.cs
r17707 r17719 325 325 protected override void Run(CancellationToken cancellationToken) 326 326 { 327 while (ResultsCurrentGeneration.Value < MaximumGenerations.Value)328 { 329 try327 try 328 { 329 while (ResultsCurrentGeneration.Value < MaximumGenerations.Value) 330 330 { 331 331 // todo: make parameter out of this … … 336 336 List<Solution> rt = Utility.Concat(solutions, qt); 337 337 338 // todo: remove this check 339 for (int i = 0; i < rt.Count / 2; i++) 340 if (!solutions.Contains(rt[i])) throw new Exception($"This should never happen: !solutions.Contains(rt[{i}])"); 341 338 342 solutions = NSGA3Selection.SelectSolutionsForNextGeneration(rt, GetCopyOfReferencePoints(), Problem.Maximization, PopulationSize.Value, random); 339 343 340 344 ResultsCurrentGeneration.Value++; 341 Analyze();342 345 cancellationToken.ThrowIfCancellationRequested(); 343 346 } 344 catch (OperationCanceledException ex)345 {346 throw new OperationCanceledException("Optimization process was cancelled.", ex);347 }348 catch (Exception ex)349 {350 throw new Exception($"Failed in generation {ResultsCurrentGeneration}.", ex);351 }352 finally353 {354 Analyze();355 }347 } 348 catch (OperationCanceledException ex) 349 { 350 throw new OperationCanceledException("Optimization process was cancelled.", ex); 351 } 352 catch (Exception ex) 353 { 354 throw new Exception($"Failed in generation {ResultsCurrentGeneration}.", ex); 355 } 356 finally 357 { 358 Analyze(); 356 359 } 357 360 } -
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/ReferencePoint.cs
r17707 r17719 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using HEAL.Attic; 4 5 using HeuristicLab.Common; 5 6 using HeuristicLab.Core; … … 7 8 namespace HeuristicLab.Algorithms.NSGA3 8 9 { 10 [StorableType("5026513A-F3C7-4A85-95D6-82B5B376E900")] 9 11 public class ReferencePoint : IDeepCloneable 10 12 { … … 12 14 13 15 // The potentially associated solutions to this reference point and the distance to that solution 14 private readonly Dictionary<Solution, double> potentialAssociatedSolutions = new Dictionary<Solution, double>(); 15 16 private readonly IRandom random; 17 18 public double[] Values { get; } 16 private Dictionary<Solution, double> potentialAssociatedSolutions = new Dictionary<Solution, double>(); 17 18 [Storable] 19 private IRandom random; 20 21 [Storable] 22 public double[] Values { get; set; } 23 24 [Storable] 25 public int NumberOfAssociatedSolutions { get; set; } = 0; 26 19 27 public int Objectives => Values.Length; 20 public int NumberOfAssociatedSolutions { get; set; } = 0;21 28 22 29 #endregion Properties 23 30 24 31 #region Constructors 32 33 [StorableConstructor] 34 public ReferencePoint(StorableConstructorFlag _) 35 { 36 } 25 37 26 38 public ReferencePoint(IRandom random, int obj) -
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/Solution.cs
r17692 r17719 10 10 { 11 11 // Chromosome 12 [Storable] 12 13 public RealVector Chromosome { get; set; } 13 14 14 15 // actual fitness of solution as given by Problem 16 [Storable] 15 17 public double[] Fitness { get; set; } 16 18 17 19 // normalized fitness used in selection process (in order to not overwrite the original Fitness) 20 [Storable] 18 21 public double[] ConvertedFitness { get; set; } 22 23 [StorableConstructor] 24 public Solution(StorableConstructorFlag _) 25 { 26 } 19 27 20 28 public Solution(RealVector chromosome)
Note: See TracChangeset
for help on using the changeset viewer.