[3253] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[5445] | 3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3253] | 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 |
|
---|
[4068] | 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
[3376] | 24 | using HeuristicLab.Common;
|
---|
[3269] | 25 | using HeuristicLab.Core;
|
---|
[4068] | 26 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 27 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
|
---|
[3269] | 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[3373] | 29 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
|
---|
[3269] | 30 | [StorableClass]
|
---|
| 31 | [Item("Variable", "Represents a variable value.")]
|
---|
[4022] | 32 | public class Variable : Symbol {
|
---|
[3269] | 33 | #region Properties
|
---|
[3485] | 34 | [Storable]
|
---|
[4989] | 35 | private double weightMu;
|
---|
| 36 | public double WeightMu {
|
---|
| 37 | get { return weightMu; }
|
---|
[3824] | 38 | set {
|
---|
[4989] | 39 | if (value != weightMu) {
|
---|
| 40 | weightMu = value;
|
---|
[3824] | 41 | OnChanged(EventArgs.Empty);
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
[3269] | 44 | }
|
---|
[3485] | 45 | [Storable]
|
---|
[3294] | 46 | private double weightSigma;
|
---|
| 47 | public double WeightSigma {
|
---|
| 48 | get { return weightSigma; }
|
---|
| 49 | set {
|
---|
| 50 | if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
[3824] | 51 | if (value != weightSigma) {
|
---|
| 52 | weightSigma = value;
|
---|
| 53 | OnChanged(EventArgs.Empty);
|
---|
| 54 | }
|
---|
[3294] | 55 | }
|
---|
[3269] | 56 | }
|
---|
[3485] | 57 | [Storable]
|
---|
[4989] | 58 | private double weightManipulatorMu;
|
---|
| 59 | public double WeightManipulatorMu {
|
---|
| 60 | get { return weightManipulatorMu; }
|
---|
[3824] | 61 | set {
|
---|
[4989] | 62 | if (value != weightManipulatorMu) {
|
---|
| 63 | weightManipulatorMu = value;
|
---|
[3824] | 64 | OnChanged(EventArgs.Empty);
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
[3512] | 67 | }
|
---|
| 68 | [Storable]
|
---|
| 69 | private double weightManipulatorSigma;
|
---|
| 70 | public double WeightManipulatorSigma {
|
---|
| 71 | get { return weightManipulatorSigma; }
|
---|
| 72 | set {
|
---|
| 73 | if (weightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
[3824] | 74 | if (value != weightManipulatorSigma) {
|
---|
| 75 | weightManipulatorSigma = value;
|
---|
| 76 | OnChanged(EventArgs.Empty);
|
---|
| 77 | }
|
---|
[3512] | 78 | }
|
---|
| 79 | }
|
---|
[5326] | 80 | [Storable(DefaultValue = 0.0)]
|
---|
| 81 | private double multiplicativeWeightManipulatorSigma;
|
---|
| 82 | public double MultiplicativeWeightManipulatorSigma {
|
---|
| 83 | get { return multiplicativeWeightManipulatorSigma; }
|
---|
| 84 | set {
|
---|
| 85 | if (multiplicativeWeightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
| 86 | if (value != multiplicativeWeightManipulatorSigma) {
|
---|
| 87 | multiplicativeWeightManipulatorSigma = value;
|
---|
| 88 | OnChanged(EventArgs.Empty);
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
[3541] | 92 | private List<string> variableNames;
|
---|
[3512] | 93 | [Storable]
|
---|
[3442] | 94 | public IEnumerable<string> VariableNames {
|
---|
[3294] | 95 | get { return variableNames; }
|
---|
| 96 | set {
|
---|
| 97 | if (value == null) throw new ArgumentNullException();
|
---|
| 98 | variableNames.Clear();
|
---|
| 99 | variableNames.AddRange(value);
|
---|
[3824] | 100 | OnChanged(EventArgs.Empty);
|
---|
[3294] | 101 | }
|
---|
[3269] | 102 | }
|
---|
| 103 | #endregion
|
---|
[4722] | 104 | [StorableConstructor]
|
---|
[5326] | 105 | protected Variable(bool deserializing)
|
---|
| 106 | : base(deserializing) {
|
---|
[4722] | 107 | variableNames = new List<string>();
|
---|
| 108 | }
|
---|
| 109 | protected Variable(Variable original, Cloner cloner)
|
---|
| 110 | : base(original, cloner) {
|
---|
[4989] | 111 | weightMu = original.weightMu;
|
---|
[4722] | 112 | weightSigma = original.weightSigma;
|
---|
| 113 | variableNames = new List<string>(original.variableNames);
|
---|
[4989] | 114 | weightManipulatorMu = original.weightManipulatorMu;
|
---|
[4722] | 115 | weightManipulatorSigma = original.weightManipulatorSigma;
|
---|
[5326] | 116 | multiplicativeWeightManipulatorSigma = original.multiplicativeWeightManipulatorSigma;
|
---|
[4722] | 117 | }
|
---|
[4022] | 118 | public Variable() : this("Variable", "Represents a variable value.") { }
|
---|
| 119 | public Variable(string name, string description)
|
---|
| 120 | : base(name, description) {
|
---|
[4989] | 121 | weightMu = 1.0;
|
---|
[3294] | 122 | weightSigma = 1.0;
|
---|
[4989] | 123 | weightManipulatorMu = 0.0;
|
---|
[5334] | 124 | weightManipulatorSigma = 0.05;
|
---|
[5326] | 125 | multiplicativeWeightManipulatorSigma = 0.03;
|
---|
[3294] | 126 | variableNames = new List<string>();
|
---|
[3269] | 127 | }
|
---|
| 128 |
|
---|
[3253] | 129 | public override SymbolicExpressionTreeNode CreateTreeNode() {
|
---|
| 130 | return new VariableTreeNode(this);
|
---|
| 131 | }
|
---|
[3485] | 132 |
|
---|
| 133 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[4722] | 134 | return new Variable(this, cloner);
|
---|
[3485] | 135 | }
|
---|
[3253] | 136 | }
|
---|
| 137 | }
|
---|