Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableCondition.cs @ 5060

Last change on this file since 5060 was 5060, checked in by mkommend, 14 years ago

Implemented VariableCondition symbol (ticket #1325).

File size: 6.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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 System;
23using System.Collections.Generic;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
31  [StorableClass]
32  [Item("Variable Condition", "Represents a condition that tests a given variable.")]
33  public sealed class VariableCondition : Symbol {
34    #region properties
35    [Storable]
36    private double thresholdInitializerMu;
37    public double ThresholdInitializerMu {
38      get { return thresholdInitializerMu; }
39      set {
40        if (value != thresholdInitializerMu) {
41          thresholdInitializerMu = value;
42          OnChanged(EventArgs.Empty);
43        }
44      }
45    }
46    [Storable]
47    private double thresholdInitializerSigma;
48    public double ThresholdInitializerSigma {
49      get { return thresholdInitializerSigma; }
50      set {
51        if (thresholdInitializerSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
52        if (value != thresholdInitializerSigma) {
53          thresholdInitializerSigma = value;
54          OnChanged(EventArgs.Empty);
55        }
56      }
57    }
58
59    [Storable]
60    private double thresholdManipulatorMu;
61    public double ThresholdManipulatorMu {
62      get { return thresholdManipulatorMu; }
63      set {
64        if (value != thresholdManipulatorMu) {
65          thresholdManipulatorMu = value;
66          OnChanged(EventArgs.Empty);
67        }
68      }
69    }
70    [Storable]
71    private double thresholdManipulatorSigma;
72    public double ThresholdManipulatorSigma {
73      get { return thresholdManipulatorSigma; }
74      set {
75        if (thresholdManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
76        if (value != thresholdManipulatorSigma) {
77          thresholdManipulatorSigma = value;
78          OnChanged(EventArgs.Empty);
79        }
80      }
81    }
82
83    private List<string> variableNames;
84    [Storable]
85    public IEnumerable<string> VariableNames {
86      get { return variableNames; }
87      set {
88        if (value == null) throw new ArgumentNullException();
89        variableNames.Clear();
90        variableNames.AddRange(value);
91        OnChanged(EventArgs.Empty);
92      }
93    }
94
95    [Storable]
96    private double slopeInitializerMu;
97    public double SlopeInitializerMu {
98      get { return slopeInitializerMu; }
99      set {
100        if (value != slopeInitializerMu) {
101          slopeInitializerMu = value;
102          OnChanged(EventArgs.Empty);
103        }
104      }
105    }
106    [Storable]
107    private double slopeInitializerSigma;
108    public double SlopeInitializerSigma {
109      get { return slopeInitializerSigma; }
110      set {
111        if (slopeInitializerSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
112        if (value != slopeInitializerSigma) {
113          slopeInitializerSigma = value;
114          OnChanged(EventArgs.Empty);
115        }
116      }
117    }
118
119    [Storable]
120    private double slopeManipulatorMu;
121    public double SlopeManipulatorMu {
122      get { return slopeManipulatorMu; }
123      set {
124        if (value != slopeManipulatorMu) {
125          slopeManipulatorMu = value;
126          OnChanged(EventArgs.Empty);
127        }
128      }
129    }
130    [Storable]
131    private double slopeManipulatorSigma;
132    public double SlopeManipulatorSigma {
133      get { return slopeManipulatorSigma; }
134      set {
135        if (slopeManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
136        if (value != slopeManipulatorSigma) {
137          slopeManipulatorSigma = value;
138          OnChanged(EventArgs.Empty);
139        }
140      }
141    }
142    #endregion
143
144    #region persistence and cloning
145    [StorableConstructor]
146    protected VariableCondition(bool deserializing) : base(deserializing) { }
147    protected VariableCondition(VariableCondition original, Cloner cloner)
148      : base(original, cloner) {
149      thresholdInitializerMu = original.thresholdInitializerMu;
150      thresholdInitializerSigma = original.thresholdInitializerSigma;
151      thresholdManipulatorMu = original.thresholdManipulatorMu;
152      thresholdManipulatorSigma = original.thresholdManipulatorSigma;
153
154      variableNames = new List<string>(original.variableNames);
155
156      slopeInitializerMu = original.slopeInitializerMu;
157      slopeInitializerSigma = original.slopeInitializerSigma;
158      slopeManipulatorMu = original.slopeManipulatorMu;
159      slopeManipulatorSigma = original.slopeManipulatorSigma;
160    }
161    public override IDeepCloneable Clone(Cloner cloner) {
162      return new VariableCondition(this, cloner);
163    }
164    #endregion
165
166    public VariableCondition() : this("Variable Condition", "Represents a condition that tests a given variable.") { }
167    public VariableCondition(string name, string description)
168      : base(name, description) {
169      thresholdInitializerMu = 0.0;
170      thresholdInitializerSigma = 1.0;
171      thresholdManipulatorMu = 0.0;
172      thresholdManipulatorSigma = 1.0;
173
174      variableNames = new List<string>();
175
176      slopeInitializerMu = 1.0;
177      slopeInitializerSigma = 0.5;
178      slopeManipulatorMu = 0.0;
179      slopeManipulatorSigma = 0.5;
180    }
181
182    public override SymbolicExpressionTreeNode CreateTreeNode() {
183      return new VariableConditionTreeNode(this);
184    }
185  }
186}
Note: See TracBrowser for help on using the repository browser.