Changeset 16313
- Timestamp:
- 11/21/18 10:27:55 (6 years ago)
- Location:
- branches/2956_apriori_knowledge
- Files:
-
- 3 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 -
branches/2956_apriori_knowledge/HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration/3.4/Plugin.cs
r16303 r16313 29 29 namespace HeuristicLab.Algorithms.DataAnalysis.IntervalArithmetic 30 30 { 31 [Plugin("HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntergration", "3.4.0. 0")]31 [Plugin("HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntergration", "3.4.0.16303")] 32 32 [PluginFile("HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration-3.4.dll", PluginFileType.Assembly)] 33 33 public class Plugin : PluginBase{ -
branches/2956_apriori_knowledge/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r16303 r16313 34 34 using HeuristicLab.MainForm; 35 35 using HeuristicLab.MainForm.WindowsForms; 36 using System.Globalization; 36 37 37 38 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { … … 193 194 var interpreter = new SymbolicDataAnalysisIntervalArithmeticInterpreter(); 194 195 195 //var intervalParam = ((IRegressionProblemData)Content.ProblemData).IntervalVariable; 196 //Get the Variable Ranges and add it to the dictionary 197 var intervalParameters = ((IRegressionProblemData)Content.ProblemData).VariableRanges; 196 198 var customIntervals = new Dictionary<String, Interval>(); 197 var parser = new FormulationParser(); 198 //foreach (var ci in intervalParam) { 199 //var inter = parser.Parse(ci.Formulation.GetValue()); 200 //customIntervals.Add(ci.Variable.GetValue(), new Interval(0, 1)); 201 //} 202 var resultInterval = interpreter.GetSymbolicExressionTreeIntervals(tree, Content.ProblemData.Dataset, Content.ProblemData.TrainingIndices, out intervals); 199 for (int x = 0; x < intervalParameters.Rows; ++x) { 200 customIntervals.Add(intervalParameters.RowNames.ElementAt(x), 201 new Interval(intervalParameters.GetRow(x).ElementAt(0), 202 intervalParameters.GetRow(x).ElementAt(1))); 203 } 204 205 var resultInterval = interpreter.GetSymbolicExressionTreeIntervals(tree, Content.ProblemData.Dataset, Content.ProblemData.TrainingIndices, customIntervals, out intervals); 203 206 await Task.Delay(500); // wait for progressbar to finish animation 204 207 var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2); … … 206 209 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 207 210 } 208 //Instruction currentInstr = instructions.NextInstruction(); 209 //while (instructions.HasNextInstruction()) { 210 // //intervals[currentInstr.dynamicNode] = (Interval)currentInstr.data; 211 // intervals.Add(Tuple.Create(currentInstr.dynamicNode, (Interval)currentInstr.data)); 212 // currentInstr = instructions.NextInstruction(); 213 //} 214 215 216 217 //intervals.Add(Tuple.Create(currentInstr.dynamicNode, (Interval)currentInstr.data)); 211 218 212 nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); 219 213 progress.Finish(); 220 214 PaintIntervals(); 221 //PaintNodeImpacts();222 215 } 223 216 … … 291 284 if (visualTree != null) { 292 285 visualTree.ToolTip = visualTree.Content.ToString(); 293 //visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{intervals[node].Item2.LowerBound:E4} ... {intervals[node].Item2.UpperBound:E4}]{Environment.NewLine}"); 294 visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{intervals[treeNode].LowerBound:E4} ... {intervals[treeNode].UpperBound:E4}]{Environment.NewLine}]"); 286 visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{intervals[treeNode].LowerBound:G5} ... {intervals[treeNode].UpperBound:G5}]{Environment.NewLine}"); 295 287 node++; 296 288 … … 309 301 visualTree.FillColor = Color.FromArgb((int)(impact / max * 255), Color.Green); 310 302 } 311 visualTree.ToolTip += String.Format($" {Environment.NewLine} Node impact: {impact:E4}");303 visualTree.ToolTip += String.Format($"Node impact: {impact:G5}"); 312 304 var constantReplacementNode = foldedNodes[treeNode] as ConstantTreeNode; 313 305 if (constantReplacementNode != null) { 314 visualTree.ToolTip += String.Format($"{Environment.NewLine} Replacement value: {constantReplacementNode.Value:E4}");306 visualTree.ToolTip += String.Format($"{Environment.NewLine}Replacement value: {constantReplacementNode.Value:G5}"); 315 307 } 316 308 }
Note: See TracChangeset
for help on using the changeset viewer.