diff options
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index a393474..8a90a26 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |||
| @@ -2,6 +2,7 @@ package uk.ac.ox.cs.pagoda.reasoner; | |||
| 2 | 2 | ||
| 3 | import org.semanticweb.karma2.profile.ELHOProfile; | 3 | import org.semanticweb.karma2.profile.ELHOProfile; |
| 4 | import org.semanticweb.owlapi.model.OWLOntology; | 4 | import org.semanticweb.owlapi.model.OWLOntology; |
| 5 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; | ||
| 5 | import uk.ac.ox.cs.pagoda.multistage.MultiStageQueryEngine; | 6 | import uk.ac.ox.cs.pagoda.multistage.MultiStageQueryEngine; |
| 6 | import uk.ac.ox.cs.pagoda.owl.EqualitiesEliminator; | 7 | import uk.ac.ox.cs.pagoda.owl.EqualitiesEliminator; |
| 7 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | 8 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; |
| @@ -18,6 +19,7 @@ import uk.ac.ox.cs.pagoda.tracking.QueryTracker; | |||
| 18 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; | 19 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; |
| 19 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderDisjVar1; | 20 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderDisjVar1; |
| 20 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderWithGap; | 21 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderWithGap; |
| 22 | import uk.ac.ox.cs.pagoda.util.ExponentialInterpolation; | ||
| 21 | import uk.ac.ox.cs.pagoda.util.PagodaProperties; | 23 | import uk.ac.ox.cs.pagoda.util.PagodaProperties; |
| 22 | import uk.ac.ox.cs.pagoda.util.Timer; | 24 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 23 | import uk.ac.ox.cs.pagoda.util.Utility; | 25 | import uk.ac.ox.cs.pagoda.util.Utility; |
| @@ -25,6 +27,7 @@ import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | |||
| 25 | import uk.ac.ox.cs.pagoda.util.tuples.Tuple; | 27 | import uk.ac.ox.cs.pagoda.util.tuples.Tuple; |
| 26 | 28 | ||
| 27 | import java.util.Collection; | 29 | import java.util.Collection; |
| 30 | import java.util.LinkedList; | ||
| 28 | 31 | ||
| 29 | class MyQueryReasoner extends QueryReasoner { | 32 | class MyQueryReasoner extends QueryReasoner { |
| 30 | 33 | ||
| @@ -399,8 +402,32 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 399 | relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram); | 402 | relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram); |
| 400 | 403 | ||
| 401 | boolean isFullyProcessed = false; | 404 | boolean isFullyProcessed = false; |
| 402 | for (int currentMaxTermDepth = 1; | 405 | LinkedList<Tuple<Long>> lastTwoTriplesCounts = new LinkedList<>(); |
| 403 | currentMaxTermDepth <= properties.getSkolemDepth() && !isFullyProcessed; currentMaxTermDepth++) { | 406 | for (int currentMaxTermDepth = 1; !isFullyProcessed; currentMaxTermDepth++) { |
| 407 | |||
| 408 | if(currentMaxTermDepth > properties.getSkolemDepth()) { | ||
| 409 | Utility.logInfo("Maximum term depth reached"); | ||
| 410 | break; | ||
| 411 | } | ||
| 412 | |||
| 413 | if(lastTwoTriplesCounts.size() == 2) { | ||
| 414 | if(lastTwoTriplesCounts.get(0).get(1).equals(lastTwoTriplesCounts.get(1).get(1))) | ||
| 415 | break; | ||
| 416 | |||
| 417 | ExponentialInterpolation interpolation = new ExponentialInterpolation(lastTwoTriplesCounts.get(0).get(0), | ||
| 418 | lastTwoTriplesCounts.get(0).get(1), | ||
| 419 | lastTwoTriplesCounts.get(1).get(0), | ||
| 420 | lastTwoTriplesCounts.get(1).get(1)); | ||
| 421 | double triplesEstimate = interpolation.computeValue(currentMaxTermDepth); | ||
| 422 | |||
| 423 | Utility.logDebug("Estimate of the number of triples:" + triplesEstimate); | ||
| 424 | |||
| 425 | // exit condition if the query is not fully answered | ||
| 426 | if(triplesEstimate > properties.getMaxTriplesInSkolemStore()) { | ||
| 427 | Utility.logInfo("Interrupting Semi-Skolemisation because of triples count limit"); | ||
| 428 | break; | ||
| 429 | } | ||
| 430 | } | ||
| 404 | 431 | ||
| 405 | Utility.logInfo("Trying with maximum depth " + currentMaxTermDepth); | 432 | Utility.logInfo("Trying with maximum depth " + currentMaxTermDepth); |
| 406 | 433 | ||
| @@ -408,18 +435,31 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 408 | currentMaxTermDepth); | 435 | currentMaxTermDepth); |
| 409 | queryRecord.addProcessingTime(Step.SKOLEM_UPPER_BOUND, t.duration()); | 436 | queryRecord.addProcessingTime(Step.SKOLEM_UPPER_BOUND, t.duration()); |
| 410 | if(materialisationTag == -1) { | 437 | if(materialisationTag == -1) { |
| 438 | relevantStore.dispose(); | ||
| 411 | throw new Error("A consistent ontology has turned out to be " + | 439 | throw new Error("A consistent ontology has turned out to be " + |
| 412 | "inconsistent in the Skolemises-relevant-upper-store"); | 440 | "inconsistent in the Skolemises-relevant-upper-store"); |
| 413 | } | 441 | } |
| 414 | else if(materialisationTag != 1) { | 442 | else if(materialisationTag != 1) { |
| 415 | Utility.logInfo("Semi-Skolemised relevant upper store cannot be employed"); | 443 | Utility.logInfo("Semi-Skolemised relevant upper store cannot be employed"); |
| 416 | return false; | 444 | break; |
| 417 | } | 445 | } |
| 418 | 446 | ||
| 419 | Utility.logInfo("Querying semi-Skolemised upper store..."); | 447 | Utility.logInfo("Querying semi-Skolemised upper store..."); |
| 420 | isFullyProcessed = queryUpperStore(relevantStore, queryRecord, | 448 | isFullyProcessed = queryUpperStore(relevantStore, queryRecord, |
| 421 | queryRecord.getExtendedQueryText(), | 449 | queryRecord.getExtendedQueryText(), |
| 422 | Step.SKOLEM_UPPER_BOUND); | 450 | Step.SKOLEM_UPPER_BOUND); |
| 451 | |||
| 452 | try { | ||
| 453 | lastTwoTriplesCounts.add | ||
| 454 | (new Tuple<>((long) currentMaxTermDepth, relevantStore.getStoreSize())); | ||
| 455 | } catch (JRDFStoreException e) { | ||
| 456 | e.printStackTrace(); | ||
| 457 | break; | ||
| 458 | } | ||
| 459 | if(lastTwoTriplesCounts.size() > 2) | ||
| 460 | lastTwoTriplesCounts.remove(); | ||
| 461 | |||
| 462 | Utility.logInfo("Last two triples counts:" + lastTwoTriplesCounts); | ||
| 423 | } | 463 | } |
| 424 | 464 | ||
| 425 | relevantStore.dispose(); | 465 | relevantStore.dispose(); |
