Changeset 5749


Ignore:
Timestamp:
03/18/11 10:44:18 (11 years ago)
Author:
gkronber
Message:

#1418 Minor changes in SymbolicDataAnalysisExpressionTreeInterpreter to prepare for integration of interval arithmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r5624 r5749  
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Data;
     29using HeuristicLab.Parameters;
    2830
    2931namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3032  [StorableClass]
    3133  [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
    3337    private class InterpreterState {
    3438      private const int ARGUMENT_STACK_SIZE = 1024;
     
    8892      }
    8993    }
    90 
    9194    private class OpCodes {
    9295      public const byte Add = 1;
     
    129132      public const byte VariableCondition = 27;
    130133    }
     134    #endregion
    131135
    132136    private Dictionary<Type, byte> symbolToOpcode = new Dictionary<Type, byte>() {
     
    160164    };
    161165
    162 
    163166    public override bool CanChangeName {
    164167      get { return false; }
     
    167170      get { return false; }
    168171    }
     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
    169186
    170187    [StorableConstructor]
     
    176193
    177194    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)));
    179197    }
    180198
    181199    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.");
    182202      var compiler = new SymbolicExpressionTreeCompiler();
    183203      Instruction[] code = compiler.Compile(tree, MapSymbolToOpCode);
Note: See TracChangeset for help on using the changeset viewer.