Changeset 16692 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs
- Timestamp:
- 03/18/19 17:24:30 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; … … 29 27 [StorableClass] 30 28 [Item("Variable", "Represents a variable value.")] 31 public class Variable : Symbol { 32 #region Properties 33 [Storable] 34 private double weightMu; 35 public double WeightMu { 36 get { return weightMu; } 37 set { 38 if (value != weightMu) { 39 weightMu = value; 40 OnChanged(EventArgs.Empty); 41 } 42 } 43 } 44 [Storable] 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 if (value != weightSigma) { 51 weightSigma = value; 52 OnChanged(EventArgs.Empty); 53 } 54 } 55 } 56 [Storable] 57 private double weightManipulatorMu; 58 public double WeightManipulatorMu { 59 get { return weightManipulatorMu; } 60 set { 61 if (value != weightManipulatorMu) { 62 weightManipulatorMu = value; 63 OnChanged(EventArgs.Empty); 64 } 65 } 66 } 67 [Storable] 68 private double weightManipulatorSigma; 69 public double WeightManipulatorSigma { 70 get { return weightManipulatorSigma; } 71 set { 72 if (weightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed."); 73 if (value != weightManipulatorSigma) { 74 weightManipulatorSigma = value; 75 OnChanged(EventArgs.Empty); 76 } 77 } 78 } 79 [Storable(DefaultValue = 0.0)] 80 private double multiplicativeWeightManipulatorSigma; 81 public double MultiplicativeWeightManipulatorSigma { 82 get { return multiplicativeWeightManipulatorSigma; } 83 set { 84 if (multiplicativeWeightManipulatorSigma < 0.0) throw new ArgumentException("Negative sigma is not allowed."); 85 if (value != multiplicativeWeightManipulatorSigma) { 86 multiplicativeWeightManipulatorSigma = value; 87 OnChanged(EventArgs.Empty); 88 } 89 } 90 } 91 private List<string> variableNames; 92 [Storable] 93 public IEnumerable<string> VariableNames { 94 get { return variableNames; } 95 set { 96 if (value == null) throw new ArgumentNullException(); 97 variableNames.Clear(); 98 variableNames.AddRange(value); 99 OnChanged(EventArgs.Empty); 100 } 101 } 102 103 private List<string> allVariableNames; 104 [Storable] 105 public IEnumerable<string> AllVariableNames { 106 get { return allVariableNames; } 107 set { 108 if (value == null) throw new ArgumentNullException(); 109 allVariableNames.Clear(); 110 allVariableNames.AddRange(value); 111 } 112 } 113 114 public override bool Enabled { 115 get { 116 if (variableNames.Count == 0) return false; 117 return base.Enabled; 118 } 119 set { 120 if (variableNames.Count == 0) base.Enabled = false; 121 else base.Enabled = value; 122 } 123 } 124 125 private const int minimumArity = 0; 126 private const int maximumArity = 0; 127 128 public override int MinimumArity { 129 get { return minimumArity; } 130 } 131 public override int MaximumArity { 132 get { return maximumArity; } 133 } 134 #endregion 135 136 [StorableHook(HookType.AfterDeserialization)] 137 private void AfterDeserialization() { 138 if (allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) { 139 allVariableNames = variableNames; 140 } 141 } 29 public sealed class Variable : VariableBase { 142 30 143 31 [StorableConstructor] 144 pr otectedVariable(bool deserializing)32 private Variable(bool deserializing) 145 33 : base(deserializing) { 146 variableNames = new List<string>();147 allVariableNames = new List<string>();148 34 } 149 pr otectedVariable(Variable original, Cloner cloner)35 private Variable(Variable original, Cloner cloner) 150 36 : base(original, cloner) { 151 weightMu = original.weightMu;152 weightSigma = original.weightSigma;153 variableNames = new List<string>(original.variableNames);154 allVariableNames = new List<string>(original.allVariableNames);155 weightManipulatorMu = original.weightManipulatorMu;156 weightManipulatorSigma = original.weightManipulatorSigma;157 multiplicativeWeightManipulatorSigma = original.multiplicativeWeightManipulatorSigma;158 37 } 159 public Variable() : this("Variable", "Represents a variable value.") { } 160 public Variable(string name, string description) 161 : base(name, description) { 162 weightMu = 1.0; 163 weightSigma = 1.0; 164 weightManipulatorMu = 0.0; 165 weightManipulatorSigma = 0.05; 166 multiplicativeWeightManipulatorSigma = 0.03; 167 variableNames = new List<string>(); 168 allVariableNames = new List<string>(); 169 } 38 public Variable() : base("Variable", "Represents a variable value.") { } 39 public Variable(string name, string description) : base(name, description) { } 170 40 171 41 public override ISymbolicExpressionTreeNode CreateTreeNode() {
Note: See TracChangeset
for help on using the changeset viewer.