Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9004 for trunk/sources


Ignore:
Timestamp:
12/05/12 19:00:39 (12 years ago)
Author:
gkronber
Message:

#1081: locking for update of evaluated solutions in interpreter and added cloning for fields in result collection

Location:
trunk/sources
Files:
3 edited

Legend:

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

    r8798 r9004  
    8282
    8383      string targetVariable = TargetVariable;
    84       EvaluatedSolutions.Value++; // increment the evaluated solutions counter
    85       var state = PrepareInterpreterState(tree, dataset, targetVariableCache);
     84      lock (EvaluatedSolutions) {
     85        EvaluatedSolutions.Value++; // increment the evaluated solutions counter
     86      }
     87      var state = PrepareInterpreterState(tree, dataset, targetVariableCache, TargetVariable);
    8688      var rowsEnumerator = rows.GetEnumerator();
    8789      var horizonsEnumerator = horizons.GetEnumerator();
     
    114116    }
    115117
    116     private InterpreterState PrepareInterpreterState(ISymbolicExpressionTree tree, Dataset dataset, double[] targetVariableCache) {
     118    private static InterpreterState PrepareInterpreterState(ISymbolicExpressionTree tree, Dataset dataset, double[] targetVariableCache, string targetVariable) {
    117119      Instruction[] code = SymbolicExpressionTreeCompiler.Compile(tree, OpCodes.MapSymbolToOpCode);
    118120      int necessaryArgStackSize = 0;
     
    120122        if (instr.opCode == OpCodes.Variable) {
    121123          var variableTreeNode = (VariableTreeNode)instr.dynamicNode;
    122           if (variableTreeNode.VariableName == TargetVariable)
     124          if (variableTreeNode.VariableName == targetVariable)
    123125            instr.iArg0 = targetVariableCache;
    124126          else
     
    126128        } else if (instr.opCode == OpCodes.LagVariable) {
    127129          var variableTreeNode = (LaggedVariableTreeNode)instr.dynamicNode;
    128           if (variableTreeNode.VariableName == TargetVariable)
     130          if (variableTreeNode.VariableName == targetVariable)
    129131            instr.iArg0 = targetVariableCache;
    130132          else
     
    132134        } else if (instr.opCode == OpCodes.VariableCondition) {
    133135          var variableTreeNode = (VariableConditionTreeNode)instr.dynamicNode;
    134           if (variableTreeNode.VariableName == TargetVariable)
     136          if (variableTreeNode.VariableName == targetVariable)
    135137            instr.iArg0 = targetVariableCache;
    136138          else
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r8486 r9004  
    9999        throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");
    100100
    101       EvaluatedSolutions.Value++; // increment the evaluated solutions counter
     101      lock (EvaluatedSolutions) {
     102        EvaluatedSolutions.Value++; // increment the evaluated solutions counter
     103      }
    102104      var state = PrepareInterpreterState(tree, dataset);
    103105
     
    109111    }
    110112
    111     private InterpreterState PrepareInterpreterState(ISymbolicExpressionTree tree, Dataset dataset) {
     113    private static InterpreterState PrepareInterpreterState(ISymbolicExpressionTree tree, Dataset dataset) {
    112114      Instruction[] code = SymbolicExpressionTreeCompiler.Compile(tree, OpCodes.MapSymbolToOpCode);
    113115      int necessaryArgStackSize = 0;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs

    r8764 r9004  
    331331    [StorableConstructor]
    332332    public TimeSeriesPrognosisResults(bool deserializing) : base(deserializing) { }
    333     protected TimeSeriesPrognosisResults(TimeSeriesPrognosisResults original, Cloner cloner) : base(original, cloner) { }
     333    protected TimeSeriesPrognosisResults(TimeSeriesPrognosisResults original, Cloner cloner)
     334      : base(original, cloner) {
     335      this.trainingHorizon = original.trainingHorizon;
     336      this.testHorizon = original.testHorizon;
     337      this.solution = cloner.Clone(original.solution);
     338    }
    334339    public override IDeepCloneable Clone(Cloner cloner) {
    335340      return new TimeSeriesPrognosisResults(this, cloner);
Note: See TracChangeset for help on using the changeset viewer.