Changeset 2217
- Timestamp:
- 07/31/09 12:11:41 (15 years ago)
- Location:
- branches/HeuristicLab.Modeling Database Backend/sources
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Core/3.3/Results.cs
r2208 r2217 85 85 86 86 private IEnumerable<ResultsEntry> SelectRows() { 87 database.GetAllModelResults(); 87 88 entries = new List<ResultsEntry>(); 88 89 foreach (var model in database.GetAllModels()) { … … 91 92 modelEntry.Set(modelResult.Result.Name, modelResult.Value); 92 93 } 93 modelEntry.Set("PersistedData", model.Data);94 modelEntry.Set("PersistedData", database.GetModelData(model)); 94 95 modelEntry.Set("TargetVariable", model.TargetVariable.Name); 95 96 Dictionary<HeuristicLab.Modeling.Database.IVariable, ResultsEntry> inputVariableResultsEntries = … … 100 101 inputVariableResultsEntries[inputVariableResult.Variable] = new ResultsEntry(); 101 102 inputVariableResultsEntries[inputVariableResult.Variable].Set("InputVariableName", inputVariableResult.Variable.Name); 102 103 103 } 104 inputVariableResultsEntries[inputVariableResult.Variable].Set(inputVariableResult.Result.Name, inputVariableResult.Value); 104 105 } 105 106 modelEntry.Set("VariableImpacts", inputVariableResultsEntries.Values); -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs
r2203 r2217 14 14 } 15 15 16 public Model(Variable targetVariable, Algorithm algorithm , byte[] data)16 public Model(Variable targetVariable, Algorithm algorithm) 17 17 : this() { 18 18 this.targetVariableId = targetVariable.Id; 19 19 this.algorithmId = algorithm.Id; 20 this.Data = data;21 20 } 22 21 … … 26 25 get { return this.id; } 27 26 private set { this.id = value; } 28 }29 30 private byte[] data;31 [Column(Storage = "data", DbType = "image", CanBeNull = false)]32 public byte[] Data {33 get { return this.data; }34 set { this.data = value; }35 27 } 36 28 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs
r2207 r2217 45 45 46 46 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 47 model = new Model(target, algo , PersistenceManager.SaveToGZip(algorithm.Model.Data));47 model = new Model(target, algo); 48 48 model.TrainingSamplesStart = trainingSamplesStart; 49 49 model.TrainingSamplesEnd = trainingSamplesEnd; … … 59 59 60 60 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 61 ctx.ModelData.InsertOnSubmit(new ModelData(model, PersistenceManager.SaveToGZip(algorithm.Model.Data))); 62 } 63 64 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 61 65 foreach (string inputVariable in algorithm.Model.InputVariables) { 62 ctx.InputVariables.InsertOnSubmit(new InputVariable(model, variables[inputVariable])); 66 ctx.InputVariables.InsertOnSubmit(new InputVariable(model, variables[inputVariable])); 63 67 } 64 68 ctx.SubmitChanges(); … … 194 198 195 199 public IEnumerable<IResult> GetAllResultsForInputVariables() { 196 using (ModelingDataContext ctx = new ModelingDataContext(connection) ){197 return (from ir in ctx.InputVariableResults 200 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 201 return (from ir in ctx.InputVariableResults select ir.Result).Distinct().ToList().Cast<IResult>(); 198 202 } 199 203 } … … 205 209 ModelingDataContext ctx = new ModelingDataContext(connection); 206 210 DataLoadOptions dlo = new DataLoadOptions(); 207 dlo.LoadWith<ModelResult>(mr => mr.Model);208 211 dlo.LoadWith<ModelResult>(mr => mr.Result); 209 212 ctx.LoadOptions = dlo; … … 214 217 return results.ToList().Cast<IModelResult>(); 215 218 } 219 220 public void GetAllModelResults() { 221 ModelingDataContext ctx = new ModelingDataContext(connection); 222 DataLoadOptions dlo = new DataLoadOptions(); 223 dlo.LoadWith<ModelResult>(mr => mr.Result); 224 dlo.LoadWith<ModelResult>(mr => mr.Model); 225 ctx.LoadOptions = dlo; 226 227 var results = from result in ctx.ModelResults 228 select result; 229 results.ToList(); 230 231 } 216 232 #endregion 217 233 … … 221 237 DataLoadOptions dlo = new DataLoadOptions(); 222 238 dlo.LoadWith<InputVariableResult>(ir => ir.Variable); 223 dlo.LoadWith<InputVariableResult>(ir => ir.Result); 224 dlo.LoadWith<InputVariableResult>(ir => ir.Model); 239 dlo.LoadWith<InputVariableResult>(ir => ir.Result); 225 240 ctx.LoadOptions = dlo; 226 241 … … 241 256 return ctx.Models.ToList().Cast<IModel>(); 242 257 } 258 259 public byte[] GetModelData(IModel model) { 260 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 261 var data = (from md in ctx.ModelData 262 where md.Model == model 263 select md); 264 if (data.Count() == 0) 265 return null; 266 return data.Single().Data; 267 } 268 } 243 269 #endregion 244 270 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/HeuristicLab.Modeling.Database.SQLServerCompact-3.2.csproj
r2213 r2217 122 122 <Compile Include="DataObjects\InputVariableResult.cs" /> 123 123 <Compile Include="DataObjects\Model.cs" /> 124 <Compile Include="DataObjects\ModelData.cs" /> 124 125 <Compile Include="HeuristicLabModelingDatabaseSQLServerCompactPlugin.cs" /> 125 126 <Compile Include="ModelingDataContext.cs" /> -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/ModelingDataContext.cs
r2194 r2217 33 33 } 34 34 35 public Table<ModelData> ModelData { 36 get { return GetTable<ModelData>(); } 37 } 38 35 39 public Table<InputVariableResult> InputVariableResults { 36 40 get { return GetTable<InputVariableResult>(); } -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database/3.2/IModel.cs
r2194 r2217 29 29 IVariable TargetVariable { get; } 30 30 IAlgorithm Algorithm { get; } 31 byte[] Data { get; }32 31 int TrainingSamplesStart { get; } 33 32 int TrainingSamplesEnd { get; } -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database/3.2/IModelingDatabase.cs
r2207 r2217 32 32 IEnumerable<IResult> GetAllResultsForInputVariables(); 33 33 IEnumerable<IModelResult> GetModelResults(IModel model); 34 IEnumerable<IInputVariableResult> GetInputVariableResults(IModel model); 34 byte[] GetModelData(IModel model); 35 IEnumerable<IInputVariableResult> GetInputVariableResults(IModel model); 36 37 void GetAllModelResults(); 35 38 } 36 39 }
Note: See TracChangeset
for help on using the changeset viewer.