Changeset 2131
- Timestamp:
- 07/03/09 15:56:05 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Charting/3.3/BubbleChart.cs
r2047 r2131 31 31 using HeuristicLab.Core; 32 32 using HeuristicLab.CEDMA.DB.Interfaces; 33 using System.Diagnostics; 33 34 34 35 namespace HeuristicLab.CEDMA.Charting { … … 58 59 private Results results; 59 60 private Dictionary<IPrimitive, ResultsEntry> primitiveToEntryDictionary; 60 private Dictionary<ResultsEntry, IPrimitive> entryToPrimitiveDictionary;61 //private Dictionary<ResultsEntry, IList<IPrimitive>> entryToPrimitivesDictionary; 61 62 private Random random = new Random(); 62 63 private Group points; … … 66 67 records = new List<ResultsEntry>(); 67 68 primitiveToEntryDictionary = new Dictionary<IPrimitive, ResultsEntry>(); 68 entryToPrimitiveDictionary = new Dictionary<ResultsEntry, IPrimitive>();69 // entryToPrimitivesDictionary = new Dictionary<ResultsEntry, IList<IPrimitive>>(); 69 70 this.results = results; 70 71 … … 132 133 Group.Clear(); 133 134 primitiveToEntryDictionary.Clear(); 134 entryToPrimitiveDictionary.Clear();135 // entryToPrimitivesDictionary.Clear(); 135 136 points = new Group(this); 136 137 Group.Add(new Axis(this, 0, 0, AxisType.Both)); 137 138 UpdateViewSize(0, 0, 5); 138 139 foreach (ResultsEntry r in records) { 139 double x, y; 140 List<double> xs = new List<double>(); 141 List<double> ys = new List<double>(); 140 142 int size; 141 143 if (results.OrdinalVariables.Contains(xDimension)) { 142 x = Convert.ToDouble(r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor;144 xs.Add(Convert.ToDouble(r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor); 143 145 } else if (results.CategoricalVariables.Contains(xDimension)) { 144 x = results.IndexOfCategoricalValue(xDimension, r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor; 146 xs.Add(results.IndexOfCategoricalValue(xDimension, r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor); 147 } else if (results.MultiDimensionalCategoricalVariables.Contains(xDimension)) { 148 var path = xDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()); 149 IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0)); 150 foreach (ResultsEntry subEntry in subEntries) { 151 xs.Add(results.IndexOfCategoricalValue(xDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor); 152 } 153 } else if (results.MultiDimensionalOrdinalVariables.Contains(xDimension)) { 154 var path = xDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()); 155 IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0)); 156 foreach (ResultsEntry subEntry in subEntries) { 157 xs.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor); 158 } 145 159 } else { 146 x = double.NaN;160 xs.Add(double.NaN); 147 161 } 148 162 if (results.OrdinalVariables.Contains(yDimension)) { 149 y = Convert.ToDouble(r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor;163 ys.Add(Convert.ToDouble(r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor); 150 164 } else if (results.CategoricalVariables.Contains(yDimension)) { 151 y = results.IndexOfCategoricalValue(yDimension, r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor; 165 ys.Add(results.IndexOfCategoricalValue(yDimension, r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor); 166 } else if (results.MultiDimensionalCategoricalVariables.Contains(yDimension)) { 167 var path = yDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()); 168 IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0)); 169 foreach (ResultsEntry subEntry in subEntries) { 170 ys.Add(results.IndexOfCategoricalValue(yDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor); 171 } 172 } else if (results.MultiDimensionalOrdinalVariables.Contains(yDimension)) { 173 var path = yDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()); 174 IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0)); 175 foreach (ResultsEntry subEntry in subEntries) { 176 ys.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor); 177 } 152 178 } else { 153 y = double.NaN;179 ys.Add(double.NaN); 154 180 } 155 181 size = CalculateSize(Convert.ToDouble(r.Get(sizeDimension)), minSize, maxSize); 156 157 if (double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN; 158 if (double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN; 159 if (!double.IsNaN(x) && !double.IsNaN(y)) { 160 UpdateViewSize(x, y, size); 161 int alpha = CalculateAlpha(size); 162 Pen pen = new Pen(Color.FromArgb(alpha, r.Selected ? selectionColor : defaultColor)); 163 Brush brush = pen.Brush; 164 FixedSizeCircle c = new FixedSizeCircle(this, x, y, size, pen, brush); 165 c.ToolTipText = r.GetToolTipText(); 166 points.Add(c); 167 if (!r.Selected) c.IntoBackground(); 168 primitiveToEntryDictionary[c] = r; 169 entryToPrimitiveDictionary[r] = c; 182 Debug.Assert(xs.Count() == ys.Count() || xs.Count() == 1 || ys.Count() == 1); 183 int n = Math.Max(xs.Count(), ys.Count()); 184 for (int i = 0; i < n; i++) { 185 double x = xs[Math.Min(i, xs.Count()-1)]; 186 double y = ys[Math.Min(i, ys.Count()-1)]; 187 if (double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN; 188 if (double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN; 189 if (!double.IsNaN(x) && !double.IsNaN(y)) { 190 UpdateViewSize(x, y, size); 191 int alpha = CalculateAlpha(size); 192 Pen pen = new Pen(Color.FromArgb(alpha, r.Selected ? selectionColor : defaultColor)); 193 Brush brush = pen.Brush; 194 FixedSizeCircle c = new FixedSizeCircle(this, x, y, size, pen, brush); 195 c.ToolTipText = r.GetToolTipText(); 196 points.Add(c); 197 if (!r.Selected) c.IntoBackground(); 198 primitiveToEntryDictionary[c] = r; 199 //if (!entryToPrimitivesDictionary.ContainsKey(r)) entryToPrimitivesDictionary[r] = new List<IPrimitive>(); 200 //entryToPrimitivesDictionary[r].Add(c); 201 } 170 202 } 171 203 } -
trunk/sources/HeuristicLab.CEDMA.Charting/3.3/BubbleChartView.cs
r1529 r2131 40 40 xAxisComboBox.Items.AddRange(Results.OrdinalVariables); 41 41 xAxisComboBox.Items.AddRange(Results.CategoricalVariables); 42 xAxisComboBox.Items.AddRange(Results.MultiDimensionalCategoricalVariables); 43 xAxisComboBox.Items.AddRange(Results.MultiDimensionalOrdinalVariables); 42 44 yAxisComboBox.Items.AddRange(Results.OrdinalVariables); 43 45 yAxisComboBox.Items.AddRange(Results.CategoricalVariables); 46 yAxisComboBox.Items.AddRange(Results.MultiDimensionalCategoricalVariables); 47 yAxisComboBox.Items.AddRange(Results.MultiDimensionalOrdinalVariables); 44 48 sizeComboBox.Items.Add(CONSTANT_SIZE); 45 49 sizeComboBox.Items.AddRange(Results.OrdinalVariables); -
trunk/sources/HeuristicLab.CEDMA.Core/3.3/DataSetView.cs
r2000 r2131 60 60 if (dataSet.Activated) { 61 61 activateButton.Enabled = false; 62 editorGroupBox.Enabled = false;62 editorGroupBox.Enabled = true; 63 63 viewComboBox.Enabled = true; 64 64 resultsButton.Enabled = true; -
trunk/sources/HeuristicLab.CEDMA.Core/3.3/Results.cs
r2081 r2131 58 58 } 59 59 60 private string[] multiDimensionalOrdinalVariables = new string[] { "VariableImpacts: EvaluationImpact", "VariableImpacts: QualityImpact" }; 61 public string[] MultiDimensionalOrdinalVariables { 62 get { return multiDimensionalOrdinalVariables; } 63 } 64 65 private string[] multiDimensionalCategoricalVariables = new string[] { "VariableImpacts: InputVariableName" }; 66 public string[] MultiDimensionalCategoricalVariables { 67 get { return multiDimensionalCategoricalVariables; } 68 } 69 60 70 private IStore store; 61 71 public IStore Store { … … 87 97 entries = new List<ResultsEntry>(); 88 98 do { 89 var allBindings = store.Query("?Model <" + Ontology.InstanceOf + "> <" + Ontology.TypeModel + "> ." + Environment.NewLine + 90 "?Model ?Attribute ?Value .", page, PAGE_SIZE); 99 var allBindings = store.Query( 100 "?Model <" + Ontology.InstanceOf + "> <" + Ontology.TypeModel + "> ." + 101 "?Model ?Attribute ?Value .", 102 page, PAGE_SIZE); 91 103 var allModelBindings = allBindings.GroupBy(x => (Entity)x.Get("Model")); 92 104 resultsReturned = allBindings.Count; … … 100 112 entries.Add(entry); 101 113 newEntry = true; 114 entry.Set("VariableImpacts", SelectVariableImpacts(entry.Uri)); 102 115 } 103 116 foreach (var binding in modelBindings) { … … 117 130 FireChanged(); 118 131 cached = true; 132 } 133 134 private IEnumerable<ResultsEntry> SelectVariableImpacts(string modelUri) { 135 var allBindings = store.Query( 136 "<" + modelUri + "> <" + Ontology.HasInputVariable + "> ?InputVariable ." + 137 "?InputVariable <" + Ontology.Name + "> ?InputName ." + 138 "?InputVariable <" + Ontology.QualityImpact + "> ?QualityImpact ." + 139 "?InputVariable <" + Ontology.EvaluationImpact + "> ?EvaluationImpact .", 140 0, PAGE_SIZE); 141 var allInputVariableBindings = allBindings.GroupBy(x => (Entity)x.Get("InputVariable")); 142 List<ResultsEntry> variableImpacts = new List<ResultsEntry>(); 143 144 foreach (var inputVariableBinding in allInputVariableBindings) { 145 ResultsEntry entry = new ResultsEntry(); 146 VariableBindings binding = inputVariableBinding.First(); 147 double evaluationImpact = (double)((Literal)binding.Get("EvaluationImpact")).Value; 148 double qualityImpact = (double)((Literal)binding.Get("QualityImpact")).Value; 149 if (binding.Get("InputName") != null) entry.Set("InputVariableName", ((Literal)binding.Get("InputName")).Value); 150 if (binding.Get("QualityImpact") != null) entry.Set("QualityImpact", qualityImpact); 151 if (binding.Get("EvaluationImpact") != null) entry.Set("EvaluationImpact", evaluationImpact); 152 if (!IsAlmost(evaluationImpact, 0.0) && !IsAlmost(qualityImpact, 1.0)) { 153 variableImpacts.Add(entry); 154 } 155 } 156 return variableImpacts; 157 } 158 159 private bool IsAlmost(double x, double y) { 160 return (y + 1.0E-7 > x) && (y - 1.0E-7 < x); 119 161 } 120 162
Note: See TracChangeset
for help on using the changeset viewer.