Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs @ 18146

Last change on this file since 18146 was 18146, checked in by mkommend, 2 years ago

#3136: Merged trunk changes into branch.

File size: 3.1 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 HEAL.Attic;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25
26namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
27  [Item("Shape-constrained symbolic regression problem (single-objective)", "Represents a single-objective shape-constrained regression problem.")]
28  [StorableType("B35ADCA7-E902-4BEE-9DDE-DF8BBC1E27FE")]
29  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 150)]
30  public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem, IShapeConstrainedRegressionProblem {
31    [StorableConstructor]
32    protected ShapeConstrainedRegressionSingleObjectiveProblem(StorableConstructorFlag _) : base(_) { }
33    protected ShapeConstrainedRegressionSingleObjectiveProblem(ShapeConstrainedRegressionSingleObjectiveProblem original, Cloner cloner) : base(original, cloner) { }
34    public override IDeepCloneable Clone(Cloner cloner) { return new ShapeConstrainedRegressionSingleObjectiveProblem(this, cloner); }
35
36    public ShapeConstrainedRegressionProblemData ShapeConstrainedRegressionProblemData {
37      get => (ShapeConstrainedRegressionProblemData)ProblemData;
38      set => ProblemData = value;
39    }
40    public ShapeConstrainedRegressionSingleObjectiveProblem()
41      : base(new ShapeConstrainedRegressionProblemData(), new NMSESingleObjectiveConstraintsEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
42
43      ApplyLinearScalingParameter.Value.Value = true;
44      Maximization.Value = false;
45      SymbolicExpressionTreeGrammarParameter.Value = new LinearScalingGrammar();
46
47      InitializeOperators();
48    }
49
50
51    private void InitializeOperators() {
52      Operators.Add(new ShapeConstraintsAnalyzer());
53      ParameterizeOperators();
54    }
55
56    public override void Load(IRegressionProblemData data) {
57      var scProblemData = data as ShapeConstrainedRegressionProblemData;
58      if (scProblemData == null) {
59        scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
60                                                                  data.TrainingPartition, data.TestPartition) {
61          Name = data.Name,
62          Description = data.Description
63        };
64      }
65
66      base.Load(scProblemData);
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.