[3253] | 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 HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
[3376] | 23 | using HeuristicLab.Common;
|
---|
[3269] | 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Operators;
|
---|
| 26 | using HeuristicLab.Random;
|
---|
| 27 | using HeuristicLab.Data;
|
---|
| 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 29 | using HeuristicLab.Parameters;
|
---|
[3294] | 30 | using System.Collections.Generic;
|
---|
| 31 | using System;
|
---|
[3462] | 32 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
|
---|
[3373] | 33 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols {
|
---|
[3269] | 34 | [StorableClass]
|
---|
| 35 | [Item("Variable", "Represents a variable value.")]
|
---|
[3253] | 36 | public sealed class Variable : Symbol {
|
---|
[3269] | 37 | #region Properties
|
---|
[3485] | 38 | [Storable]
|
---|
[3294] | 39 | private double weightNu;
|
---|
| 40 | public double WeightNu {
|
---|
| 41 | get { return weightNu; }
|
---|
| 42 | set { weightNu = value; }
|
---|
[3269] | 43 | }
|
---|
[3485] | 44 | [Storable]
|
---|
[3294] | 45 | private double weightSigma;
|
---|
| 46 | public double WeightSigma {
|
---|
| 47 | get { return weightSigma; }
|
---|
| 48 | set {
|
---|
| 49 | if (weightSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
| 50 | weightSigma = value;
|
---|
| 51 | }
|
---|
[3269] | 52 | }
|
---|
[3485] | 53 | [Storable]
|
---|
[3512] | 54 | private double weightManipulatorNu;
|
---|
| 55 | public double WeightManipulatorNu {
|
---|
| 56 | get { return weightManipulatorNu; }
|
---|
| 57 | set { weightManipulatorNu = value; }
|
---|
| 58 | }
|
---|
| 59 | [Storable]
|
---|
| 60 | private double weightManipulatorSigma;
|
---|
| 61 | public double WeightManipulatorSigma {
|
---|
| 62 | get { return weightManipulatorSigma; }
|
---|
| 63 | set {
|
---|
| 64 | if (weightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed.");
|
---|
| 65 | weightManipulatorSigma = value;
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
[3541] | 68 | private List<string> variableNames;
|
---|
[3512] | 69 | [Storable]
|
---|
[3442] | 70 | public IEnumerable<string> VariableNames {
|
---|
[3294] | 71 | get { return variableNames; }
|
---|
| 72 | set {
|
---|
| 73 | if (value == null) throw new ArgumentNullException();
|
---|
| 74 | variableNames.Clear();
|
---|
| 75 | variableNames.AddRange(value);
|
---|
| 76 | }
|
---|
[3269] | 77 | }
|
---|
| 78 | #endregion
|
---|
| 79 | public Variable()
|
---|
| 80 | : base() {
|
---|
[3294] | 81 | weightNu = 1.0;
|
---|
| 82 | weightSigma = 1.0;
|
---|
[3512] | 83 | weightManipulatorNu = 0.0;
|
---|
| 84 | weightManipulatorSigma = 1.0;
|
---|
[3294] | 85 | variableNames = new List<string>();
|
---|
[3269] | 86 | }
|
---|
| 87 |
|
---|
[3253] | 88 | public override SymbolicExpressionTreeNode CreateTreeNode() {
|
---|
| 89 | return new VariableTreeNode(this);
|
---|
| 90 | }
|
---|
[3485] | 91 |
|
---|
| 92 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 93 | Variable clone = (Variable)base.Clone(cloner);
|
---|
| 94 | clone.weightNu = weightNu;
|
---|
| 95 | clone.weightSigma = weightSigma;
|
---|
| 96 | clone.variableNames = new List<string>(variableNames);
|
---|
[3512] | 97 | clone.weightManipulatorNu = weightManipulatorNu;
|
---|
| 98 | clone.weightManipulatorSigma = weightManipulatorSigma;
|
---|
[3485] | 99 | return clone;
|
---|
| 100 | }
|
---|
[3253] | 101 | }
|
---|
| 102 | }
|
---|