diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-06-04 18:27:28 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-06-04 18:27:28 +0100 |
| commit | b0148d89a76b8fcbeb2e021442842e4e89690ef3 (patch) | |
| tree | 5fa660dabd4b009c114c522fffd9aaed39a9adde | |
| parent | 51cfc39903ae53cbcaba9a9f5c69cac08ae63fa7 (diff) | |
| download | ACQuA-b0148d89a76b8fcbeb2e021442842e4e89690ef3.tar.gz ACQuA-b0148d89a76b8fcbeb2e021442842e4e89690ef3.zip | |
Fixed terms' depth count in SkolemTermsManager (it was always zero).
8 files changed, 44 insertions, 25 deletions
| @@ -1,4 +1,4 @@ | |||
| 1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 1 | <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" |
| 2 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 2 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 3 | <modelVersion>4.0.0</modelVersion> | 3 | <modelVersion>4.0.0</modelVersion> |
| 4 | <groupId>uk.ac.ox.cs.pagoda</groupId> | 4 | <groupId>uk.ac.ox.cs.pagoda</groupId> |
| @@ -88,6 +88,20 @@ | |||
| 88 | <artifactId>dashboard-maven-plugin</artifactId> | 88 | <artifactId>dashboard-maven-plugin</artifactId> |
| 89 | <version>1.0.0-beta-1</version> | 89 | <version>1.0.0-beta-1</version> |
| 90 | </plugin> | 90 | </plugin> |
| 91 | <plugin> | ||
| 92 | <groupId>org.apache.maven.plugins</groupId> | ||
| 93 | <artifactId>maven-surefire-plugin</artifactId> | ||
| 94 | <version>2.13</version> | ||
| 95 | <configuration> | ||
| 96 | <forkMode>always</forkMode> | ||
| 97 | <systemPropertyVariables> | ||
| 98 | <reporter.debug>false</reporter.debug> | ||
| 99 | </systemPropertyVariables> | ||
| 100 | <suiteXmlFiles> | ||
| 101 | <suiteXmlFile>testResources/LightTests.xml</suiteXmlFile> | ||
| 102 | </suiteXmlFiles> | ||
| 103 | </configuration> | ||
| 104 | </plugin> | ||
| 91 | </plugins> | 105 | </plugins> |
| 92 | </reporting> | 106 | </reporting> |
| 93 | <dependencies> | 107 | <dependencies> |
diff --git a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java index 0987279..af1b413 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java | |||
| @@ -168,6 +168,9 @@ public class MultiStageQueryEngine extends StageQueryEngine { | |||
| 168 | store.makeFactsExplicit(); | 168 | store.makeFactsExplicit(); |
| 169 | subTimer.reset(); | 169 | subTimer.reset(); |
| 170 | oldTripleCount = store.getTriplesCount(); | 170 | oldTripleCount = store.getTriplesCount(); |
| 171 | |||
| 172 | Utility.logInfo("Number of violations: " + violations.size()); | ||
| 173 | |||
| 171 | for(Violation v : violations) { | 174 | for(Violation v : violations) { |
| 172 | 175 | ||
| 173 | Utility.logDebug("Dealing with violation: " + v.constraint); | 176 | Utility.logDebug("Dealing with violation: " + v.constraint); |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index 123bd5e..727f80d 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |||
| @@ -190,7 +190,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 190 | return; | 190 | return; |
| 191 | 191 | ||
| 192 | OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); | 192 | OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); |
| 193 | queryRecord.saveRelevantOntology("/home/alessandro/Desktop/fragment_query" + queryRecord.getQueryID() + ".owl"); | 193 | // queryRecord.saveRelevantOntology("./fragment_query" + queryRecord.getQueryID() + ".owl"); |
| 194 | 194 | ||
| 195 | if(PagodaProperties.getDefaultUseSkolemUpperBound() && | 195 | if(PagodaProperties.getDefaultUseSkolemUpperBound() && |
| 196 | querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) | 196 | querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) |
diff --git a/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java b/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java index dc2ba8a..da67264 100644 --- a/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java +++ b/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java | |||
| @@ -64,14 +64,14 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima | |||
| 64 | 64 | ||
| 65 | private Collection<DLClause> overApprox(DLClause clause, DLClause originalClause, Collection<Tuple<Individual>> violationTuples) { | 65 | private Collection<DLClause> overApprox(DLClause clause, DLClause originalClause, Collection<Tuple<Individual>> violationTuples) { |
| 66 | ArrayList<DLClause> result = new ArrayList<>(); | 66 | ArrayList<DLClause> result = new ArrayList<>(); |
| 67 | |||
| 68 | for(Tuple<Individual> violationTuple : violationTuples) | 67 | for(Tuple<Individual> violationTuple : violationTuples) |
| 69 | if(getMaxDepth(violationTuple) > maxTermDepth) { | 68 | if(getMaxDepth(violationTuple) < maxTermDepth) { |
| 70 | result.addAll(alternativeApproximator.convert(clause, originalClause, null)); | 69 | result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); |
| 71 | Utility.logDebug("Approximating maximal individual by a constant in rule:" + originalClause); | 70 | Utility.logDebug("Approximating maximal individual by a constant in rule:" + originalClause); |
| 72 | } | 71 | } |
| 73 | else | 72 | else |
| 74 | result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); | 73 | result.addAll(alternativeApproximator.convert(clause, originalClause, null)); |
| 74 | |||
| 75 | 75 | ||
| 76 | return result; | 76 | return result; |
| 77 | } | 77 | } |
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 07ad1f9..ef004c4 100644 --- a/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java +++ b/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java | |||
| @@ -21,7 +21,6 @@ public class SkolemTermsManager { | |||
| 21 | private Map<Individual, Integer> individualToDepth_map = new HashMap<>(); | 21 | private Map<Individual, Integer> individualToDepth_map = new HashMap<>(); |
| 22 | private int dependenciesCounter = 0; | 22 | private int dependenciesCounter = 0; |
| 23 | 23 | ||
| 24 | // TODO replace with hashcode. in case of collision you would get only a different upper bound model. | ||
| 25 | private Map<Tuple<Individual>, Integer> dependencyToId_map = new HashMap<>(); | 24 | private Map<Tuple<Individual>, Integer> dependencyToId_map = new HashMap<>(); |
| 26 | 25 | ||
| 27 | private SkolemTermsManager() { | 26 | private SkolemTermsManager() { |
| @@ -49,36 +48,33 @@ public class SkolemTermsManager { | |||
| 49 | 48 | ||
| 50 | /** | 49 | /** |
| 51 | * Get a fresh Individual, unique for the clause, the offset and the dependency. | 50 | * Get a fresh Individual, unique for the clause, the offset and the dependency. |
| 52 | * */ | 51 | */ |
| 53 | public Individual getFreshIndividual(DLClause originalClause, int offset, Tuple<Individual> dependency) { | 52 | public Individual getFreshIndividual(DLClause originalClause, int offset, Tuple<Individual> dependency) { |
| 54 | String termId = Integer.toString(mapClauseToId(originalClause) + offset) | 53 | String termId = Integer.toString(mapClauseToId(originalClause) + offset) |
| 55 | + "_" + mapDependencyToId(dependency); | 54 | + "_" + mapDependencyToId(dependency); |
| 56 | Individual newIndividual = Individual.create(SKOLEMISED_INDIVIDUAL_PREFIX + termId); | 55 | Individual newIndividual = Individual.create(SKOLEMISED_INDIVIDUAL_PREFIX + termId); |
| 57 | 56 | ||
| 58 | int depth = 0; | 57 | int depth = 0; |
| 59 | for (Individual individual : dependency) | 58 | for(Individual individual : dependency) |
| 60 | depth = Integer.max(depth, getDepthOf(individual)); | 59 | depth = Integer.max(depth, getDepthOf(individual)); |
| 61 | individualToDepth_map.put(newIndividual, depth); | 60 | individualToDepth_map.put(newIndividual, depth + 1); |
| 62 | 61 | ||
| 63 | return newIndividual; | 62 | return newIndividual; |
| 64 | } | 63 | } |
| 65 | 64 | ||
| 66 | /** | 65 | /** |
| 67 | * Get a fresh Individual, unique for the clause and the offset. | 66 | * Get a fresh Individual, unique for the clause and the offset. |
| 68 | * */ | 67 | */ |
| 69 | public Individual getFreshIndividual(DLClause originalClause, int offset) { | 68 | public Individual getFreshIndividual(DLClause originalClause, int offset) { |
| 70 | String termId = Integer.toString(mapClauseToId(originalClause) + offset); | 69 | String termId = Integer.toString(mapClauseToId(originalClause) + offset); |
| 71 | Individual newIndividual = Individual.create(SKOLEMISED_INDIVIDUAL_PREFIX + termId); | 70 | return Individual.create(SKOLEMISED_INDIVIDUAL_PREFIX + termId); |
| 72 | // individualToDepth_map.put(newIndividual, 0); // TODO REMOVE | ||
| 73 | |||
| 74 | return newIndividual; | ||
| 75 | } | 71 | } |
| 76 | 72 | ||
| 77 | /** | 73 | /** |
| 78 | * Get the depth of a term. | 74 | * Get the depth of a term. |
| 79 | * <p> | 75 | * <p> |
| 80 | * The term must have been generated by this manager. | 76 | * The term must have been generated by this manager. |
| 81 | * */ | 77 | */ |
| 82 | public int getDepthOf(Individual individual) { | 78 | public int getDepthOf(Individual individual) { |
| 83 | if(individualToDepth_map.containsKey(individual)) return individualToDepth_map.get(individual); | 79 | if(individualToDepth_map.containsKey(individual)) return individualToDepth_map.get(individual); |
| 84 | else return 0; | 80 | else return 0; |
| @@ -86,7 +82,7 @@ public class SkolemTermsManager { | |||
| 86 | 82 | ||
| 87 | /** | 83 | /** |
| 88 | * Get the number of individuals generated by this manager. | 84 | * Get the number of individuals generated by this manager. |
| 89 | * */ | 85 | */ |
| 90 | public int getNumberOfSkolemisedIndividual() { | 86 | public int getNumberOfSkolemisedIndividual() { |
| 91 | return individualToDepth_map.keySet().size(); | 87 | return individualToDepth_map.keySet().size(); |
| 92 | } | 88 | } |
| @@ -107,9 +103,10 @@ public class SkolemTermsManager { | |||
| 107 | 103 | ||
| 108 | private int noOfExistential(DLClause originalClause) { | 104 | private int noOfExistential(DLClause originalClause) { |
| 109 | int no = 0; | 105 | int no = 0; |
| 110 | for (Atom atom : originalClause.getHeadAtoms()) | 106 | for(Atom atom : originalClause.getHeadAtoms()) |
| 111 | if (atom.getDLPredicate() instanceof AtLeast) | 107 | if(atom.getDLPredicate() instanceof AtLeast) |
| 112 | no += ((AtLeast) atom.getDLPredicate()).getNumber(); | 108 | no += ((AtLeast) atom.getDLPredicate()).getNumber(); |
| 113 | return no; | 109 | return no; |
| 114 | } | 110 | } |
| 111 | |||
| 115 | } | 112 | } |
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 3e72748..9139a5d 100644 --- a/src/uk/ac/ox/cs/pagoda/util/tuples/Tuple.java +++ b/src/uk/ac/ox/cs/pagoda/util/tuples/Tuple.java | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util.tuples; | 1 | package uk.ac.ox.cs.pagoda.util.tuples; |
| 2 | 2 | ||
| 3 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
| 4 | import java.util.Collections; | ||
| 4 | import java.util.Iterator; | 5 | import java.util.Iterator; |
| 5 | import java.util.Spliterator; | 6 | import java.util.Spliterator; |
| 6 | import java.util.function.Consumer; | 7 | import java.util.function.Consumer; |
| @@ -11,10 +12,9 @@ public class Tuple<T> implements Iterable<T> { | |||
| 11 | 12 | ||
| 12 | Tuple() { } | 13 | Tuple() { } |
| 13 | 14 | ||
| 15 | @SafeVarargs | ||
| 14 | public Tuple(T... elements) { | 16 | public Tuple(T... elements) { |
| 15 | for(T t: elements) { | 17 | Collections.addAll(this.elements, elements); |
| 16 | this.elements.add(t); | ||
| 17 | } | ||
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | public Tuple(Iterable<T> iterable) { | 20 | public Tuple(Iterable<T> iterable) { |
| @@ -41,4 +41,9 @@ public class Tuple<T> implements Iterable<T> { | |||
| 41 | public Spliterator<T> spliterator() { | 41 | public Spliterator<T> spliterator() { |
| 42 | return elements.spliterator(); | 42 | return elements.spliterator(); |
| 43 | } | 43 | } |
| 44 | |||
| 45 | @Override | ||
| 46 | public int hashCode() { | ||
| 47 | return elements.hashCode() + getClass().hashCode(); | ||
| 48 | } | ||
| 44 | } | 49 | } |
diff --git a/test/resources/LightTests.xml b/test/resources/LightTests.xml index 859e3fa..e260c25 100644 --- a/test/resources/LightTests.xml +++ b/test/resources/LightTests.xml | |||
| @@ -10,10 +10,10 @@ | |||
| 10 | </groups> | 10 | </groups> |
| 11 | 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"/>--> |
| 15 | <!--Fly does not terminate: query-5 looks really hard--> | 15 | <!--Fly does not terminate: query-5 looks really hard--> |
| 16 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/> | 16 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/>--> |
| 17 | </classes> | 17 | </classes> |
| 18 | </test> | 18 | </test> |
| 19 | </suite> \ No newline at end of file | 19 | </suite> \ No newline at end of file |
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 352bcba..4fdccf8 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java | |||
| @@ -12,7 +12,7 @@ import java.nio.file.Paths; | |||
| 12 | 12 | ||
| 13 | public class TestPagodaFLY { | 13 | public class TestPagodaFLY { |
| 14 | 14 | ||
| 15 | @Test(groups = {"light"}) | 15 | // @Test(groups = {"light"}) |
| 16 | public void answersCorrectness_withGJFC() throws IOException { | 16 | public void answersCorrectness_withGJFC() throws IOException { |
| 17 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | 17 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); |
| 18 | Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); | 18 | Path answers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); |
