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[] Objectives { get; set; }
|
---|
18 |
|
---|
19 | // normalized fitness used in selection process (in order to not overwrite the original Fitness)
|
---|
20 | [Storable]
|
---|
21 | public double[] NormalizedObjectives { get; set; }
|
---|
22 |
|
---|
23 | [StorableConstructor]
|
---|
24 | public Solution(StorableConstructorFlag _) { }
|
---|
25 |
|
---|
26 | public Solution(RealVector chromosome)
|
---|
27 | {
|
---|
28 | Chromosome = chromosome;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public Solution(Solution solution, Cloner cloner)
|
---|
32 | {
|
---|
33 | Chromosome = cloner.Clone(solution.Chromosome);
|
---|
34 | if (solution.Objectives != null)
|
---|
35 | {
|
---|
36 | Objectives = new double[solution.Objectives.Length];
|
---|
37 | Array.Copy(solution.Objectives, Objectives, solution.Objectives.Length);
|
---|
38 | }
|
---|
39 | if (solution.NormalizedObjectives != null)
|
---|
40 | {
|
---|
41 | NormalizedObjectives = new double[solution.NormalizedObjectives.Length];
|
---|
42 | Array.Copy(solution.NormalizedObjectives, NormalizedObjectives, solution.NormalizedObjectives.Length);
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | public IDeepCloneable Clone(Cloner cloner)
|
---|
47 | {
|
---|
48 | return new Solution(this, cloner);
|
---|
49 | }
|
---|
50 |
|
---|
51 | public object Clone()
|
---|
52 | {
|
---|
53 | return new Cloner().Clone(this);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.