Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ParsedConstraint.cs @ 16824

Last change on this file since 16824 was 16800, checked in by chaider, 6 years ago

#2971 Several chanages regarding review comments

File size: 2.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HEAL.Attic;
6
7namespace HeuristicLab.Problems.DataAnalysis {
8  [StorableType("A56BFB05-8F11-4766-9FBF-20C7010F1CA3")]
9  [Item("ParsedConstraint", "Represents parsed constraints.")]
10  public class ParsedConstraint : Item {
11    private static readonly string exampleInput = "#Example for a target variable constraint:" + Environment.NewLine +
12                                                  "Target:y in [0 .. 100]" + Environment.NewLine + Environment.NewLine +
13                                                  "#Example for constraint on model parameter: " + Environment.NewLine +
14                                                  "dy/dx in [0 .. 10]" + Environment.NewLine +
15                                                  "\u2202²y/\u2202x² in ]-1 .. inf.[";
16     
17    public string Input { get; set; }
18
19    private IEnumerable<IntervalConstraint> constraints;
20    public IEnumerable<IntervalConstraint> Constraints {
21      get => constraints;
22      set {
23        constraints = value;
24        OnChanged(EventArgs.Empty);
25      }
26  }
27    public IRegressionProblemData ProblemData { get; set; }
28
29    [StorableConstructor]
30    protected ParsedConstraint(StorableConstructorFlag _) : base(_) { }
31
32    protected ParsedConstraint(ParsedConstraint original, Cloner cloner)
33      : base(original, cloner) {
34      this.Input = original.Input;
35      this.constraints = original.Constraints;
36      this.ProblemData = original.ProblemData;
37    }
38
39    public override IDeepCloneable Clone(Cloner cloner) {
40      return new ParsedConstraint(this, cloner);
41    }
42
43    public ParsedConstraint() {
44      this.Input = exampleInput;
45      this.constraints = new CheckedItemList<IntervalConstraint>();
46      this.ProblemData = null;
47    }
48
49    public ParsedConstraint(IRegressionProblemData problemData) {
50      this.Input = exampleInput;
51      this.constraints = new List<IntervalConstraint>();
52      this.ProblemData = problemData;
53    }
54
55    public ParsedConstraint(string input, IRegressionProblemData problemData) {
56      this.Input = input;
57      this.constraints = new CheckedItemList<IntervalConstraint>();
58      this.ProblemData = problemData;
59    }
60
61    public ParsedConstraint(string input, IEnumerable<IntervalConstraint> constraints) {
62      this.Input = input;
63      this.constraints = constraints;
64    }
65
66    public event EventHandler Changed;
67    protected virtual void OnChanged(EventArgs e) {
68      EventHandler handlers = Changed;
69      if (handlers != null)
70        handlers(this, e);
71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.