1 | using System;
|
---|
2 | using System.ComponentModel;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Runtime.CompilerServices;
|
---|
5 | using HeuristicLab.Common;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Problems.DataAnalysis.Annotations;
|
---|
8 | using HEAL.Attic;
|
---|
9 |
|
---|
10 | namespace HeuristicLab.Problems.DataAnalysis {
|
---|
11 | [StorableType("8109BE58-CCFB-4462-A2F4-EEE5DFADAFF7")]
|
---|
12 | [Item("Interval Constraint", "Constraint on intervals.")]
|
---|
13 | public class IntervalConstraint : NamedItem {
|
---|
14 | private string expression;
|
---|
15 | public string Expression {
|
---|
16 | get => expression;
|
---|
17 | set {
|
---|
18 | if (value != expression) {
|
---|
19 | expression = value;
|
---|
20 | }
|
---|
21 | }
|
---|
22 | }
|
---|
23 | public string Definition { get; set; }
|
---|
24 | public Interval Interval { get; set; }
|
---|
25 | private bool inclusiveLowerBound;
|
---|
26 |
|
---|
27 | public bool InclusiveLowerBound {
|
---|
28 | get => inclusiveLowerBound;
|
---|
29 | set {
|
---|
30 | if (value != inclusiveLowerBound) {
|
---|
31 | inclusiveLowerBound = value;
|
---|
32 | OnChanged(EventArgs.Empty);
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
36 | public bool InclusiveUpperBound { get; set; }
|
---|
37 | public bool IsDerivation { get; set; }
|
---|
38 |
|
---|
39 | private string variable;
|
---|
40 | public string Variable {
|
---|
41 | get => variable;
|
---|
42 | set {
|
---|
43 | if (value != variable) {
|
---|
44 | variable = value;
|
---|
45 | OnChanged(EventArgs.Empty);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 | public int NumberOfDerivation { get; set; }
|
---|
50 |
|
---|
51 | public IntervalConstraint() {}
|
---|
52 |
|
---|
53 | public IntervalConstraint(string name) {
|
---|
54 | base.name = name;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public IntervalConstraint(string expression, string definition, Interval interval, bool inclusiveLowerBound,
|
---|
58 | bool inclusiveUpperBound, bool isDerivation, string variable, int numberOfDerivation) {
|
---|
59 | base.name = expression;
|
---|
60 | Expression = expression;
|
---|
61 | Definition = definition;
|
---|
62 | Interval = interval;
|
---|
63 | InclusiveLowerBound = inclusiveLowerBound;
|
---|
64 | InclusiveUpperBound = inclusiveUpperBound;
|
---|
65 | IsDerivation = isDerivation;
|
---|
66 | Variable = variable;
|
---|
67 | NumberOfDerivation = numberOfDerivation;
|
---|
68 | }
|
---|
69 |
|
---|
70 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
71 | return new IntervalConstraint(this, cloner);
|
---|
72 | }
|
---|
73 |
|
---|
74 | protected IntervalConstraint(IntervalConstraint original, Cloner cloner)
|
---|
75 | : base(original, cloner) {
|
---|
76 | this.Expression = original.Expression;
|
---|
77 | this.Definition = original.Definition;
|
---|
78 | this.Interval = original.Interval;
|
---|
79 | this.InclusiveLowerBound = original.InclusiveLowerBound;
|
---|
80 | this.InclusiveUpperBound = original.InclusiveUpperBound;
|
---|
81 | this.IsDerivation = original.IsDerivation;
|
---|
82 | this.Variable = original.Variable;
|
---|
83 | this.NumberOfDerivation = original.NumberOfDerivation;
|
---|
84 | }
|
---|
85 |
|
---|
86 | public event EventHandler Changed;
|
---|
87 | protected virtual void OnChanged(EventArgs e) {
|
---|
88 | EventHandler handlers = Changed;
|
---|
89 | if (handlers != null)
|
---|
90 | handlers(this, e);
|
---|
91 | }
|
---|
92 | }
|
---|
93 | }
|
---|