using System; using HEAL.Attic; using HeuristicLab.Common; using HeuristicLab.Encodings.RealVectorEncoding; namespace HeuristicLab.Algorithms.NSGA3 { [StorableType("D35C9D79-77DF-4CF3-AB44-FCCC00E44C5F")] public class Solution : IDeepCloneable { // Chromosome public RealVector Chromosome { get; set; } // actual fitness of solution as given by Problem public double[] Fitness { get; set; } // normalized fitness used in selection process (in order to not overwrite the original Fitness) public double[] ConvertedFitness { get; set; } public Solution(RealVector chromosome) { Chromosome = chromosome; } public Solution(Solution solution, Cloner cloner) { Chromosome = cloner.Clone(solution.Chromosome); if (solution.Fitness != null) { Fitness = new double[solution.Fitness.Length]; Array.Copy(solution.Fitness, Fitness, solution.Fitness.Length); } if (solution.ConvertedFitness != null) { ConvertedFitness = new double[solution.ConvertedFitness.Length]; Array.Copy(solution.ConvertedFitness, ConvertedFitness, solution.ConvertedFitness.Length); } } public IDeepCloneable Clone(Cloner cloner) { return new Solution(this, cloner); } public object Clone() { return new Cloner().Clone(this); } } }