Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeMultiObjectiveProblem.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: 2.6 KB
Line 
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
24using System.Linq;
25using HEAL.Attic;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Optimization;
29
30namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
31  [StorableType("f4819c68-b6fc-469f-bcb5-cb5b2a9d8aff")]
32  public abstract class SymbolicExpressionTreeMultiObjectiveProblem : MultiObjectiveProblem<SymbolicExpressionTreeEncoding, ISymbolicExpressionTree> {
33
34    // persistence
35    [StorableConstructor]
36    protected SymbolicExpressionTreeMultiObjectiveProblem(StorableConstructorFlag _) : base(_) { }
37    [StorableHook(HookType.AfterDeserialization)]
38    private void AfterDeserialization() { }
39
40
41    // cloning
42    protected SymbolicExpressionTreeMultiObjectiveProblem(SymbolicExpressionTreeMultiObjectiveProblem original, Cloner cloner)
43      : base(original, cloner) {
44    }
45
46    protected SymbolicExpressionTreeMultiObjectiveProblem(SymbolicExpressionTreeEncoding encoding)
47      : base(encoding) {
48      EncodingParameter.ReadOnly = true;
49    }
50
51    public override void Analyze(ISymbolicExpressionTree[] trees, double[][] qualities, ResultCollection results,
52      IRandom random) {
53      base.Analyze(trees, qualities, results, random);
54      var front = DominationCalculator.CalculateBestParetoFront(trees, qualities, Maximization);
55
56      // TODO: Calculate Pareto front and add to results
57    }
58
59    protected override void OnEncodingChanged() {
60      base.OnEncodingChanged();
61      Parameterize();
62    }
63
64    private void Parameterize() {
65      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
66        similarityCalculator.SolutionVariableName = Encoding.Name;
67        similarityCalculator.QualityVariableName = Evaluator.QualitiesParameter.ActualName;
68      }
69    }
70  }
71}
Note: See TracBrowser for help on using the repository browser.