aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pom.xml10
-rw-r--r--src/uk/ac/ox/cs/pagoda/Pagoda.java6
-rw-r--r--src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java4
-rw-r--r--src/uk/ac/ox/cs/pagoda/query/QueryRecord.java8
-rw-r--r--src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java7
-rw-r--r--src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java1
-rw-r--r--src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java2
-rw-r--r--src/uk/ac/ox/cs/pagoda/util/tuples/Tuple.java5
-rw-r--r--test/resources/ComparisonTests.xml24
-rw-r--r--test/resources/LightTests.xml4
-rw-r--r--test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java60
-rw-r--r--test/uk/ac/ox/cs/pagoda/util/TestUtil.java18
12 files changed, 132 insertions, 17 deletions
diff --git a/pom.xml b/pom.xml
index 0a9f1c7..3b9a94a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -172,11 +172,11 @@
172 <artifactId>jrdfox</artifactId> 172 <artifactId>jrdfox</artifactId>
173 <version>1.0</version> 173 <version>1.0</version>
174 </dependency> 174 </dependency>
175 <!--<dependency>--> 175 <dependency>
176 <!--<groupId>commons-lang</groupId>--> 176 <groupId>commons-lang</groupId>
177 <!--<artifactId>commons-lang</artifactId>--> 177 <artifactId>commons-lang</artifactId>
178 <!--<version>2.1</version>--> 178 <version>2.1</version>
179 <!--</dependency>--> 179 </dependency>
180 <!--<dependency>--> 180 <!--<dependency>-->
181 <!--<groupId>org.codehaus.plexus</groupId>--> 181 <!--<groupId>org.codehaus.plexus</groupId>-->
182 <!--<artifactId>plexus-utils</artifactId>--> 182 <!--<artifactId>plexus-utils</artifactId>-->
diff --git a/src/uk/ac/ox/cs/pagoda/Pagoda.java b/src/uk/ac/ox/cs/pagoda/Pagoda.java
index aeb85a7..f5dce15 100644
--- a/src/uk/ac/ox/cs/pagoda/Pagoda.java
+++ b/src/uk/ac/ox/cs/pagoda/Pagoda.java
@@ -177,6 +177,12 @@ public class Pagoda implements Runnable {
177 return this; 177 return this;
178 } 178 }
179 179
180 public PagodaBuilder skolem(Boolean isEnabled) {
181 if(instance == null) return null;
182 instance.properties.setUseSkolemUpperBound(isEnabled);
183 return this;
184 }
185
180 public Pagoda build() { 186 public Pagoda build() {
181 Pagoda builtInstance = instance; 187 Pagoda builtInstance = instance;
182 instance = null; 188 instance = null;
diff --git a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java
index 479905d..2471c80 100644
--- a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java
+++ b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java
@@ -10,6 +10,7 @@ import uk.ac.ox.cs.pagoda.query.GapByStore4ID;
10import uk.ac.ox.cs.pagoda.query.QueryRecord; 10import uk.ac.ox.cs.pagoda.query.QueryRecord;
11import uk.ac.ox.cs.pagoda.rules.DatalogProgram; 11import uk.ac.ox.cs.pagoda.rules.DatalogProgram;
12import uk.ac.ox.cs.pagoda.rules.Program; 12import uk.ac.ox.cs.pagoda.rules.Program;
13import uk.ac.ox.cs.pagoda.rules.approximators.SkolemTermsManager;
13import uk.ac.ox.cs.pagoda.util.PagodaProperties; 14import uk.ac.ox.cs.pagoda.util.PagodaProperties;
14import uk.ac.ox.cs.pagoda.util.Timer; 15import uk.ac.ox.cs.pagoda.util.Timer;
15import uk.ac.ox.cs.pagoda.util.Utility; 16import uk.ac.ox.cs.pagoda.util.Utility;
@@ -216,6 +217,9 @@ public class MultiStageQueryEngine extends StageQueryEngine {
216 Utility.logDebug(name + " store after adding facts for violations: " + (tripleCount = 217 Utility.logDebug(name + " store after adding facts for violations: " + (tripleCount =
217 store.getTriplesCount()) + " (" + (tripleCount - oldTripleCount) + " new)"); 218 store.getTriplesCount()) + " (" + (tripleCount - oldTripleCount) + " new)");
218 Utility.logDebug("Time to add triples for violations: " + subTimer.duration()); 219 Utility.logDebug("Time to add triples for violations: " + subTimer.duration());
220
221 Utility.logDebug("Number of Skolem individuals: " + SkolemTermsManager.getInstance()
222 .getSkolemIndividualsCount());
219 } 223 }
220 } catch(JRDFStoreException e) { 224 } catch(JRDFStoreException e) {
221 e.printStackTrace(); 225 e.printStackTrace();
diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java
index 7f02741..5878a57 100644
--- a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java
+++ b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java
@@ -2,6 +2,7 @@ package uk.ac.ox.cs.pagoda.query;
2 2
3import com.google.gson.*; 3import com.google.gson.*;
4import com.google.gson.reflect.TypeToken; 4import com.google.gson.reflect.TypeToken;
5import org.apache.commons.lang.WordUtils;
5import org.semanticweb.HermiT.model.*; 6import org.semanticweb.HermiT.model.*;
6import org.semanticweb.owlapi.model.*; 7import org.semanticweb.owlapi.model.*;
7import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper; 8import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper;
@@ -713,7 +714,12 @@ public class QueryRecord extends Disposable {
713 FRAGMENT_REFINEMENT, 714 FRAGMENT_REFINEMENT,
714 SUMMARISATION, 715 SUMMARISATION,
715 DEPENDENCY, 716 DEPENDENCY,
716 FULL_REASONING 717 FULL_REASONING;
718
719 @Override
720 public String toString() {
721 return WordUtils.capitalizeFully(super.toString(), new char[]{'_'}).replace("_", "");
722 }
717 } 723 }
718 724
719 /** 725 /**
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
index e6e508a..e689de6 100644
--- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
+++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
@@ -19,7 +19,6 @@ import uk.ac.ox.cs.pagoda.tracking.QueryTracker;
19import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; 19import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder;
20import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderDisjVar1; 20import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderDisjVar1;
21import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderWithGap; 21import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderWithGap;
22import uk.ac.ox.cs.pagoda.util.PagodaProperties;
23import uk.ac.ox.cs.pagoda.util.Timer; 22import uk.ac.ox.cs.pagoda.util.Timer;
24import uk.ac.ox.cs.pagoda.util.Utility; 23import uk.ac.ox.cs.pagoda.util.Utility;
25import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; 24import uk.ac.ox.cs.pagoda.util.disposable.DisposedException;
@@ -192,7 +191,7 @@ class MyQueryReasoner extends QueryReasoner {
192 OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); 191 OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord);
193// queryRecord.saveRelevantOntology("./fragment_query" + queryRecord.getQueryID() + ".owl"); 192// queryRecord.saveRelevantOntology("./fragment_query" + queryRecord.getQueryID() + ".owl");
194 193
195 if(PagodaProperties.getDefaultUseSkolemUpperBound() && 194 if(properties.getUseSkolemUpperBound() &&
196 querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) 195 querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord))
197 return; 196 return;
198 197
@@ -297,7 +296,7 @@ class MyQueryReasoner extends QueryReasoner {
297 296
298 Tuple<String> extendedQueryTexts = queryRecord.getExtendedQueryText(); 297 Tuple<String> extendedQueryTexts = queryRecord.getExtendedQueryText();
299 298
300 if(PagodaProperties.getDefaultUseAlwaysSimpleUpperBound() || lazyUpperStore == null) { 299 if(properties.getUseAlwaysSimpleUpperBound() || lazyUpperStore == null) {
301 Utility.logDebug("Tracking store"); 300 Utility.logDebug("Tracking store");
302 if(queryUpperStore(trackingStore, queryRecord, extendedQueryTexts, Step.SIMPLE_UPPER_BOUND)) 301 if(queryUpperStore(trackingStore, queryRecord, extendedQueryTexts, Step.SIMPLE_UPPER_BOUND))
303 return true; 302 return true;
@@ -369,8 +368,10 @@ class MyQueryReasoner extends QueryReasoner {
369 new MultiStageQueryEngine("Relevant-store", true); // checkValidity is true 368 new MultiStageQueryEngine("Relevant-store", true); // checkValidity is true
370 369
371 relevantStore.importDataFromABoxOf(relevantSubset); 370 relevantStore.importDataFromABoxOf(relevantSubset);
371 String relevantOriginalMarkProgram = OWLHelper.getOriginalMarkProgram(relevantSubset);
372 372
373 int queryDependentMaxTermDepth = 5; // TODO make it dynamic 373 int queryDependentMaxTermDepth = 5; // TODO make it dynamic
374 relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram);
374 int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null, 375 int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null,
375 queryDependentMaxTermDepth); 376 queryDependentMaxTermDepth);
376 queryRecord.addProcessingTime(Step.SKOLEM_UPPER_BOUND, t.duration()); 377 queryRecord.addProcessingTime(Step.SKOLEM_UPPER_BOUND, t.duration());
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java
index eab6a1b..3a057ec 100644
--- a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java
+++ b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java
@@ -193,6 +193,7 @@ public abstract class QueryReasoner extends Disposable {
193 if(!record.isProcessed()) 193 if(!record.isProcessed())
194 evaluate(record); 194 evaluate(record);
195 Utility.logInfo("Total time to answer this query: " + t.duration()); 195 Utility.logInfo("Total time to answer this query: " + t.duration());
196 Utility.logInfo("Difficulty of this query: " + record.getDifficulty());
196 if(!fullReasoner && !record.isProcessed()) { 197 if(!fullReasoner && !record.isProcessed()) {
197 Utility.logInfo("The query has not been fully answered in " + t.duration() + " seconds."); 198 Utility.logInfo("The query has not been fully answered in " + t.duration() + " seconds.");
198 continue; 199 continue;
diff --git a/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java b/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java
index 44daf7a..a78aabe 100644
--- a/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java
+++ b/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java
@@ -83,7 +83,7 @@ public class SkolemTermsManager {
83 /** 83 /**
84 * Get the number of individuals generated by this manager. 84 * Get the number of individuals generated by this manager.
85 */ 85 */
86 public int getNumberOfSkolemisedIndividual() { 86 public int getSkolemIndividualsCount() {
87 return individualToDepth_map.keySet().size(); 87 return individualToDepth_map.keySet().size();
88 } 88 }
89 89
diff --git a/src/uk/ac/ox/cs/pagoda/util/tuples/Tuple.java b/src/uk/ac/ox/cs/pagoda/util/tuples/Tuple.java
index 9139a5d..0a5983c 100644
--- a/src/uk/ac/ox/cs/pagoda/util/tuples/Tuple.java
+++ b/src/uk/ac/ox/cs/pagoda/util/tuples/Tuple.java
@@ -46,4 +46,9 @@ public class Tuple<T> implements Iterable<T> {
46 public int hashCode() { 46 public int hashCode() {
47 return elements.hashCode() + getClass().hashCode(); 47 return elements.hashCode() + getClass().hashCode();
48 } 48 }
49
50 @Override
51 public String toString() {
52 return elements.toString();
53 }
49} 54}
diff --git a/test/resources/ComparisonTests.xml b/test/resources/ComparisonTests.xml
new file mode 100644
index 0000000..0095724
--- /dev/null
+++ b/test/resources/ComparisonTests.xml
@@ -0,0 +1,24 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
3
4<!--
5Compare different configurations of the system.
6
7Actually it is not a great idea to test performances in this way,
8because all the different configurations are executed on the same JVM.
9-->
10
11<suite name="ComparisonTests">
12 <test name="comparison">
13 <groups>
14 <run>
15 <include name="comparison"/>
16 </run>
17 </groups>
18 <classes>
19 <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/>-->
20 <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/>-->
21 <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/>
22 </classes>
23 </test>
24</suite> \ No newline at end of file
diff --git a/test/resources/LightTests.xml b/test/resources/LightTests.xml
index 859e3fa..8d9a700 100644
--- a/test/resources/LightTests.xml
+++ b/test/resources/LightTests.xml
@@ -5,10 +5,10 @@
5 <test name="light"> 5 <test name="light">
6 <groups> 6 <groups>
7 <run> 7 <run>
8 <include name="light"/> 8 <!--<include name="light"/>-->
9 <include name="justExecute"/>
9 </run> 10 </run>
10 </groups> 11 </groups>
11
12 <classes> 12 <classes>
13 <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/>--> 13 <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/>-->
14 <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/>--> 14 <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/>-->
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java
index 4fdccf8..42827a0 100644
--- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java
+++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java
@@ -4,6 +4,7 @@ import org.testng.annotations.Test;
4import uk.ac.ox.cs.pagoda.Pagoda; 4import uk.ac.ox.cs.pagoda.Pagoda;
5import uk.ac.ox.cs.pagoda.query.CheckAnswers; 5import uk.ac.ox.cs.pagoda.query.CheckAnswers;
6import uk.ac.ox.cs.pagoda.util.TestUtil; 6import uk.ac.ox.cs.pagoda.util.TestUtil;
7import uk.ac.ox.cs.pagoda.util.Timer;
7 8
8import java.io.File; 9import java.io.File;
9import java.io.IOException; 10import java.io.IOException;
@@ -20,8 +21,8 @@ public class TestPagodaFLY {
20 Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-fly-with-GJ-FC-individuals.json"); 21 Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-fly-with-GJ-FC-individuals.json");
21 22
22 Pagoda pagoda = Pagoda.builder() 23 Pagoda pagoda = Pagoda.builder()
23 .ontology(TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl")) 24 .ontology(Paths.get(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"))
24 .query(TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql")) 25 .query(Paths.get(ontoDir, "fly/queries/fly.sparql"))
25 .answer(answers) 26 .answer(answers)
26 .classify(false) 27 .classify(false)
27 .hermit(true) 28 .hermit(true)
@@ -39,9 +40,10 @@ public class TestPagodaFLY {
39 Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-fly-rolledup.json"); 40 Path givenAnswers = TestUtil.getAnswersFilePath("answers/pagoda-fly-rolledup.json");
40 41
41 Pagoda pagoda = Pagoda.builder() 42 Pagoda pagoda = Pagoda.builder()
42 .ontology(TestUtil.combinePaths(ontoDir, "fly/fly_rolledUp.owl")) 43 .ontology(Paths.get(ontoDir, "fly/fly_rolledUp.owl"))
43 .query(TestUtil.combinePaths(ontoDir, "fly/queries/fly_rolledUp.sparql")) 44 .query(Paths.get(ontoDir, "fly/queries/fly_rolledUp.sparql"))
44 .answer(answers) 45 .answer(answers)
46 .answer(Paths.get("/home/alessandro/Desktop/answers.json"))
45 .classify(false) 47 .classify(false)
46 .hermit(true) 48 .hermit(true)
47 .build(); 49 .build();
@@ -49,4 +51,54 @@ public class TestPagodaFLY {
49 pagoda.run(); 51 pagoda.run();
50 CheckAnswers.assertSameAnswers(answers, givenAnswers); 52 CheckAnswers.assertSameAnswers(answers, givenAnswers);
51 } 53 }
54
55 @Test(groups = {"light", "justExecute"})
56 public void justExecute_newQueries() throws IOException {
57 String ontoDir = TestUtil.getConfig().getProperty("ontoDir");
58
59 Pagoda pagoda = Pagoda.builder()
60 .ontology(Paths.get(ontoDir, "fly/fly_rolledUp.owl"))
61// .ontology(Paths.get(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"))
62 .query(Paths.get(ontoDir, "fly/queries/new_queries.sparql"))
63// .answer(Paths.get("/home/alessandro/Desktop/answers.json"))
64 .classify(false)
65 .hermit(true)
66 .skolem(false)
67 .build();
68
69 pagoda.run();
70 }
71
72 @Test(groups = {"light", "comparison"})
73 public void compare_newQueries() throws IOException {
74 String ontoDir = TestUtil.getConfig().getProperty("ontoDir");
75
76 Timer timer = new Timer();
77 Pagoda.builder()
78 .ontology(Paths.get(ontoDir, "fly/fly_rolledUp.owl"))
79 .query(Paths.get(ontoDir, "fly/queries/new_queries.sparql"))
80 .classify(false)
81 .hermit(true)
82 .skolem(true) // <----<< Skolem upper bound is ENABLED <<<
83 .build()
84 .run();
85 double t1 = timer.duration();
86
87 timer.reset();
88
89 Pagoda.builder()
90 .ontology(Paths.get(ontoDir, "fly/fly_rolledUp.owl"))
91 .query(Paths.get(ontoDir, "fly/queries/new_queries.sparql"))
92 .classify(false)
93 .hermit(true)
94 .skolem(false) // <----<< Skolem upper bound is DISABLED <<<
95 .build()
96 .run();
97 double t2 = timer.duration();
98
99 if(t1 < t2)
100 TestUtil.logInfo("Overall reasoning with Skolem upper bound was " + (int) (t2 / t1 * 100 - 100) + "x faster!");
101 else
102 TestUtil.logInfo("Overall reasoning with Skolem upper bound was " + (int) (t1 / t2 * 100 - 100) + "x slower...");
103 }
52} 104}
diff --git a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java
index c3909d5..fdd242a 100644
--- a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java
+++ b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java
@@ -22,7 +22,7 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
22public class TestUtil { 22public class TestUtil {
23 23
24 public static final String CONFIG_FILE = "test.properties"; 24 public static final String CONFIG_FILE = "test.properties";
25 25 private static final Logger LOGGER = Logger.getLogger("Tester");
26 private static boolean isConfigLoaded = false; 26 private static boolean isConfigLoaded = false;
27 private static Properties config; 27 private static Properties config;
28 28
@@ -71,4 +71,20 @@ public class TestUtil {
71 return Paths.get(givenAnswersURL.getPath()); 71 return Paths.get(givenAnswersURL.getPath());
72 } 72 }
73 73
74 public static void logInfo(Object msg) {
75 LOGGER.info(msg);
76 }
77
78 public static void logDebug(Object msg) {
79 LOGGER.debug(msg);
80 }
81
82 public static void logError(Object msg) {
83 LOGGER.error(msg);
84 }
85
86 public static void logError(Object msg, Throwable t) {
87 LOGGER.error(msg, t);
88 }
89
74} 90}