1 | #region License Information
|
---|
2 |
|
---|
3 | /* HeuristicLab
|
---|
4 | * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
5 | *
|
---|
6 | * This file is part of HeuristicLab.
|
---|
7 | *
|
---|
8 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
9 | * it under the terms of the GNU General Public License as published by
|
---|
10 | * the Free Software Foundation, either version 3 of the License, or
|
---|
11 | * (at your option) any later version.
|
---|
12 | *
|
---|
13 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | * GNU General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU General Public License
|
---|
19 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #endregion
|
---|
23 |
|
---|
24 | using System.Linq;
|
---|
25 | using HEAL.Attic;
|
---|
26 | using HeuristicLab.Analysis;
|
---|
27 | using HeuristicLab.Common;
|
---|
28 | using HeuristicLab.Core;
|
---|
29 | using HeuristicLab.Optimization;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
|
---|
32 | [StorableType("f4819c68-b6fc-469f-bcb5-cb5b2a9d8aff")]
|
---|
33 | public abstract class SymbolicExpressionTreeMultiObjectiveProblem : MultiObjectiveProblem<SymbolicExpressionTreeEncoding, ISymbolicExpressionTree> {
|
---|
34 |
|
---|
35 | // persistence
|
---|
36 | [StorableConstructor]
|
---|
37 | protected SymbolicExpressionTreeMultiObjectiveProblem(StorableConstructorFlag _) : base(_) { }
|
---|
38 | [StorableHook(HookType.AfterDeserialization)]
|
---|
39 | private void AfterDeserialization() { }
|
---|
40 |
|
---|
41 |
|
---|
42 | // cloning
|
---|
43 | protected SymbolicExpressionTreeMultiObjectiveProblem(SymbolicExpressionTreeMultiObjectiveProblem original, Cloner cloner)
|
---|
44 | : base(original, cloner) {
|
---|
45 | }
|
---|
46 |
|
---|
47 | protected SymbolicExpressionTreeMultiObjectiveProblem(SymbolicExpressionTreeEncoding encoding)
|
---|
48 | : base(encoding) {
|
---|
49 | EncodingParameter.ReadOnly = true;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public override void Analyze(ISymbolicExpressionTree[] trees, double[][] qualities, ResultCollection results,
|
---|
53 | IRandom random) {
|
---|
54 | base.Analyze(trees, qualities, results, random);
|
---|
55 |
|
---|
56 | var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(trees, qualities, Maximization);
|
---|
57 | var plot = new ParetoFrontScatterPlot<ISymbolicExpressionTree>(fronts, trees, qualities, Objectives, BestKnownFront);
|
---|
58 | results.AddOrUpdateResult("Pareto Front Scatter Plot", plot);
|
---|
59 | }
|
---|
60 |
|
---|
61 | protected override void OnEncodingChanged() {
|
---|
62 | base.OnEncodingChanged();
|
---|
63 | Parameterize();
|
---|
64 | }
|
---|
65 |
|
---|
66 | private void Parameterize() {
|
---|
67 | foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
|
---|
68 | similarityCalculator.SolutionVariableName = Encoding.Name;
|
---|
69 | similarityCalculator.QualityVariableName = Evaluator.QualitiesParameter.ActualName;
|
---|
70 | }
|
---|
71 | }
|
---|
72 | }
|
---|
73 | }
|
---|