Changeset 5749
- Timestamp:
- 03/18/11 10:44:18 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r5624 r5749 26 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 28 30 29 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 30 32 [StorableClass] 31 33 [Item("SymbolicDataAnalysisExpressionTreeInterpreter", "Interpreter for symbolic expression trees including automatically defined functions.")] 32 public sealed class SymbolicDataAnalysisExpressionTreeInterpreter : NamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter { 34 public sealed class SymbolicDataAnalysisExpressionTreeInterpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter { 35 private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic"; 36 #region private classes 33 37 private class InterpreterState { 34 38 private const int ARGUMENT_STACK_SIZE = 1024; … … 88 92 } 89 93 } 90 91 94 private class OpCodes { 92 95 public const byte Add = 1; … … 129 132 public const byte VariableCondition = 27; 130 133 } 134 #endregion 131 135 132 136 private Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() { … … 160 164 }; 161 165 162 163 166 public override bool CanChangeName { 164 167 get { return false; } … … 167 170 get { return false; } 168 171 } 172 173 #region parameter properties 174 public IValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter { 175 get { return (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; } 176 } 177 #endregion 178 179 #region properties 180 public BoolValue CheckExpressionsWithIntervalArithmetic { 181 get { return CheckExpressionsWithIntervalArithmeticParameter.Value; } 182 set { CheckExpressionsWithIntervalArithmeticParameter.Value = value; } 183 } 184 #endregion 185 169 186 170 187 [StorableConstructor] … … 176 193 177 194 public SymbolicDataAnalysisExpressionTreeInterpreter() 178 : base() { 195 : base("SymbolicDataAnalysisExpressionTreeInterpreter", "Interpreter for symbolic expression trees including automatically defined functions.") { 196 Parameters.Add(new ValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false))); 179 197 } 180 198 181 199 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, Dataset dataset, IEnumerable<int> rows) { 200 if (CheckExpressionsWithIntervalArithmetic.Value) 201 throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter."); 182 202 var compiler = new SymbolicExpressionTreeCompiler(); 183 203 Instruction[] code = compiler.Compile(tree, MapSymbolToOpCode);
Note: See TracChangeset
for help on using the changeset viewer.