1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 | using HEAL.Attic;
|
---|
7 | using HeuristicLab.Common;
|
---|
8 | using HeuristicLab.Core;
|
---|
9 | using HeuristicLab.Data;
|
---|
10 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
11 | using HeuristicLab.Parameters;
|
---|
12 |
|
---|
13 | namespace 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 | }
|
---|