- Timestamp:
- 09/24/09 17:37:00 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs
r2371 r2389 46 46 public int Id { 47 47 get { return this.id; } 48 privateset { this.id = value; }48 set { this.id = value; } 49 49 } 50 50 -
trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs
r2384 r2389 95 95 } 96 96 97 public IModel CreateModel(ModelType modelType, IAlgorithm algorithm, IVariable targetVariable, 98 int trainingSamplesStart, int trainingSamplesEnd, int validationSamplesStart, int validationSamplesEnd, int testSamplesStart, int testSamplesEnd) { 99 return CreateModel(null, modelType, algorithm, targetVariable, trainingSamplesStart, trainingSamplesEnd, validationSamplesStart, validationSamplesEnd, testSamplesStart, testSamplesEnd); 97 public IModel CreateModel(int id, string modelName, ModelType modelType, IAlgorithm algorithm, IVariable targetVariable, 98 int trainingSamplesStart, int trainingSamplesEnd, int validationSamplesStart, int validationSamplesEnd, int testSamplesStart, int testSamplesEnd) { 99 Model m = (Model)CreateModel(modelName, modelType, algorithm, targetVariable, trainingSamplesStart, trainingSamplesEnd, validationSamplesStart, validationSamplesEnd, testSamplesStart, testSamplesEnd); 100 m.Id = id; 101 return m; 100 102 } 101 103 … … 142 144 143 145 public Dataset GetDataset() { 144 if (ctx.Problems.Count() != 1) 145 throw new InvalidOperationException("Could not get dataset. No or more than one problems are persisted in the database."); 146 Problem problem = ctx.Problems.Single(); 147 return problem.Dataset; 146 if (ctx.Problems.Count() > 1) 147 throw new InvalidOperationException("Could not get dataset. More than one problems are persisted in the database."); 148 if (ctx.Problems.Count() == 1) 149 return ctx.Problems.Single().Dataset; 150 return null; 148 151 } 149 152 … … 192 195 ctx.SubmitChanges(); 193 196 } 197 } 198 199 public IInputVariable GetInputVariable(IModel model, string inputVariableName) { 200 var inputVariables = ctx.InputVariables.Where(i => i.Model == model && i.Variable.Name == inputVariableName); 201 if (inputVariables.Count() == 1) 202 return inputVariables.Single(); 203 204 if (inputVariables.Count() > 1) 205 throw new ArgumentException("More than one input variable with the same name are for the given model persisted."); 206 207 return null; 194 208 } 195 209 … … 258 272 } 259 273 260 public void PersistModelResults(IModel model, IEnumerable<IModelResult> modelResults) {274 public void PersistModelResults(IModel model, IEnumerable<IModelResult> modelResults) { 261 275 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 262 276 ctx.ModelResults.DeleteAllOnSubmit(GetModelResults(model).Cast<ModelResult>()); … … 277 291 } 278 292 279 public void PersistInputVariableResults(IModel model, IEnumerable<IInputVariableResult> inputVariableResults) {293 public void PersistInputVariableResults(IModel model, IEnumerable<IInputVariableResult> inputVariableResults) { 280 294 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 281 295 ctx.InputVariableResults.DeleteAllOnSubmit(GetInputVariableResults(model).Cast<InputVariableResult>()); … … 306 320 307 321 public IModel Persist(HeuristicLab.Modeling.IAnalyzerModel model, string algorithmName, string algorithmDescription) { 308 Algorithm algorithm = (Algorithm) 309 Variable targetVariable = (Variable)GetVariable(model.TargetVariable);310 311 Model m = (Model)CreateModel( model.Type, algorithm, targetVariable, model.TrainingSamplesStart, model.TrainingSamplesEnd,322 Algorithm algorithm = (Algorithm)GetOrPersistAlgorithm(algorithmName); 323 Variable targetVariable = (Variable)GetVariable(model.TargetVariable); 324 325 Model m = (Model)CreateModel(null, model.Type, algorithm, targetVariable, model.TrainingSamplesStart, model.TrainingSamplesEnd, 312 326 model.ValidationSamplesStart, model.ValidationSamplesEnd, model.TestSamplesStart, model.TestSamplesEnd); 313 327 PersistModel(m);
Note: See TracChangeset
for help on using the changeset viewer.