[5060] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 28 |
|
---|
[5532] | 29 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
|
---|
[5060] | 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();
|
---|
[5689] | 88 | variableNames = new List<string>(value);
|
---|
[5060] | 89 | OnChanged(EventArgs.Empty);
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | [Storable]
|
---|
| 94 | private double slopeInitializerMu;
|
---|
| 95 | public double SlopeInitializerMu {
|
---|
| 96 | get { return slopeInitializerMu; }
|
---|
| 97 | set {
|
---|
| 98 | if (value != slopeInitializerMu) {
|
---|
| 99 | slopeInitializerMu = value;
|
---|
| 100 | OnChanged(EventArgs.Empty);
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
| 104 | [Storable]
|
---|
| 105 | private double slopeInitializerSigma;
|
---|
| 106 | public double SlopeInitializerSigma {
|
---|
| 107 | get { return slopeInitializerSigma; }
|
---|
| 108 | set {
|
---|
| 109 | if (slopeInitializerSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
| 110 | if (value != slopeInitializerSigma) {
|
---|
| 111 | slopeInitializerSigma = value;
|
---|
| 112 | OnChanged(EventArgs.Empty);
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | [Storable]
|
---|
| 118 | private double slopeManipulatorMu;
|
---|
| 119 | public double SlopeManipulatorMu {
|
---|
| 120 | get { return slopeManipulatorMu; }
|
---|
| 121 | set {
|
---|
| 122 | if (value != slopeManipulatorMu) {
|
---|
| 123 | slopeManipulatorMu = value;
|
---|
| 124 | OnChanged(EventArgs.Empty);
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 | [Storable]
|
---|
| 129 | private double slopeManipulatorSigma;
|
---|
| 130 | public double SlopeManipulatorSigma {
|
---|
| 131 | get { return slopeManipulatorSigma; }
|
---|
| 132 | set {
|
---|
| 133 | if (slopeManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
| 134 | if (value != slopeManipulatorSigma) {
|
---|
| 135 | slopeManipulatorSigma = value;
|
---|
| 136 | OnChanged(EventArgs.Empty);
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
[6803] | 140 |
|
---|
| 141 | private const int minimumArity = 2;
|
---|
| 142 | private const int maximumArity = 2;
|
---|
| 143 |
|
---|
| 144 | public override int MinimumArity {
|
---|
| 145 | get { return minimumArity; }
|
---|
| 146 | }
|
---|
| 147 | public override int MaximumArity {
|
---|
| 148 | get { return maximumArity; }
|
---|
| 149 | }
|
---|
[5060] | 150 | #endregion
|
---|
| 151 |
|
---|
| 152 | #region persistence and cloning
|
---|
| 153 | [StorableConstructor]
|
---|
[5484] | 154 | private VariableCondition(bool deserializing) : base(deserializing) { }
|
---|
| 155 | private VariableCondition(VariableCondition original, Cloner cloner)
|
---|
[5060] | 156 | : base(original, cloner) {
|
---|
| 157 | thresholdInitializerMu = original.thresholdInitializerMu;
|
---|
| 158 | thresholdInitializerSigma = original.thresholdInitializerSigma;
|
---|
| 159 | thresholdManipulatorMu = original.thresholdManipulatorMu;
|
---|
| 160 | thresholdManipulatorSigma = original.thresholdManipulatorSigma;
|
---|
| 161 |
|
---|
| 162 | variableNames = new List<string>(original.variableNames);
|
---|
| 163 |
|
---|
| 164 | slopeInitializerMu = original.slopeInitializerMu;
|
---|
| 165 | slopeInitializerSigma = original.slopeInitializerSigma;
|
---|
| 166 | slopeManipulatorMu = original.slopeManipulatorMu;
|
---|
| 167 | slopeManipulatorSigma = original.slopeManipulatorSigma;
|
---|
| 168 | }
|
---|
| 169 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 170 | return new VariableCondition(this, cloner);
|
---|
| 171 | }
|
---|
| 172 | #endregion
|
---|
| 173 |
|
---|
| 174 | public VariableCondition() : this("Variable Condition", "Represents a condition that tests a given variable.") { }
|
---|
| 175 | public VariableCondition(string name, string description)
|
---|
| 176 | : base(name, description) {
|
---|
| 177 | thresholdInitializerMu = 0.0;
|
---|
[5467] | 178 | thresholdInitializerSigma = 0.1;
|
---|
[5060] | 179 | thresholdManipulatorMu = 0.0;
|
---|
[5467] | 180 | thresholdManipulatorSigma = 0.1;
|
---|
[5060] | 181 |
|
---|
| 182 | variableNames = new List<string>();
|
---|
| 183 |
|
---|
| 184 | slopeInitializerMu = 1.0;
|
---|
[5467] | 185 | slopeInitializerSigma = 0.05;
|
---|
[5060] | 186 | slopeManipulatorMu = 0.0;
|
---|
[5467] | 187 | slopeManipulatorSigma = 0.05;
|
---|
[5060] | 188 | }
|
---|
| 189 |
|
---|
[5532] | 190 | public override ISymbolicExpressionTreeNode CreateTreeNode() {
|
---|
[5060] | 191 | return new VariableConditionTreeNode(this);
|
---|
| 192 | }
|
---|
| 193 | }
|
---|
| 194 | }
|
---|