Changeset 16313 for branches/2956_apriori_knowledge/HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration/3.4/Interpreter
- Timestamp:
- 11/21/18 10:27:55 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2956_apriori_knowledge/HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration/3.4/Interpreter/SymbolicDataAnalysisIntervalArithmeticInterpreter.cs
r16303 r16313 42 42 private readonly object syncRoot = new object(); 43 43 44 private static InterpreterState PrepareInterpreterState(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows, Dictionary<string, Interval> customIntervals = null) { 44 private static InterpreterState PrepareInterpreterState(ISymbolicExpressionTree tree, 45 IEnumerable<int> rows, IDataset dataset = null, Dictionary<string, Interval> customIntervals = null) { 45 46 Instruction[] code = SymbolicExpressionTreeCompiler.Compile(tree, OpCodes.MapSymbolToOpCode); 46 47 int necessaryArgStackSize = 0; … … 51 52 IList<double> values = new List<double>(); 52 53 53 if (customIntervals != null && customIntervals.ContainsKey(variableTreeNode.VariableName)) { 54 instr.data = customIntervals[variableTreeNode.VariableName]; 54 if (dataset != null && customIntervals != null) { 55 if (customIntervals.ContainsKey(variableTreeNode.VariableName)) { 56 instr.data = customIntervals[variableTreeNode.VariableName]; 57 } else { 58 foreach (var rowEnum in rows) { 59 values.Add(dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName)[rowEnum]); 60 } 61 instr.data = new Interval(values.Min(), values.Max()); 62 } 63 } else if (dataset != null) { 64 foreach (var rowEnum in rows) { 65 values.Add(dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName)[rowEnum]); 66 } 67 instr.data = new Interval(values.Min(), values.Max()); 68 } else if (customIntervals != null) { 69 if (customIntervals.ContainsKey(variableTreeNode.VariableName)) { 70 instr.data = customIntervals[variableTreeNode.VariableName]; 71 } 55 72 } else { 56 foreach (var rowEnum in rows) { 57 values.Add(dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName)[rowEnum]); 58 } 59 instr.data = new Interval(values.Min(), values.Max()); 73 throw new Exception("No valid input for variables!"); 60 74 } 61 75 } … … 204 218 // var x = Evaluate(dataset, state); 205 219 // state.Reset(); 206 220 207 221 // return state; 208 222 //} 209 223 210 // public Interval GetSymbolicExressionTreeInterval(tree,variableIntervals)224 // public Interval GetSymbolicExressionTreeInterval(tree,variableIntervals) 211 225 //public Interval GetSymbolicExressionTreeInterval(tree,Dataset,intervals = null) 226 227 public Interval GetSymbolicExressionTreeIntervals(ISymbolicExpressionTree tree, IEnumerable<int> rows, out Dictionary<ISymbolicExpressionTreeNode, Interval> intervals) { 228 intervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>(); 229 var state = PrepareInterpreterState(tree, rows); 230 var x = Evaluate(state, intervals); 231 232 return x; 233 } 234 235 public Interval GetSymbolicExressionTreeIntervals(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows, 236 Dictionary<string, Interval> customIntervals, out Dictionary<ISymbolicExpressionTreeNode, Interval> intervals) { 237 intervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>(); 238 var state = PrepareInterpreterState(tree, rows, dataset, customIntervals); 239 var x = Evaluate(state, intervals); 240 241 return x; 242 } 243 212 244 public Interval GetSymbolicExressionTreeIntervals(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows, 213 245 out Dictionary<ISymbolicExpressionTreeNode, Interval> intervals) { 214 246 intervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>(); 215 var state = PrepareInterpreterState(tree, dataset, rows);247 var state = PrepareInterpreterState(tree, rows, dataset); 216 248 var x = Evaluate(state, intervals); 217 249
Note: See TracChangeset
for help on using the changeset viewer.