Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Analysis/3.3/MultiObjective/ParetoFrontScatterPlot.cs @ 17229

Last change on this file since 17229 was 17229, checked in by abeham, 5 years ago

#2521: Refactored ParetoFrontScatterPlot (moved from TestFunctions.MultiObjective to Analysis)

  • Introduced generic type that may work with all solution encodings
File size: 5.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Drawing;
25using System.Linq;
26using HEAL.Attic;
27using HeuristicLab.Common;
28using HeuristicLab.Core;
29
30namespace HeuristicLab.Analysis {
31  [StorableType("1bc5f640-ed3a-49dd-9dca-aa034cc81e12")]
32  [Item("Pareto Front Scatter Plot", "The optimal front, current front(s) and associated items.")]
33  public class ParetoFrontScatterPlot<T> : Item where T: class, IItem {
34
35    public static new Image StaticItemImage {
36      get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }
37    }
38
39    [Storable]
40    private int objectives;
41    public int Objectives {
42      get { return objectives; }
43    }
44
45    [Storable]
46    private IList<double[][]> fronts;
47    public IList<double[][]> Fronts {
48      get { return fronts; }
49    }
50
51    [Storable]
52    private IList<T[]> items;
53    public IList<T[]> Items {
54      get { return items; }
55    }
56
57    [Storable]
58    private IList<double[]> bestKnownFront;
59    public IList<double[]> BestKnownFront {
60      get { return bestKnownFront; }
61    }
62
63    [StorableConstructor]
64    protected ParetoFrontScatterPlot(StorableConstructorFlag _) : base(_) { }
65    public ParetoFrontScatterPlot() { }
66    public ParetoFrontScatterPlot(IList<double[][]> qualities, IList<T[]> items, IList<double[]> paretoFront, int objectives) {
67      this.fronts = qualities;
68      this.items = items;
69      this.bestKnownFront = paretoFront;
70      this.objectives = objectives;
71    }
72    protected ParetoFrontScatterPlot(ParetoFrontScatterPlot<T> original, Cloner cloner)
73      : base(original, cloner) {
74      if (original.fronts != null) fronts = original.fronts.Select(s => s.Select(x => x.ToArray()).ToArray()).ToArray();
75      if (original.items != null) items = original.items.Select(s => s.Select(cloner.Clone).ToArray()).ToArray();
76      if (original.bestKnownFront != null) bestKnownFront = original.bestKnownFront.Select(s => s.ToArray()).ToArray();
77      objectives = original.objectives;
78    }
79    public override IDeepCloneable Clone(Cloner cloner) {
80      return new ParetoFrontScatterPlot<T>(this, cloner);
81    }
82  }
83
84  [StorableType("3BF7AD0E-8D55-4033-974A-01DB16F9E41A")]
85  [Item("Pareto Front Scatter Plot", "The optimal front, current front and its associated Points in the searchspace")]
86  [Obsolete("Use the generic ParetoFrontScatterPlot<T> instead.")]
87  public class ParetoFrontScatterPlot : Item {
88    public static new Image StaticItemImage {
89      get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }
90    }
91
92    [Storable]
93    private int objectives;
94    public int Objectives {
95      get { return objectives; }
96    }
97
98    [Storable]
99    private int problemSize;
100    public int ProblemSize {
101      get { return problemSize; }
102    }
103
104    [Storable]
105    private double[][] qualities;
106    public double[][] Qualities {
107      get { return qualities; }
108    }
109
110    [Storable]
111    private double[][] solutions;
112    public double[][] Solutions {
113      get { return solutions; }
114    }
115
116    [Storable]
117    private double[][] paretoFront;
118    public double[][] ParetoFront {
119      get { return paretoFront; }
120    }
121
122    #region Constructor, Cloning & Persistance
123    public ParetoFrontScatterPlot(double[][] qualities, double[][] solutions, double[][] paretoFront, int objectives, int problemSize) {
124      this.qualities = qualities;
125      this.solutions = solutions;
126      this.paretoFront = paretoFront;
127      this.objectives = objectives;
128      this.problemSize = problemSize;
129    }
130    public ParetoFrontScatterPlot() { }
131
132    protected ParetoFrontScatterPlot(ParetoFrontScatterPlot original, Cloner cloner)
133      : base(original, cloner) {
134      if (original.qualities != null) qualities = original.qualities.Select(s => s.ToArray()).ToArray();
135      if (original.solutions != null) solutions = original.solutions.Select(s => s.ToArray()).ToArray();
136      if (original.paretoFront != null) paretoFront = original.paretoFront.Select(s => s.ToArray()).ToArray();
137      objectives = original.objectives;
138      problemSize = original.problemSize;
139    }
140    public override IDeepCloneable Clone(Cloner cloner) {
141      return new ParetoFrontScatterPlot(this, cloner);
142    }
143
144    [StorableConstructor]
145    protected ParetoFrontScatterPlot(StorableConstructorFlag _) : base(_) { }
146    #endregion
147  }
148}
Note: See TracBrowser for help on using the repository browser.