Index: trunk/tools/CedmaExporter/CedmaExporter.cs
===================================================================
--- branches/CEDMA-Exporter-715/tools/CedmaExporter/CedmaExporter.cs	(revision 2286)
+++ trunk/tools/CedmaExporter/CedmaExporter.cs	(revision 2312)
@@ -3,5 +3,4 @@
 using System.Linq;
 using System.Text;
-using SemWeb;
 using HeuristicLab.GP;
 using HeuristicLab.Core;
@@ -11,58 +10,48 @@
 using SVM;
 using HeuristicLab.DataAnalysis;
+using HeuristicLab.Modeling.Database;
 
 namespace CedmaExporter {
   class CedmaExporter {
 
-    public static List<string> WriteVariableImpactHeaders(Store store, StreamWriter writer) {
+    public static List<string> WriteVariableImpactHeaders(HeuristicLab.Modeling.Database.SQLServerCompact.DatabaseService database, StreamWriter writer) {
       List<string> inputVarNames = new List<string>();
-      Statement template = new Statement();
-      template.Predicate = Ontology.HasInputVariable;
-      var inputVars = store.Select(template).Select(x => x.Object);
-      foreach (Entity inputVar in inputVars) {
-        var names = store.SelectObjects(inputVar, Ontology.Name);
-        if (names.Count() > 0) {
-          var inputVarName = ((Literal)names[0]).Value;
-          if (!inputVarNames.Contains(inputVarName)) inputVarNames.Add(inputVarName);
+      var variables = database.GetAllVariables();
+      foreach (var r in database.GetAllResultsForInputVariables()) {
+        foreach (string varName in variables.Keys) {
+          writer.Write(r.Name); writer.Write(": "); writer.Write(varName); writer.Write("; ");
         }
       }
-      inputVarNames.Sort();
-      foreach (string inputVarName in inputVarNames) {
-        writer.Write("EvaluationImpact ("); writer.Write(inputVarName); writer.Write("); ");
-      }
-      foreach (string inputVarName in inputVarNames) {
-        writer.Write("QualityImpact ("); writer.Write(inputVarName); writer.Write("); ");
-      }
       writer.WriteLine();
-      return inputVarNames;
+      return new List<string>(variables.Keys);
     }
 
-    public static void WriteModel(Entity model, int id, Store store, StreamWriter writer, List<string> inputVariables, ModelExporter exporter) {
+    public static void WriteModel(IModel model, int id, HeuristicLab.Modeling.Database.IModelingDatabase database, StreamWriter writer, List<string> inputVariables, ModelExporter exporter) {
       try {
         writer.Write(id); writer.Write("; ");
-        string targetVariable = LiteralValue(store.SelectObjects(model, Ontology.TargetVariable)[0]).ToString();
-        string algoName = LiteralValue(store.SelectObjects(model, Ontology.Name)[0]).ToString();
+        string targetVariable = model.TargetVariable.Name;
+        string algoName = model.Algorithm.Name;
         string modelFileName = "model_" + targetVariable + "_" + id.ToString("000");
         writer.Write(modelFileName); writer.Write("; ");
         writer.Write(targetVariable); writer.Write("; ");
         writer.Write(algoName); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TrainingMeanSquaredError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.ValidationMeanSquaredError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TestMeanSquaredError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TrainingCoefficientOfDetermination)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.ValidationCoefficientOfDetermination)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TestCoefficientOfDetermination)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TrainingMeanAbsolutePercentageError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.ValidationMeanAbsolutePercentageError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TestMeanAbsolutePercentageError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TrainingMeanAbsolutePercentageOfRangeError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.ValidationMeanAbsolutePercentageOfRangeError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TestMeanAbsolutePercentageOfRangeError)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TrainingVarianceAccountedFor)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.ValidationVarianceAccountedFor)[0]).ToString()); writer.Write("; ");
