Changeset 2137 for trunk/sources
- Timestamp:
- 07/06/09 19:52:06 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Charting/3.3/BubbleChart.cs
r2135 r2137 201 201 double x = xs[Math.Min(i, xs.Count() - 1)]; 202 202 double y = ys[Math.Min(i, ys.Count() - 1)]; 203 string actualXValue = actualXValues[Math.Min(i, actualXValues.Count() - 1)].ToString();204 string actualYValue = actualYValues[Math.Min(i, actualYValues.Count() - 1)].ToString();205 203 if (double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN; 206 204 if (double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN; 207 205 if (!double.IsNaN(x) && !double.IsNaN(y)) { 206 string actualXValue = actualXValues[Math.Min(i, actualXValues.Count() - 1)].ToString(); 207 string actualYValue = actualYValues[Math.Min(i, actualYValues.Count() - 1)].ToString(); 208 208 UpdateViewSize(x, y, size); 209 209 int alpha = CalculateAlpha(size); -
trunk/sources/HeuristicLab.CEDMA.Core/3.3/Results.cs
r2131 r2137 90 90 } 91 91 92 long nStatements; 93 DateTime start, stop; 92 94 private IEnumerable<ResultsEntry> SelectRows() { 95 start = DateTime.Now; 96 nStatements = 0; 93 97 int page = 0; 94 98 int resultsReturned = 0; 95 bool newEntry = false;96 if (store == null) yield break;97 99 entries = new List<ResultsEntry>(); 100 if (store == null) return entries; 98 101 do { 99 var all Bindings = store.Query(102 var allModels = store.Query( 100 103 "?Model <" + Ontology.InstanceOf + "> <" + Ontology.TypeModel + "> ." + 101 "?Model ?Attribute ?Value .", 102 page, PAGE_SIZE); 103 var allModelBindings = allBindings.GroupBy(x => (Entity)x.Get("Model")); 104 resultsReturned = allBindings.Count; 105 106 foreach (var modelBindings in allModelBindings) { 107 ResultsEntry entry = entries.FirstOrDefault(x => x.Uri == modelBindings.Key.Uri); 108 newEntry = false; 109 if (entry == null) { 110 entry = new ResultsEntry(); 111 entry.Uri = modelBindings.Key.Uri; 104 "?Model <" + Ontology.TargetVariable + "> ?TargetVariable ." + 105 "?Model <" + Ontology.TestMeanSquaredError + "> ?TestMSE .", 106 0, 3000) 107 .Select(modelBinding => new { 108 Model = ((Entity)modelBinding.Get("Model")).Uri, 109 TestMSE = (double)((Literal)modelBinding.Get("TestMSE")).Value, 110 TargetVariable = (string)((Literal)modelBinding.Get("TargetVariable")).Value 111 }) 112 .Distinct() 113 .GroupBy(m => m.TargetVariable) 114 .Select(grouping => grouping.OrderBy(m => m.TestMSE)); 115 foreach (var targetVariableBindings in allModels) { 116 resultsReturned = targetVariableBindings.Count(); 117 nStatements += resultsReturned; 118 int nModels = Math.Max(10, resultsReturned * 10 / 100); 119 foreach (var modelBindings in targetVariableBindings.Take(nModels)) { 120 ResultsEntry entry = new ResultsEntry(); 121 entry.Uri = modelBindings.Model; 112 122 entries.Add(entry); 113 newEntry = true;114 entry.Set("VariableImpacts", SelectVariableImpacts( entry.Uri));123 SetModelAttributes(entry, modelBindings.Model); 124 entry.Set("VariableImpacts", SelectVariableImpacts(modelBindings.Model)); 115 125 } 116 foreach (var binding in modelBindings) {117 if (binding.Get("Value") is Literal) {118 string name = ((Entity)binding.Get("Attribute")).Uri.Replace(Ontology.CedmaNameSpace, "");119 if (entry.Get(name) == null) {120 object value = ((Literal)binding.Get("Value")).Value;121 entry.Set(name, value);122 }123 }124 }125 if (newEntry) yield return entry;126 126 } 127 127 page++; 128 128 } while (resultsReturned == PAGE_SIZE); 129 129 stop = DateTime.Now; 130 130 FireChanged(); 131 131 cached = true; 132 return entries; 133 } 134 135 private void SetModelAttributes(ResultsEntry entry, string modelUri) { 136 var modelBindings = store.Query( 137 "<" + modelUri + "> ?Attribute ?Value .", 138 0, PAGE_SIZE); 139 nStatements += modelBindings.Count(); 140 foreach (var binding in modelBindings) { 141 if (binding.Get("Value") is Literal) { 142 string name = ((Entity)binding.Get("Attribute")).Uri.Replace(Ontology.CedmaNameSpace, ""); 143 if (entry.Get(name) == null) { 144 object value = ((Literal)binding.Get("Value")).Value; 145 entry.Set(name, value); 146 } 147 } 148 } 132 149 } 133 150 134 151 private IEnumerable<ResultsEntry> SelectVariableImpacts(string modelUri) { 135 var allBindings = store.Query(152 var inputVariableNameBindings = store.Query( 136 153 "<" + modelUri + "> <" + Ontology.HasInputVariable + "> ?InputVariable ." + 137 "?InputVariable <" + Ontology.Name + "> ?InputName ." + 138 "?InputVariable <" + Ontology.QualityImpact + "> ?QualityImpact ." + 139 "?InputVariable <" + Ontology.EvaluationImpact + "> ?EvaluationImpact .", 154 "?InputVariable <" + Ontology.Name + "> ?InputName .", 140 155 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; 156 157 var qualityImpactBindings = store.Query( 158 "<" + modelUri + "> <" + Ontology.HasInputVariable + "> ?InputVariable ." + 159 "?InputVariable <" + Ontology.QualityImpact + "> ?QualityImpact .", 160 0, PAGE_SIZE); 161 162 var evaluationImpactBindings = store.Query( 163 "<" + modelUri + "> <" + Ontology.HasInputVariable + "> ?InputVariable ." + 164 "?InputVariable <" + Ontology.EvaluationImpact + "> ?EvaluationImpact .", 165 0, PAGE_SIZE); 166 Dictionary<object, ResultsEntry> inputVariableAttributes = new Dictionary<object, ResultsEntry>(); 167 nStatements += inputVariableNameBindings.Count(); 168 nStatements += qualityImpactBindings.Count(); 169 nStatements += evaluationImpactBindings.Count(); 170 171 foreach (var inputVariableNameBinding in inputVariableNameBindings) { 172 object inputVariable = inputVariableNameBinding.Get("InputVariable"); 173 object name = ((Literal)inputVariableNameBinding.Get("InputName")).Value; 174 if (!inputVariableAttributes.ContainsKey(inputVariable)) { 175 inputVariableAttributes[inputVariable] = new ResultsEntry(); 176 inputVariableAttributes[inputVariable].Set("InputVariableName", name); 177 } 178 } 179 180 foreach (var qualityImpactBinding in qualityImpactBindings) { 181 double qualityImpact = (double)((Literal)qualityImpactBinding.Get("QualityImpact")).Value; 182 object inputVariable = qualityImpactBinding.Get("InputVariable"); 183 if (!IsAlmost(qualityImpact, 1.0)) { 184 if (inputVariableAttributes[inputVariable].Get("QualityImpact") == null) 185 inputVariableAttributes[inputVariable].Set("QualityImpact", qualityImpact); 186 } else inputVariableAttributes.Remove(inputVariable); 187 } 188 189 foreach (var evaluationImpactBinding in evaluationImpactBindings) { 190 double evaluationImpact = (double)((Literal)evaluationImpactBinding.Get("EvaluationImpact")).Value; 191 object inputVariable = evaluationImpactBinding.Get("InputVariable"); 192 if (!IsAlmost(evaluationImpact, 0.0)) { 193 if (inputVariableAttributes.ContainsKey(inputVariable) && inputVariableAttributes[inputVariable].Get("EvaluationImpact") == null) 194 inputVariableAttributes[inputVariable].Set("EvaluationImpact", evaluationImpact); 195 } else inputVariableAttributes.Remove(inputVariable); 196 } 197 198 return inputVariableAttributes.Values; 157 199 } 158 200 159 201 private bool IsAlmost(double x, double y) { 160 return (y + 1.0E-7 > x) && (y - 1.0E-7 < x);202 return Math.Abs(x - y) < 1.0E-12; 161 203 } 162 204 -
trunk/sources/HeuristicLab.CEDMA.DB/3.3/Store.cs
r2053 r2137 75 75 SemWeb.N3Reader n3Reader = new SemWeb.N3Reader(new StringReader(query)); 76 76 SemWeb.Query.GraphMatch matcher = new SemWeb.Query.GraphMatch(n3Reader); 77 matcher.Run(store, resultSink); 77 if (memStore == null) { 78 CacheStore(); 79 } 80 matcher.Run(memStore, resultSink); 78 81 return resultSink.Bindings.Skip(page * pageSize).Take(pageSize).ToList(); 79 82 } 80 83 } 81 84 85 SemWeb.Store memStore; 86 private void CacheStore() { 87 memStore = new SemWeb.MemoryStore(); 88 memStore.Import(store); 89 } 90 82 91 public ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize) { 83 92 lock (bigLock) { 84 93 MyQueryResultSink resultSink = new MyQueryResultSink(); 85 Translate(query).Run(store, resultSink); 94 if (memStore == null) { 95 CacheStore(); 96 } 97 Translate(query).Run(memStore, resultSink); 86 98 return resultSink.Bindings.Skip(page * pageSize).Take(pageSize).ToList(); 87 99 }
Note: See TracChangeset
for help on using the changeset viewer.