Changeset 17100 for stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Timestamp:
- 07/07/19 23:47:53 (5 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk merged: 16629,16631,16646,16740,16743,16757-16758,16769,16822
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 16629,16740,16758,16822
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs
r17097 r17100 69 69 #endregion 70 70 71 public Interval GetSymbolicEx ressionTreeInterval(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows = null) {71 public Interval GetSymbolicExpressionTreeInterval(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows = null) { 72 72 var variableRanges = DatasetUtil.GetVariableRanges(dataset, rows); 73 return GetSymbolicEx ressionTreeInterval(tree, variableRanges);74 } 75 76 public Interval GetSymbolicEx ressionTreeIntervals(ISymbolicExpressionTree tree, IDataset dataset,77 out Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals, IEnumerable<int> rows = null) {73 return GetSymbolicExpressionTreeInterval(tree, variableRanges); 74 } 75 76 public Interval GetSymbolicExpressionTreeIntervals(ISymbolicExpressionTree tree, IDataset dataset, 77 out IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals, IEnumerable<int> rows = null) { 78 78 var variableRanges = DatasetUtil.GetVariableRanges(dataset, rows); 79 return GetSymbolicEx ressionTreeIntervals(tree, variableRanges, out nodeIntervals);80 } 81 82 public Interval GetSymbolicEx ressionTreeInterval(ISymbolicExpressionTree tree,Dictionary<string, Interval> variableRanges) {79 return GetSymbolicExpressionTreeIntervals(tree, variableRanges, out nodeIntervals); 80 } 81 82 public Interval GetSymbolicExpressionTreeInterval(ISymbolicExpressionTree tree, IDictionary<string, Interval> variableRanges) { 83 83 lock (syncRoot) { 84 84 EvaluatedSolutions++; … … 88 88 var outputInterval = Evaluate(instructions, ref instructionCount); 89 89 90 return outputInterval; 91 } 92 93 94 public Interval GetSymbolicExressionTreeIntervals(ISymbolicExpressionTree tree, 95 Dictionary<string, Interval> variableRanges, out Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals) { 90 // because of numerical errors the bounds might be incorrect 91 if (outputInterval.LowerBound <= outputInterval.UpperBound) 92 return outputInterval; 93 else 94 return new Interval(outputInterval.UpperBound, outputInterval.LowerBound); 95 } 96 97 98 public Interval GetSymbolicExpressionTreeIntervals(ISymbolicExpressionTree tree, 99 IDictionary<string, Interval> variableRanges, out IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals) { 96 100 lock (syncRoot) { 97 101 EvaluatedSolutions++; … … 102 106 var outputInterval = Evaluate(instructions, ref instructionCount, intervals); 103 107 104 nodeIntervals = intervals; 105 106 return outputInterval; 107 } 108 109 110 private static Instruction[] PrepareInterpreterState(ISymbolicExpressionTree tree, Dictionary<string, Interval> variableRanges) { 108 // fix incorrect intervals if necessary (could occur because of numerical errors) 109 nodeIntervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>(); 110 foreach (var kvp in intervals) { 111 var interval = kvp.Value; 112 if (interval.IsInfiniteOrUndefined || interval.LowerBound <= interval.UpperBound) 113 nodeIntervals.Add(kvp.Key, interval); 114 else 115 nodeIntervals.Add(kvp.Key, new Interval(interval.UpperBound, interval.LowerBound)); 116 } 117 118 // because of numerical errors the bounds might be incorrect 119 if (outputInterval.IsInfiniteOrUndefined || outputInterval.LowerBound <= outputInterval.UpperBound) 120 return outputInterval; 121 else 122 return new Interval(outputInterval.UpperBound, outputInterval.LowerBound); 123 } 124 125 126 private static Instruction[] PrepareInterpreterState(ISymbolicExpressionTree tree, IDictionary<string, Interval> variableRanges) { 111 127 if (variableRanges == null) 112 128 throw new ArgumentNullException("No variablew ranges are present!", nameof(variableRanges)); … … 125 141 } 126 142 127 private Interval Evaluate(Instruction[] instructions, ref int instructionCounter, Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals = null) {143 private Interval Evaluate(Instruction[] instructions, ref int instructionCounter, IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals = null) { 128 144 Instruction currentInstr = instructions[instructionCounter]; 129 145 //Use ref parameter, because the tree will be iterated through recursively from the left-side branch to the right side … … 200 216 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals); 201 217 result = Interval.Tangens(argumentInterval); 218 break; 219 } 220 case OpCodes.Tanh: { 221 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals); 222 result = Interval.HyperbolicTangent(argumentInterval); 202 223 break; 203 224 }
Note: See TracChangeset
for help on using the changeset viewer.