-        writer.Write(LiteralValue(store.SelectObjects(model, Ontology.TestVarianceAccountedFor)[0]).ToString()); writer.Write("; ");
-        WriteVariableImpacts(writer, store, model, inputVariables);
-        var data = PersistenceManager.RestoreFromGZip(Convert.FromBase64String((string)LiteralValue(store.SelectObjects(model, Ontology.SerializedData)[0])));
-        exporter.Export(modelFileName, data);
+        var modelResults = database.GetModelResults(model);
+        writer.Write(FindResult("TrainingMeanSquaredError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("ValidationMeanSquaredError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TestMeanSquaredError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TrainingCoefficientOfDetermination", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("ValidationCoefficientOfDetermination", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TestCoefficientOfDetermination", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TrainingMeanAbsolutePercentageError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("ValidationMeanAbsolutePercentageError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TestMeanAbsolutePercentageError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TrainingMeanAbsolutePercentageOfRangeError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("ValidationMeanAbsolutePercentageOfRangeError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TestMeanAbsolutePercentageOfRangeError", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TrainingVarianceAccountedFor", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("ValidationVarianceAccountedFor", modelResults)); writer.Write("; ");
+        writer.Write(FindResult("TestVarianceAccountedFor", modelResults)); writer.Write("; ");
+        WriteVariableImpacts(writer, database, model, inputVariables);
+        // exporter.Export(modelFileName, data);
       }
       catch (FormatException ex) {
@@ -74,19 +63,15 @@
     }
 
-    private static void WriteVariableImpacts(StreamWriter writer, Store store, Entity model, List<string> inputVariables) {
-      var inputVariableEntities = store.SelectObjects(model, Ontology.HasInputVariable);
-      Dictionary<string, List<double>> impacts = new Dictionary<string, List<double>>();
-      foreach (Entity inputVariableEntity in inputVariableEntities) {
-        var variableImpacts = new List<double>();
-        var names = store.SelectObjects(inputVariableEntity, Ontology.Name);
-        if (names.Count() == 0) throw new FormatException();
-        impacts[(string)(LiteralValue(names[0]))] = variableImpacts;
-        variableImpacts.Add((double)(LiteralValue(store.SelectObjects(inputVariableEntity, Ontology.EvaluationImpact)[0])));
-        variableImpacts.Add((double)(LiteralValue(store.SelectObjects(inputVariableEntity, Ontology.QualityImpact)[0])));
+    private static void WriteVariableImpacts(StreamWriter writer, IModelingDatabase database, IModel model, List<string> inputVariables) {
+      Dictionary<string, List<IInputVariableResult>> impacts = new Dictionary<string, List<IInputVariableResult>>();
+      foreach (var inputVariableResult in database.GetInputVariableResults(model)) {
+        if (!impacts.ContainsKey(inputVariableResult.Variable.Name))
+          impacts[inputVariableResult.Variable.Name] = new List<IInputVariableResult>();
+        impacts[inputVariableResult.Variable.Name].Add(inputVariableResult);
       }
 
       foreach (string varName in inputVariables) {
         if (impacts.ContainsKey(varName)) {
-          writer.Write(impacts[varName][0]); writer.Write("; ");
+          writer.Write(FindResult("VariableEvaluationImpact", impacts[varName])); writer.Write("; ");
         } else {
           writer.Write(" ; ");
@@ -96,9 +81,17 @@
       foreach (string varName in inputVariables) {
         if (impacts.ContainsKey(varName)) {
-          writer.Write(impacts[varName][1]); writer.Write("; ");
+          writer.Write(FindResult("VariableQualityImpact", impacts[varName])); writer.Write("; ");
         } else {
           writer.Write(" ; ");
         }
       }
+    }
+
+    private static double FindResult(string p, List<IInputVariableResult> rs) {
+      return rs.First(e => e.Result.Name == p).Value;
+    }
+
+    private static double FindResult(string p, IEnumerable<IModelResult> rs) {
+      return rs.First(e => e.Result.Name == p).Value;
     }
 
@@ -111,15 +104,9 @@
         "TrainingVAF; ValidationVAF; TestVAF; ");
     }
-
-    private static object LiteralValue(Resource resource) {
-      return ((Literal)resource).ParseValue();
-    }
   }
-
   class ModelExporter {
     private string outputDir;
     private bool debugging;
     private Dataset dataset;
-    IFunctionTreeExporter treeExporter;
 
     public ModelExporter(Dataset ds, string outputDir, bool debugging) {
@@ -127,21 +114,20 @@
       this.outputDir = outputDir;
       this.debugging = debugging;
-      treeExporter = new SymbolicExpressionExporter(ds);
     }
 
     public void Export(string modelFileName, IStorable model) {
-      if (debugging) return;
-      foreach (char c in Path.GetInvalidFileNameChars()) {
-        modelFileName = modelFileName.Replace(c, '_');
-      }
-      if (model is IFunctionTree) {
-        using (StreamWriter writer = File.CreateText(Path.Combine(outputDir, modelFileName + ".gp.txt"))) {
-          writer.Write(treeExporter.Export((IFunctionTree)model));
-        }
-      } else if (model is SVMModel) {
-        SVMModel svmModel = (SVMModel)model;
-        RangeTransform.Write(Path.Combine(outputDir, modelFileName + ".svm.transform.txt"), svmModel.RangeTransform);
-        SVM.Model.Write(Path.Combine(outputDir, modelFileName + ".svm.model.txt"), svmModel.Model);
-      } else throw new NotSupportedException("This type of model is not supported by the CedmaExporter: " + model);
+      //if (debugging) return;
+      //foreach (char c in Path.GetInvalidFileNameChars()) {
+      //  modelFileName = modelFileName.Replace(c, '_');
+      //}
+      //if (model is Predictor) {
+      //  using (StreamWriter writer = File.CreateText(Path.Combine(outputDir, modelFileName + ".gp.txt"))) {
+      //    writer.Write(treeExporter.Export(((Predictor)model).FunctionTree);
+      //  }
+      //} else if (model is HeuristicLab.SupportVectorMachines.Predictor) {
+      //  SVMModel svmModel = (SVMModel)model;
+      //  RangeTransform.Write(Path.Combine(outputDir, modelFileName + ".svm.transform.txt"), svmModel.RangeTransform);
+      //  SVM.Model.Write(Path.Combine(outputDir, modelFileName + ".svm.model.txt"), svmModel.Model);
+      //} else throw new NotSupportedException("This type of model is not supported by the CedmaExporter: " + model);
     }
   }
Index: trunk/tools/CedmaExporter/CedmaExporter.csproj
===================================================================
--- branches/CEDMA-Exporter-715/tools/CedmaExporter/CedmaExporter.csproj	(revision 2286)
+++ trunk/tools/CedmaExporter/CedmaExporter.csproj	(revision 2312)
@@ -56,4 +56,8 @@
       <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\HeuristicLab.Core-3.2.dll</HintPath>
     </Reference>
+    <Reference Include="HeuristicLab.Data-3.2, Version=3.2.0.1609, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\HeuristicLab.Data-3.2.dll</HintPath>
+    </Reference>
     <Reference Include="HeuristicLab.DataAnalysis-3.2, Version=3.2.0.2162, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86">
       <SpecificVersion>False</SpecificVersion>
@@ -72,4 +76,12 @@
       <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\HeuristicLab.Modeling-3.2.dll</HintPath>
     </Reference>
+    <Reference Include="HeuristicLab.Modeling.Database-3.2, Version=3.2.0.2304, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\HeuristicLab.Modeling.Database-3.2.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Modeling.Database.SQLServerCompact-3.2, Version=3.2.0.2306, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\HeuristicLab.Modeling.Database.SQLServerCompact-3.2.dll</HintPath>
+    </Reference>
     <Reference Include="HeuristicLab.PluginInfrastructure, Version=3.2.0.1990, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86">
       <SpecificVersion>False</SpecificVersion>
@@ -83,12 +95,4 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\LibSVM.dll</HintPath>
-    </Reference>
-    <Reference Include="SemWeb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\SemWeb.dll</HintPath>
-    </Reference>
-    <Reference Include="SemWeb.SqliteStore, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\SemWeb.SqliteStore.dll</HintPath>
     </Reference>
     <Reference Include="System" />
@@ -116,5 +120,4 @@
       <DependentUpon>CedmaExporterForm.cs</DependentUpon>
     </Compile>
-    <Compile Include="Ontology.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -140,5 +143,4 @@
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
     </Compile>
-    <Compile Include="SymbolicExpressionExporter.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Index: trunk/tools/CedmaExporter/CedmaExporterForm.cs
===================================================================
--- branches/CEDMA-Exporter-715/tools/CedmaExporter/CedmaExporterForm.cs	(revision 2286)
+++ trunk/tools/CedmaExporter/CedmaExporterForm.cs	(revision 2312)
@@ -8,7 +8,7 @@
 using System.Windows.Forms;
 using System.IO;
-using SemWeb;
 using HeuristicLab.Core;
 using HeuristicLab.DataAnalysis;
+using HeuristicLab.Modeling.Database.SQLServerCompact;
 
 namespace CedmaExporter {
@@ -40,22 +40,21 @@
       return (sender, args) => {
         string inputFileName = fileName;
-        string outputFileName = fileName.Replace(".db3", "") + ".txt";
-        string rdfConnectionString = "sqlite:rdf:Data Source=\"" + inputFileName + "\"";
+        string outputFileName = fileName.Replace(".sdf", "") + ".txt";
+        string sqlCompactConnectionString = "sqlite:rdf:Data Source=\"" + inputFileName + "\"";
         using (StreamWriter writer = File.CreateText(outputFileName)) {
-          using (Store store = Store.Create(rdfConnectionString)) {
-            var dsEntities = store.SelectSubjects(Ontology.InstanceOf, Ontology.TypeDataSet);
-            HeuristicLab.CEDMA.Core.Problem prob = (HeuristicLab.CEDMA.Core.Problem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String(((Literal)store.SelectObjects(dsEntities[0], Ontology.SerializedData)[0]).Value));
-            Dataset ds = prob.Dataset;
-            CedmaExporter.WriteColumnHeaders(writer);
-            List<string> inputVariables = CedmaExporter.WriteVariableImpactHeaders(store, writer);
-            writer.WriteLine();
-            var subjects = store.SelectSubjects(new Entity(Ontology.InstanceOf.Uri), new Entity(Ontology.TypeModel.Uri));
-            int i = 0;
-            var exporter = new ModelExporter(ds, Path.GetDirectoryName(outputFileName), false);
-            foreach (var model in subjects) {
-              CedmaExporter.WriteModel(model, ++i, store, writer, inputVariables, exporter);
-              worker.ReportProgress((i * 100) / subjects.Count());
-              if (worker.CancellationPending) return;
-            }
+          DatabaseService database = new DatabaseService("Data Source=" + fileName);
+          database.Connect();
+          var models = database.GetAllModels();
+          var dataset = database.GetDataset();
+          CedmaExporter.WriteColumnHeaders(writer);
+          List<string> inputVariables = CedmaExporter.WriteVariableImpactHeaders(database, writer);
+          writer.WriteLine();
+          int i = 0;
+          var exporter = new ModelExporter(dataset, Path.GetDirectoryName(outputFileName), true);
+          var allModels = database.GetAllModels();
+          foreach (HeuristicLab.Modeling.Database.IModel m in allModels) {
+            CedmaExporter.WriteModel(m, ++i, database, writer, inputVariables, exporter);
+            worker.ReportProgress((i * 100) / allModels.Count());
+            if (worker.CancellationPending) return;
           }
         }
