Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/ExtendedConstraint.cs @ 18181

Last change on this file since 18181 was 18181, checked in by dpiringe, 2 years ago

#3138

  • added the class ExtendedConstraint which represents an expression (the transformation of the found model) and the corresponding shape constraints
  • added a list of ExtendedConstraint in NMSESingleObjectiveConstraintsEvaluator to make future tests/experiments (exists only temporarily in NMSESingleObjectiveConstraintsEvaluator, will be moved later)
File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HEAL.Attic;
7using HeuristicLab.Common;
8using HeuristicLab.Core;
9using HeuristicLab.Data;
10using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
11using HeuristicLab.Parameters;
12
13namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
14  [StorableType("4E416693-1051-4987-A972-F869C4ACE3D4")]
15  public class ExtendedConstraint : ParameterizedNamedItem {
16    #region Constants
17    private const string ExpressionParameterName = "Expression";
18    private const string ShapeConstraintsParameterName = "Shape Constraints";
19    #endregion
20
21    public IFixedValueParameter<StringValue> ExpressionParameter =>
22      (IFixedValueParameter<StringValue>)Parameters[ExpressionParameterName];
23
24    public IFixedValueParameter<ShapeConstraints> ShapeConstraintsParameter =>
25      (IFixedValueParameter<ShapeConstraints>)Parameters[ShapeConstraintsParameterName];
26
27    public string Expression => ExpressionParameter.Value.Value;
28    public ISymbolicExpressionTree Tree => Parser.Parse(Expression);
29    public ShapeConstraints ShapeConstraints => ShapeConstraintsParameter.Value;
30
31    private InfixExpressionParser Parser => new InfixExpressionParser();
32
33    #region Constructors & Cloning
34    public ExtendedConstraint() {
35      Parameters.Add(new FixedValueParameter<StringValue>(ExpressionParameterName, new StringValue("")));
36      Parameters.Add(new FixedValueParameter<ShapeConstraints>(ShapeConstraintsParameterName, new ShapeConstraints()));
37    }
38
39    protected ExtendedConstraint(ExtendedConstraint original, Cloner cloner) : base(original, cloner) {
40    }
41
42    [StorableConstructor]
43    protected ExtendedConstraint(StorableConstructorFlag _) : base(_) { }
44
45    public override IDeepCloneable Clone(Cloner cloner) =>
46      new ExtendedConstraint(this, cloner);
47    #endregion
48  }
49}
Note: See TracBrowser for help on using the repository browser.