Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolution.cs @ 18091

Last change on this file since 18091 was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 3.6 KB
RevLine 
[5624]1#region License Information
2/* HeuristicLab
[17180]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[5624]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
[11332]22using System.Linq;
[5624]23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
[11332]26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
[6411]27using HeuristicLab.Optimization;
[16565]28using HEAL.Attic;
[5624]29
30namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
31  /// <summary>
32  /// Represents a symbolic classification solution (model + data) and attributes of the solution like accuracy and complexity
33  /// </summary>
[16565]34  [StorableType("C2829CEB-8D34-4FAB-B9AE-23937071B53F")]
[5624]35  [Item(Name = "SymbolicClassificationSolution", Description = "Represents a symbolic classification solution (model + data) and attributes of the solution like accuracy and complexity.")]
[5717]36  public sealed class SymbolicClassificationSolution : ClassificationSolution, ISymbolicClassificationSolution {
[5736]37    private const string ModelLengthResultName = "ModelLength";
38    private const string ModelDepthResultName = "ModelDepth";
[5624]39
40    public new ISymbolicClassificationModel Model {
41      get { return (ISymbolicClassificationModel)base.Model; }
[5717]42      set { base.Model = value; }
[5624]43    }
44
45    ISymbolicDataAnalysisModel ISymbolicDataAnalysisSolution.Model {
46      get { return (ISymbolicDataAnalysisModel)base.Model; }
47    }
[5736]48    public int ModelLength {
49      get { return ((IntValue)this[ModelLengthResultName].Value).Value; }
50      private set { ((IntValue)this[ModelLengthResultName].Value).Value = value; }
51    }
[5624]52
[5736]53    public int ModelDepth {
54      get { return ((IntValue)this[ModelDepthResultName].Value).Value; }
55      private set { ((IntValue)this[ModelDepthResultName].Value).Value = value; }
56    }
57
[5624]58    [StorableConstructor]
[16565]59    private SymbolicClassificationSolution(StorableConstructorFlag _) : base(_) { }
[5717]60    private SymbolicClassificationSolution(SymbolicClassificationSolution original, Cloner cloner)
[5624]61      : base(original, cloner) {
62    }
63    public SymbolicClassificationSolution(ISymbolicClassificationModel model, IClassificationProblemData problemData)
64      : base(model, problemData) {
[11332]65      foreach (var node in model.SymbolicExpressionTree.Root.IterateNodesPrefix().OfType<SymbolicExpressionTreeTopLevelNode>())
66        node.SetGrammar(null);
67
[5736]68      Add(new Result(ModelLengthResultName, "Length of the symbolic classification model.", new IntValue()));
69      Add(new Result(ModelDepthResultName, "Depth of the symbolic classification model.", new IntValue()));
[6589]70      RecalculateResults();
[5624]71    }
72
73    public override IDeepCloneable Clone(Cloner cloner) {
74      return new SymbolicClassificationSolution(this, cloner);
75    }
[5736]76
[6411]77    protected override void RecalculateResults() {
[8723]78      base.RecalculateResults();
[5736]79      ModelLength = Model.SymbolicExpressionTree.Length;
80      ModelDepth = Model.SymbolicExpressionTree.Depth;
81    }
[5624]82  }
83}
Note: See TracBrowser for help on using the repository browser.