Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs @ 5685

Last change on this file since 5685 was 5532, checked in by gkronber, 14 years ago

#1418 copied symbol classes into Problems.DataAnalysis.Symbolic plugin.

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