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