Changeset 2053
- Timestamp:
- 06/17/09 13:49:05 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Core/3.3/DataSet.cs
r2047 r2053 47 47 public Problem Problem { 48 48 get { 49 // lazy loading of problem from DB50 if (problem == null) {51 var persistedData = Store.Query(52 "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.SerializedData.Uri + "> ?SerializedData .", 0, 10);53 if (persistedData.Count() == 1) {54 Literal persistedLiteral = (Literal)persistedData.First().Get("SerializedData");55 this.problem = (Problem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String((string)persistedLiteral.Value));56 } else57 this.problem = new Problem(); // no entry in the DB => create a new problem58 }59 49 return problem; 60 50 } … … 71 61 name = "Data set"; 72 62 activated = false; 63 problem = new Problem(); 73 64 } 74 65 … … 78 69 guid = new Guid(dataSetEntity.Uri.Remove(0, Ontology.CedmaNameSpace.Length)); 79 70 name = guid.ToString(); 71 var persistedData = Store.Query( 72 "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.SerializedData.Uri + "> ?SerializedData .", 0, 10); 73 if (persistedData.Count() == 1) { 74 Literal persistedLiteral = (Literal)persistedData.First().Get("SerializedData"); 75 problem = (Problem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String((string)persistedLiteral.Value)); 76 } else problem = new Problem(); 80 77 activated = true; 81 78 } … … 83 80 public void Activate() { 84 81 Entity myEntity = new Entity(Ontology.CedmaNameSpace + Guid); 85 Store.Add(new Statement(myEntity, Ontology.InstanceOf, Ontology.TypeDataSet)); 86 Store.Add(new Statement(myEntity, Ontology.SerializedData, new Literal(Convert.ToBase64String(PersistenceManager.SaveToGZip(problem))))); 87 Store.Add(new Statement(myEntity, Ontology.Name, new Literal(name))); 82 Store.AddRange( 83 new Statement[] { 84 new Statement(myEntity, Ontology.InstanceOf, Ontology.TypeDataSet), 85 new Statement(myEntity, Ontology.SerializedData, new Literal(Convert.ToBase64String(PersistenceManager.SaveToGZip(problem)))), 86 new Statement(myEntity, Ontology.Name, new Literal(name)) 87 }); 88 88 activated = true; 89 89 } -
trunk/sources/HeuristicLab.CEDMA.Core/3.3/StoreProxy.cs
r1858 r2053 76 76 } 77 77 78 public void AddRange(ICollection<Statement> statements) { 79 ExecuteSavely(() => { store.AddRange(statements); return 1.0; }); 80 } 81 78 82 public ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize) { 79 83 return ExecuteSavely(() => store.Query(query, page, pageSize)); -
trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/3.3/IStore.cs
r1529 r2053 35 35 36 36 [OperationContract] 37 void AddRange(ICollection<Statement> statements); 38 39 [OperationContract] 37 40 ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize); 38 41 -
trunk/sources/HeuristicLab.CEDMA.DB/3.3/Store.cs
r1529 r2053 61 61 } 62 62 63 public void AddRange(ICollection<Statement> statements) { 64 lock (bigLock) { 65 foreach (Statement s in statements) { 66 store.Add(Translate(s)); 67 } 68 } 69 } 70 63 71 64 72 public ICollection<VariableBindings> Query(string query, int page, int pageSize) { 65 MyQueryResultSink resultSink = new MyQueryResultSink(); 66 SemWeb.N3Reader n3Reader = new SemWeb.N3Reader(new StringReader(query)); 67 SemWeb.Query.GraphMatch matcher = new SemWeb.Query.GraphMatch(n3Reader); 68 matcher.Run(store, resultSink); 69 return resultSink.Bindings.Skip(page*pageSize).Take(pageSize).ToList(); 73 lock (bigLock) { 74 MyQueryResultSink resultSink = new MyQueryResultSink(); 75 SemWeb.N3Reader n3Reader = new SemWeb.N3Reader(new StringReader(query)); 76 SemWeb.Query.GraphMatch matcher = new SemWeb.Query.GraphMatch(n3Reader); 77 matcher.Run(store, resultSink); 78 return resultSink.Bindings.Skip(page * pageSize).Take(pageSize).ToList(); 79 } 70 80 } 71 81 72 82 public ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize) { 73 MyQueryResultSink resultSink = new MyQueryResultSink(); 74 Translate(query).Run(store, resultSink); 75 return resultSink.Bindings.Skip(page * pageSize).Take(pageSize).ToList(); 83 lock (bigLock) { 84 MyQueryResultSink resultSink = new MyQueryResultSink(); 85 Translate(query).Run(store, resultSink); 86 return resultSink.Bindings.Skip(page * pageSize).Take(pageSize).ToList(); 87 } 76 88 } 77 89 -
trunk/sources/HeuristicLab.CEDMA.Server/3.3/ExecuterBase.cs
r2048 r2053 71 71 protected void StoreResults(IAlgorithm finishedAlgorithm) { 72 72 Entity modelEntity = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid()); 73 store.Add(new Statement(modelEntity, Ontology.InstanceOf, Ontology.TypeModel)); 74 StoreEntityAttribute(modelEntity, Ontology.TargetVariable, finishedAlgorithm.Model.TargetVariable); 75 StoreEntityAttribute(modelEntity, Ontology.Name, finishedAlgorithm.Description); 73 List<Statement> statements = new List<Statement>(); 74 statements.Add(new Statement(modelEntity, Ontology.InstanceOf, Ontology.TypeModel)); 75 statements.Add(new Statement(modelEntity, Ontology.TargetVariable, new Literal(finishedAlgorithm.Model.TargetVariable))); 76 statements.Add(new Statement(modelEntity, Ontology.Name, new Literal(finishedAlgorithm.Description))); 76 77 77 78 IModel model = finishedAlgorithm.Model; 78 StoreEntityAttribute(modelEntity, Ontology.TrainingMeanSquaredError, model.TrainingMeanSquaredError);79 StoreEntityAttribute(modelEntity, Ontology.ValidationMeanSquaredError, model.ValidationMeanSquaredError);80 StoreEntityAttribute(modelEntity, Ontology.TestMeanSquaredError, model.TestMeanSquaredError);81 StoreEntityAttribute(modelEntity, Ontology.TrainingCoefficientOfDetermination, model.TrainingCoefficientOfDetermination);82 StoreEntityAttribute(modelEntity, Ontology.ValidationCoefficientOfDetermination, model.ValidationCoefficientOfDetermination);83 StoreEntityAttribute(modelEntity, Ontology.TestCoefficientOfDetermination, model.TestCoefficientOfDetermination);84 StoreEntityAttribute(modelEntity, Ontology.TrainingVarianceAccountedFor, model.TrainingVarianceAccountedFor);85 StoreEntityAttribute(modelEntity, Ontology.ValidationVarianceAccountedFor, model.ValidationVarianceAccountedFor);86 StoreEntityAttribute(modelEntity, Ontology.TestVarianceAccountedFor, model.TestVarianceAccountedFor);87 StoreEntityAttribute(modelEntity, Ontology.TrainingMeanAbsolutePercentageError, model.TrainingMeanAbsolutePercentageError);88 StoreEntityAttribute(modelEntity, Ontology.ValidationMeanAbsolutePercentageError, model.ValidationMeanAbsolutePercentageError);89 StoreEntityAttribute(modelEntity, Ontology.TestMeanAbsolutePercentageError, model.TestMeanAbsolutePercentageError);90 StoreEntityAttribute(modelEntity, Ontology.TrainingMeanAbsolutePercentageOfRangeError, model.TrainingMeanAbsolutePercentageOfRangeError);91 StoreEntityAttribute(modelEntity, Ontology.ValidationMeanAbsolutePercentageOfRangeError, model.ValidationMeanAbsolutePercentageOfRangeError);92 StoreEntityAttribute(modelEntity, Ontology.TestMeanAbsolutePercentageOfRangeError, model.TestMeanAbsolutePercentageOfRangeError);79 statements.Add(new Statement(modelEntity, Ontology.TrainingMeanSquaredError, new Literal(model.TrainingMeanSquaredError))); 80 statements.Add(new Statement(modelEntity, Ontology.ValidationMeanSquaredError, new Literal(model.ValidationMeanSquaredError))); 81 statements.Add(new Statement(modelEntity, Ontology.TestMeanSquaredError, new Literal(model.TestMeanSquaredError))); 82 statements.Add(new Statement(modelEntity, Ontology.TrainingCoefficientOfDetermination, new Literal(model.TrainingCoefficientOfDetermination))); 83 statements.Add(new Statement(modelEntity, Ontology.ValidationCoefficientOfDetermination, new Literal(model.ValidationCoefficientOfDetermination))); 84 statements.Add(new Statement(modelEntity, Ontology.TestCoefficientOfDetermination, new Literal(model.TestCoefficientOfDetermination))); 85 statements.Add(new Statement(modelEntity, Ontology.TrainingVarianceAccountedFor, new Literal(model.TrainingVarianceAccountedFor))); 86 statements.Add(new Statement(modelEntity, Ontology.ValidationVarianceAccountedFor, new Literal(model.ValidationVarianceAccountedFor))); 87 statements.Add(new Statement(modelEntity, Ontology.TestVarianceAccountedFor, new Literal(model.TestVarianceAccountedFor))); 88 statements.Add(new Statement(modelEntity, Ontology.TrainingMeanAbsolutePercentageError, new Literal(model.TrainingMeanAbsolutePercentageError))); 89 statements.Add(new Statement(modelEntity, Ontology.ValidationMeanAbsolutePercentageError, new Literal(model.ValidationMeanAbsolutePercentageError))); 90 statements.Add(new Statement(modelEntity, Ontology.TestMeanAbsolutePercentageError, new Literal(model.TestMeanAbsolutePercentageError))); 91 statements.Add(new Statement(modelEntity, Ontology.TrainingMeanAbsolutePercentageOfRangeError, new Literal(model.TrainingMeanAbsolutePercentageOfRangeError))); 92 statements.Add(new Statement(modelEntity, Ontology.ValidationMeanAbsolutePercentageOfRangeError, new Literal(model.ValidationMeanAbsolutePercentageOfRangeError))); 93 statements.Add(new Statement(modelEntity, Ontology.TestMeanAbsolutePercentageOfRangeError, new Literal(model.TestMeanAbsolutePercentageOfRangeError))); 93 94 94 95 for (int i = 0; i < finishedAlgorithm.Dataset.Columns; i++) { … … 99 100 100 101 Entity inputVariableEntity = new Entity(Ontology.CedmaNameSpace + Guid.NewGuid()); 101 st ore.Add(new Statement(inputVariableEntity, Ontology.InstanceOf, Ontology.TypeVariableImpact));102 st ore.Add(new Statement(modelEntity, Ontology.HasInputVariable, inputVariableEntity));103 StoreEntityAttribute(inputVariableEntity, Ontology.EvaluationImpact, evalImpact);104 StoreEntityAttribute(inputVariableEntity, Ontology.QualityImpact, qualImpact);105 StoreEntityAttribute(inputVariableEntity, Ontology.Name, variableName);102 statements.Add(new Statement(inputVariableEntity, Ontology.InstanceOf, Ontology.TypeVariableImpact)); 103 statements.Add(new Statement(modelEntity, Ontology.HasInputVariable, inputVariableEntity)); 104 statements.Add(new Statement(inputVariableEntity, Ontology.EvaluationImpact, new Literal(evalImpact))); 105 statements.Add(new Statement(inputVariableEntity, Ontology.QualityImpact, new Literal(qualImpact))); 106 statements.Add(new Statement(inputVariableEntity, Ontology.Name, new Literal(variableName))); 106 107 } 107 108 catch (ArgumentException) { … … 111 112 112 113 byte[] serializedModel = PersistenceManager.SaveToGZip(model.Data); 113 store.Add(new Statement(modelEntity, Ontology.SerializedData, new Literal(Convert.ToBase64String(serializedModel)))); 114 } 115 116 private void StoreEntityAttribute(Entity entity, Entity predicate, object value) { 117 store.Add(new Statement(entity, predicate, new Literal(value))); 114 statements.Add(new Statement(modelEntity, Ontology.SerializedData, new Literal(Convert.ToBase64String(serializedModel)))); 115 store.AddRange(statements); 118 116 } 119 117 -
trunk/sources/HeuristicLab.CEDMA.Server/3.3/GridExecuter.cs
r2012 r2053 94 94 activeOperations.Remove(readyHandle); 95 95 readyHandle.Close(); 96 ProcessingEngine finishedEngine = null;97 96 try { 98 finishedEngine = jobManager.EndExecuteOperation(finishedOp); 97 ProcessingEngine finishedEngine = jobManager.EndExecuteOperation(finishedOp); 98 StoreResults(finishedAlgorithm); 99 99 } 100 100 catch (Exception badEx) { 101 101 Trace.WriteLine("CEDMA Executer: Exception in job execution thread. " + badEx.Message); 102 }103 if (finishedEngine != null) {104 StoreResults(finishedAlgorithm);105 102 } 106 103 }
Note: See TracChangeset
for help on using the changeset viewer.