Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/Variable.cs @ 4722

Last change on this file since 4722 was 4722, checked in by swagner, 14 years ago

Merged cloning refactoring branch back into trunk (#922)

File size: 4.0 KB
RevLine 
[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
[4068]22using System;
23using System.Collections.Generic;
[3376]24using HeuristicLab.Common;
[3269]25using HeuristicLab.Core;
[4068]26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
[3269]28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[3373]29namespace 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]
[3294]35    private double weightNu;
36    public double WeightNu {
37      get { return weightNu; }
[3824]38      set {
39        if (value != weightNu) {
40          weightNu = value;
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]
[3512]58    private double weightManipulatorNu;
59    public double WeightManipulatorNu {
60      get { return weightManipulatorNu; }
[3824]61      set {
62        if (value != weightManipulatorNu) {
63          weightManipulatorNu = value;
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    }
[3541]80    private List<string> variableNames;
[3512]81    [Storable]
[3442]82    public IEnumerable<string> VariableNames {
[3294]83      get { return variableNames; }
84      set {
85        if (value == null) throw new ArgumentNullException();
86        variableNames.Clear();
87        variableNames.AddRange(value);
[3824]88        OnChanged(EventArgs.Empty);
[3294]89      }
[3269]90    }
91    #endregion
[4722]92    [StorableConstructor]
93    protected Variable(bool deserializing) : base(deserializing) {
94      variableNames = new List<string>();
95    }
96    protected Variable(Variable original, Cloner cloner)
97      : base(original, cloner) {
98      weightNu = original.weightNu;
99      weightSigma = original.weightSigma;
100      variableNames = new List<string>(original.variableNames);
101      weightManipulatorNu = original.weightManipulatorNu;
102      weightManipulatorSigma = original.weightManipulatorSigma;
103    }
[4022]104    public Variable() : this("Variable", "Represents a variable value.") { }
105    public Variable(string name, string description)
106      : base(name, description) {
[3294]107      weightNu = 1.0;
108      weightSigma = 1.0;
[3512]109      weightManipulatorNu = 0.0;
110      weightManipulatorSigma = 1.0;
[3294]111      variableNames = new List<string>();
[3269]112    }
113
[3253]114    public override SymbolicExpressionTreeNode CreateTreeNode() {
115      return new VariableTreeNode(this);
116    }
[3485]117
118    public override IDeepCloneable Clone(Cloner cloner) {
[4722]119      return new Variable(this, cloner);
[3485]120    }
[3253]121  }
122}
Note: See TracBrowser for help on using the repository browser.