Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13248


Ignore:
Timestamp:
11/18/15 13:50:15 (9 years ago)
Author:
mkommend
Message:

#2442: Reintegrated branch for compiled symbolic expression tree interpreter.

Location:
trunk/sources
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SymbolicTimeSeriesPrognosisExpressionTreeInterpreter.cs

    r12509 r13248  
    7373    }
    7474
     75    private readonly object syncRoot = new object();
    7576    public IEnumerable<IEnumerable<double>> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) {
    76       if (CheckExpressionsWithIntervalArithmetic.Value)
     77      if (CheckExpressionsWithIntervalArithmetic)
    7778        throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");
    7879      if (targetVariableCache == null || targetVariableCache.GetLength(0) < dataset.Rows)
     
    8283
    8384      string targetVariable = TargetVariable;
    84       lock (EvaluatedSolutions) {
    85         EvaluatedSolutions.Value++; // increment the evaluated solutions counter
     85      lock (syncRoot) {
     86        EvaluatedSolutions++; // increment the evaluated solutions counter
    8687      }
    8788      var state = PrepareInterpreterState(tree, dataset, targetVariableCache, TargetVariable);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r13241 r13248  
    138138    <Compile Include="Importer\Token.cs" />
    139139    <Compile Include="Interfaces\IModelBacktransformator.cs" />
     140    <Compile Include="Interpreter\SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs" />
    140141    <Compile Include="SymbolicDataAnalysisExpressionTreeSimplificationOperator.cs" />
    141142    <Compile Include="SymbolicDataAnalysisModelComplexityCalculator.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisExpressionTreeInterpreter.cs

    r12509 r13248  
    2222using System.Collections.Generic;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2625
     
    2827  public interface ISymbolicDataAnalysisExpressionTreeInterpreter : INamedItem, IStatefulItem {
    2928    IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows);
    30     IntValue EvaluatedSolutions { get; set; }
     29    int EvaluatedSolutions { get; set; }
    3130  }
    3231}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs

    r12509 r13248  
    6969
    7070    private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic";
     71    private const string CheckExpressionsWithIntervalArithmeticParameterDescription = "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.";
    7172    private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions";
    7273
     
    8081
    8182    #region parameter properties
    82 
    83     public IValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter {
    84       get { return (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }
    85     }
    86 
    87     public IValueParameter<IntValue> EvaluatedSolutionsParameter {
    88       get { return (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }
    89     }
    90 
     83    public IFixedValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter {
     84      get { return (IFixedValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }
     85    }
     86
     87    public IFixedValueParameter<IntValue> EvaluatedSolutionsParameter {
     88      get { return (IFixedValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }
     89    }
    9190    #endregion
    9291
    9392    #region properties
    94 
    95     public BoolValue CheckExpressionsWithIntervalArithmetic {
    96       get { return CheckExpressionsWithIntervalArithmeticParameter.Value; }
    97       set { CheckExpressionsWithIntervalArithmeticParameter.Value = value; }
    98     }
    99 
    100     public IntValue EvaluatedSolutions {
    101       get { return EvaluatedSolutionsParameter.Value; }
    102       set { EvaluatedSolutionsParameter.Value = value; }
    103     }
    104 
     93    public bool CheckExpressionsWithIntervalArithmetic {
     94      get { return CheckExpressionsWithIntervalArithmeticParameter.Value.Value; }
     95      set { CheckExpressionsWithIntervalArithmeticParameter.Value.Value = value; }
     96    }
     97    public int EvaluatedSolutions {
     98      get { return EvaluatedSolutionsParameter.Value.Value; }
     99      set { EvaluatedSolutionsParameter.Value.Value = value; }
     100    }
    105101    #endregion
    106 
    107102
    108103    [StorableConstructor]
     
    116111    public SymbolicDataAnalysisExpressionTreeILEmittingInterpreter()
    117112      : base("SymbolicDataAnalysisExpressionTreeILEmittingInterpreter", "Interpreter for symbolic expression trees.") {
    118       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)));
    119       Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
     113      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName,
     114        "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false)));
     115      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
     116    }
     117
     118    public SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(string name, string description)
     119      : base(name, description) {
     120      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName,
     121        "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false)));
     122      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
    120123    }
    121124
    122125    [StorableHook(HookType.AfterDeserialization)]
    123126    private void AfterDeserialization() {
    124       if (!Parameters.ContainsKey(EvaluatedSolutionsParameterName))
    125         Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
     127      var evaluatedSolutions = new IntValue(0);
     128      var checkExpressionsWithIntervalArithmetic = new BoolValue(false);
     129      if (Parameters.ContainsKey(EvaluatedSolutionsParameterName)) {
     130        var evaluatedSolutionsParameter = (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName];
     131        evaluatedSolutions = evaluatedSolutionsParameter.Value;
     132        Parameters.Remove(EvaluatedSolutionsParameterName);
     133      }
     134      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", evaluatedSolutions));
     135      if (Parameters.ContainsKey(CheckExpressionsWithIntervalArithmeticParameterName)) {
     136        var checkExpressionsWithIntervalArithmeticParameter = (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName];
     137        Parameters.Remove(CheckExpressionsWithIntervalArithmeticParameterName);
     138        checkExpressionsWithIntervalArithmetic = checkExpressionsWithIntervalArithmeticParameter.Value;
     139      }
     140      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, checkExpressionsWithIntervalArithmetic));
    126141    }
    127142
    128143    #region IStatefulItem
    129 
    130144    public void InitializeState() {
    131       EvaluatedSolutions.Value = 0;
     145      EvaluatedSolutions = 0;
    132146    }
    133147
    134148    public void ClearState() {
    135       EvaluatedSolutions.Value = 0;
    136     }
    137 
     149    }
    138150    #endregion
    139151
    140152    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) {
    141       if (CheckExpressionsWithIntervalArithmetic.Value)
     153      if (CheckExpressionsWithIntervalArithmetic)
    142154        throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");
    143155
    144       EvaluatedSolutions.Value++; // increment the evaluated solutions counter
     156      EvaluatedSolutions++; // increment the evaluated solutions counter
    145157      var state = PrepareInterpreterState(tree, dataset);
    146158
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r12509 r13248  
    3232  [StorableClass]
    3333  [Item("SymbolicDataAnalysisExpressionTreeInterpreter", "Interpreter for symbolic expression trees including automatically defined functions.")]
    34   public class SymbolicDataAnalysisExpressionTreeInterpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter {
     34  public class SymbolicDataAnalysisExpressionTreeInterpreter : ParameterizedNamedItem,
     35    ISymbolicDataAnalysisExpressionTreeInterpreter {
    3536    private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic";
     37    private const string CheckExpressionsWithIntervalArithmeticParameterDescription = "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.";
    3638    private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions";
    3739
    38     public override bool CanChangeName { get { return false; } }
    39     public override bool CanChangeDescription { get { return false; } }
     40    public override bool CanChangeName {
     41      get { return false; }
     42    }
     43
     44    public override bool CanChangeDescription {
     45      get { return false; }
     46    }
    4047
    4148    #region parameter properties
    42     public IValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter {
    43       get { return (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }
    44     }
    45 
    46     public IValueParameter<IntValue> EvaluatedSolutionsParameter {
    47       get { return (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }
     49    public IFixedValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter {
     50      get { return (IFixedValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }
     51    }
     52
     53    public IFixedValueParameter<IntValue> EvaluatedSolutionsParameter {
     54      get { return (IFixedValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }
    4855    }
    4956    #endregion
    5057
    5158    #region properties
    52     public BoolValue CheckExpressionsWithIntervalArithmetic {
    53       get { return CheckExpressionsWithIntervalArithmeticParameter.Value; }
    54       set { CheckExpressionsWithIntervalArithmeticParameter.Value = value; }
    55     }
    56 
    57     public IntValue EvaluatedSolutions {
    58       get { return EvaluatedSolutionsParameter.Value; }
    59       set { EvaluatedSolutionsParameter.Value = value; }
     59    public bool CheckExpressionsWithIntervalArithmetic {
     60      get { return CheckExpressionsWithIntervalArithmeticParameter.Value.Value; }
     61      set { CheckExpressionsWithIntervalArithmeticParameter.Value.Value = value; }
     62    }
     63
     64    public int EvaluatedSolutions {
     65      get { return EvaluatedSolutionsParameter.Value.Value; }
     66      set { EvaluatedSolutionsParameter.Value.Value = value; }
    6067    }
    6168    #endregion
     
    6370    [StorableConstructor]
    6471    protected SymbolicDataAnalysisExpressionTreeInterpreter(bool deserializing) : base(deserializing) { }
    65     protected SymbolicDataAnalysisExpressionTreeInterpreter(SymbolicDataAnalysisExpressionTreeInterpreter original, Cloner cloner) : base(original, cloner) { }
     72
     73    protected SymbolicDataAnalysisExpressionTreeInterpreter(SymbolicDataAnalysisExpressionTreeInterpreter original,
     74      Cloner cloner) : base(original, cloner) { }
     75
    6676    public override IDeepCloneable Clone(Cloner cloner) {
    6777      return new SymbolicDataAnalysisExpressionTreeInterpreter(this, cloner);
     
    7080    public SymbolicDataAnalysisExpressionTreeInterpreter()
    7181      : base("SymbolicDataAnalysisExpressionTreeInterpreter", "Interpreter for symbolic expression trees including automatically defined functions.") {
    72       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)));
    73       Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
     82      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false)));
     83      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
    7484    }
    7585
    7686    protected SymbolicDataAnalysisExpressionTreeInterpreter(string name, string description)
    7787      : base(name, description) {
    78       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)));
    79       Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
     88      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.", new BoolValue(false)));
     89      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
    8090    }
    8191
    8292    [StorableHook(HookType.AfterDeserialization)]
    8393    private void AfterDeserialization() {
    84       if (!Parameters.ContainsKey(EvaluatedSolutionsParameterName))
    85         Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
     94      var evaluatedSolutions = new IntValue(0);
     95      var checkExpressionsWithIntervalArithmetic = new BoolValue(false);
     96      if (Parameters.ContainsKey(EvaluatedSolutionsParameterName)) {
     97        var evaluatedSolutionsParameter = (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName];
     98        evaluatedSolutions = evaluatedSolutionsParameter.Value;
     99        Parameters.Remove(EvaluatedSolutionsParameterName);
     100      }
     101      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", evaluatedSolutions));
     102      if (Parameters.ContainsKey(CheckExpressionsWithIntervalArithmeticParameterName)) {
     103        var checkExpressionsWithIntervalArithmeticParameter = (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName];
     104        Parameters.Remove(CheckExpressionsWithIntervalArithmeticParameterName);
     105        checkExpressionsWithIntervalArithmetic = checkExpressionsWithIntervalArithmeticParameter.Value;
     106      }
     107      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, checkExpressionsWithIntervalArithmetic));
    86108    }
    87109
    88110    #region IStatefulItem
    89111    public void InitializeState() {
    90       EvaluatedSolutions.Value = 0;
    91     }
    92 
    93     public void ClearState() {
    94     }
     112      EvaluatedSolutions = 0;
     113    }
     114
     115    public void ClearState() { }
    95116    #endregion
    96117
    97     public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) {
    98       if (CheckExpressionsWithIntervalArithmetic.Value)
     118    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset,
     119      IEnumerable<int> rows) {
     120      if (CheckExpressionsWithIntervalArithmetic) {
    99121        throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");
    100 
    101       lock (EvaluatedSolutions) {
    102         EvaluatedSolutions.Value++; // increment the evaluated solutions counter
     122      }
     123
     124      lock (EvaluatedSolutionsParameter.Value) {
     125        EvaluatedSolutions++; // increment the evaluated solutions counter
    103126      }
    104127      var state = PrepareInterpreterState(tree, dataset);
     
    131154    }
    132155
    133 
    134156    public virtual double Evaluate(IDataset dataset, ref int row, InterpreterState state) {
    135157      Instruction currentInstr = state.NextInstruction();
     
    147169              s -= Evaluate(dataset, ref row, state);
    148170            }
    149             if (currentInstr.nArguments == 1) s = -s;
     171            if (currentInstr.nArguments == 1) { s = -s; }
    150172            return s;
    151173          }
     
    162184              p /= Evaluate(dataset, ref row, state);
    163185            }
    164             if (currentInstr.nArguments == 1) p = 1.0 / p;
     186            if (currentInstr.nArguments == 1) { p = 1.0 / p; }
    165187            return p;
    166188          }
     
    205227        case OpCodes.Gamma: {
    206228            var x = Evaluate(dataset, ref row, state);
    207             if (double.IsNaN(x)) return double.NaN;
    208             else return alglib.gammafunction(x);
     229            if (double.IsNaN(x)) { return double.NaN; } else { return alglib.gammafunction(x); }
    209230          }
    210231        case OpCodes.Psi: {
     
    216237        case OpCodes.Dawson: {
    217238            var x = Evaluate(dataset, ref row, state);
    218             if (double.IsNaN(x)) return double.NaN;
     239            if (double.IsNaN(x)) { return double.NaN; }
    219240            return alglib.dawsonintegral(x);
    220241          }
    221242        case OpCodes.ExponentialIntegralEi: {
    222243            var x = Evaluate(dataset, ref row, state);
    223             if (double.IsNaN(x)) return double.NaN;
     244            if (double.IsNaN(x)) { return double.NaN; }
    224245            return alglib.exponentialintegralei(x);
    225246          }
     
    349370            int positiveSignals = 0;
    350371            for (int i = 0; i < currentInstr.nArguments; i++) {
    351               if (Evaluate(dataset, ref row, state) > 0.0) positiveSignals++;
     372              if (Evaluate(dataset, ref row, state) > 0.0) { positiveSignals++; }
    352373            }
    353374            return positiveSignals % 2 != 0 ? 1.0 : -1.0;
     
    356377            double x = Evaluate(dataset, ref row, state);
    357378            double y = Evaluate(dataset, ref row, state);
    358             if (x > y) return 1.0;
    359             else return -1.0;
     379            if (x > y) { return 1.0; } else { return -1.0; }
    360380          }
    361381        case OpCodes.LT: {
    362382            double x = Evaluate(dataset, ref row, state);
    363383            double y = Evaluate(dataset, ref row, state);
    364             if (x < y) return 1.0;
    365             else return -1.0;
     384            if (x < y) { return 1.0; } else { return -1.0; }
    366385          }
    367386        case OpCodes.TimeLag: {
     
    437456            var laggedVariableTreeNode = (LaggedVariableTreeNode)currentInstr.dynamicNode;
    438457            int actualRow = row + laggedVariableTreeNode.Lag;
    439             if (actualRow < 0 || actualRow >= dataset.Rows) return double.NaN;
     458            if (actualRow < 0 || actualRow >= dataset.Rows) { return double.NaN; }
    440459            return ((IList<double>)currentInstr.data)[actualRow] * laggedVariableTreeNode.Weight;
    441460          }
     
    459478            return trueBranch * p + falseBranch * (1 - p);
    460479          }
    461         default: throw new NotSupportedException();
     480        default:
     481          throw new NotSupportedException();
    462482      }
    463483    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r12509 r13248  
    3535  public sealed class SymbolicDataAnalysisExpressionTreeLinearInterpreter : ParameterizedNamedItem, ISymbolicDataAnalysisExpressionTreeInterpreter {
    3636    private const string CheckExpressionsWithIntervalArithmeticParameterName = "CheckExpressionsWithIntervalArithmetic";
     37    private const string CheckExpressionsWithIntervalArithmeticParameterDescription = "Switch that determines if the interpreter checks the validity of expressions with interval arithmetic before evaluating the expression.";
    3738    private const string EvaluatedSolutionsParameterName = "EvaluatedSolutions";
    3839
     
    4849
    4950    #region parameter properties
    50     public IValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter {
    51       get { return (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }
    52     }
    53 
    54     public IValueParameter<IntValue> EvaluatedSolutionsParameter {
    55       get { return (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }
     51    public IFixedValueParameter<BoolValue> CheckExpressionsWithIntervalArithmeticParameter {
     52      get { return (IFixedValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; }
     53    }
     54
     55    public IFixedValueParameter<IntValue> EvaluatedSolutionsParameter {
     56      get { return (IFixedValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName]; }
    5657    }
    5758    #endregion
    5859
    5960    #region properties
    60     public BoolValue CheckExpressionsWithIntervalArithmetic {
    61       get { return CheckExpressionsWithIntervalArithmeticParameter.Value; }
    62       set { CheckExpressionsWithIntervalArithmeticParameter.Value = value; }
    63     }
    64     public IntValue EvaluatedSolutions {
    65       get { return EvaluatedSolutionsParameter.Value; }
    66       set { EvaluatedSolutionsParameter.Value = value; }
     61    public bool CheckExpressionsWithIntervalArithmetic {
     62      get { return CheckExpressionsWithIntervalArithmeticParameter.Value.Value; }
     63      set { CheckExpressionsWithIntervalArithmeticParameter.Value.Value = value; }
     64    }
     65    public int EvaluatedSolutions {
     66      get { return EvaluatedSolutionsParameter.Value.Value; }
     67      set { EvaluatedSolutionsParameter.Value.Value = value; }
    6768    }
    6869    #endregion
     
    8485    public SymbolicDataAnalysisExpressionTreeLinearInterpreter()
    8586      : base("SymbolicDataAnalysisExpressionTreeLinearInterpreter", "Linear (non-recursive) interpreter for symbolic expression trees (does not support ADFs).") {
    86       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)));
    87       Parameters.Add(new ValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
     87      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, new BoolValue(false)));
     88      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
     89      interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();
     90    }
     91
     92    public SymbolicDataAnalysisExpressionTreeLinearInterpreter(string name, string description)
     93      : base(name, description) {
     94      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, new BoolValue(false)));
     95      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
    8896      interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();
    8997    }
     
    9199    [StorableHook(HookType.AfterDeserialization)]
    92100    private void AfterDeserialization() {
    93       if (interpreter == null) interpreter = new SymbolicDataAnalysisExpressionTreeInterpreter();
     101      var evaluatedSolutions = new IntValue(0);
     102      var checkExpressionsWithIntervalArithmetic = new BoolValue(false);
     103      if (Parameters.ContainsKey(EvaluatedSolutionsParameterName)) {
     104        var evaluatedSolutionsParameter = (IValueParameter<IntValue>)Parameters[EvaluatedSolutionsParameterName];
     105        evaluatedSolutions = evaluatedSolutionsParameter.Value;
     106        Parameters.Remove(EvaluatedSolutionsParameterName);
     107      }
     108      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", evaluatedSolutions));
     109      if (Parameters.ContainsKey(CheckExpressionsWithIntervalArithmeticParameterName)) {
     110        var checkExpressionsWithIntervalArithmeticParameter = (IValueParameter<BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName];
     111        Parameters.Remove(CheckExpressionsWithIntervalArithmeticParameterName);
     112        checkExpressionsWithIntervalArithmetic = checkExpressionsWithIntervalArithmeticParameter.Value;
     113      }
     114      Parameters.Add(new FixedValueParameter<BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, checkExpressionsWithIntervalArithmetic));
    94115    }
    95116
    96117    #region IStatefulItem
    97118    public void InitializeState() {
    98       EvaluatedSolutions.Value = 0;
     119      EvaluatedSolutions = 0;
    99120    }
    100121
     
    103124
    104125    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) {
    105       if (CheckExpressionsWithIntervalArithmetic.Value)
     126      if (CheckExpressionsWithIntervalArithmetic)
    106127        throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");
    107128
    108       lock (EvaluatedSolutions) {
    109         EvaluatedSolutions.Value++; // increment the evaluated solutions counter
     129      lock (EvaluatedSolutionsParameter.Value) {
     130        EvaluatedSolutions++; // increment the evaluated solutions counter
    110131      }
    111132
Note: See TracChangeset for help on using the changeset viewer.