Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/Solution.cs @ 17703

Last change on this file since 17703 was 17692, checked in by dleko, 4 years ago

#2825 Bugfix: NSGA3 now works as intended.

File size: 1.6 KB
Line 
1using System;
2using HEAL.Attic;
3using HeuristicLab.Common;
4using HeuristicLab.Encodings.RealVectorEncoding;
5
6namespace HeuristicLab.Algorithms.NSGA3
7{
8    [StorableType("D35C9D79-77DF-4CF3-AB44-FCCC00E44C5F")]
9    public class Solution : IDeepCloneable
10    {
11        // Chromosome
12        public RealVector Chromosome { get; set; }
13
14        // actual fitness of solution as given by Problem
15        public double[] Fitness { get; set; }
16
17        // normalized fitness used in selection process (in order to not overwrite the original Fitness)
18        public double[] ConvertedFitness { get; set; }
19
20        public Solution(RealVector chromosome)
21        {
22            Chromosome = chromosome;
23        }
24
25        public Solution(Solution solution, Cloner cloner)
26        {
27            Chromosome = cloner.Clone(solution.Chromosome);
28            if (solution.Fitness != null)
29            {
30                Fitness = new double[solution.Fitness.Length];
31                Array.Copy(solution.Fitness, Fitness, solution.Fitness.Length);
32            }
33            if (solution.ConvertedFitness != null)
34            {
35                ConvertedFitness = new double[solution.ConvertedFitness.Length];
36                Array.Copy(solution.ConvertedFitness, ConvertedFitness, solution.ConvertedFitness.Length);
37            }
38        }
39
40        public IDeepCloneable Clone(Cloner cloner)
41        {
42            return new Solution(this, cloner);
43        }
44
45        public object Clone()
46        {
47            return new Cloner().Clone(this);
48        }
49    }
50}
Note: See TracBrowser for help on using the repository browser.