aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox/cs/acqua/reasoner
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-16 19:14:37 +0100
committerFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-16 19:14:37 +0100
commit778072331d2d93ef2e3f7800ca300257deb29e65 (patch)
tree7f054929b5f051ce28789170f098aecaa2fddc43 /src/main/scala/uk/ac/ox/cs/acqua/reasoner
parent2ebd0c8c4fd421dd676004e559b69ed8e5c9bb49 (diff)
downloadACQuA-778072331d2d93ef2e3f7800ca300257deb29e65.tar.gz
ACQuA-778072331d2d93ef2e3f7800ca300257deb29e65.zip
Make ACQuA query reasoner depend on RSAComb query reasoner
Diffstat (limited to 'src/main/scala/uk/ac/ox/cs/acqua/reasoner')
-rw-r--r--src/main/scala/uk/ac/ox/cs/acqua/reasoner/AcquaQueryReasoner.scala16
-rw-r--r--src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSACombQueryReasoner.scala60
2 files changed, 52 insertions, 24 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/acqua/reasoner/AcquaQueryReasoner.scala b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/AcquaQueryReasoner.scala
index 0aa5ff2..de6e87c 100644
--- a/src/main/scala/uk/ac/ox/cs/acqua/reasoner/AcquaQueryReasoner.scala
+++ b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/AcquaQueryReasoner.scala
@@ -74,8 +74,8 @@ class AcquaQueryReasoner(val ontology: Ontology)
74 74
75 private val rlLowerStore: BasicQueryEngine = new BasicQueryEngine("rl-lower-bound") 75 private val rlLowerStore: BasicQueryEngine = new BasicQueryEngine("rl-lower-bound")
76 private val elLowerStore: KarmaQueryEngine = new KarmaQueryEngine("elho-lower-bound") 76 private val elLowerStore: KarmaQueryEngine = new KarmaQueryEngine("elho-lower-bound")
77 private lazy val lowerRSAOntology = ontology approximate (new Lowerbound) 77 private lazy val lowerRSAEngine = new RSACombQueryReasoner(ontology, new Lowerbound)
78 private lazy val upperRSAOntology = ontology approximate (new Upperbound) 78 private lazy val upperRSAEngine = new RSACombQueryReasoner(ontology, new Upperbound)
79 79
80 private val trackingStore = new MultiStageQueryEngine("tracking", false); 80 private val trackingStore = new MultiStageQueryEngine("tracking", false);
81 81
@@ -172,8 +172,8 @@ class AcquaQueryReasoner(val ontology: Ontology)
172 /* Force computation of lower RSA approximations and its canonical 172 /* Force computation of lower RSA approximations and its canonical
173 * model. We wait to process the upperbound since it might not be 173 * model. We wait to process the upperbound since it might not be
174 * necessary after all. */ 174 * necessary after all. */
175 lowerRSAOntology.computeCanonicalModel() 175 lowerRSAEngine.preprocess()
176 //upperRSAOntology.computeCanonicalModel() 176 //upperRSAEngine.preprocess()
177 177
178 true 178 true
179 } 179 }
@@ -387,9 +387,7 @@ class AcquaQueryReasoner(val ontology: Ontology)
387 * @returns true if the query is fully answered. 387 * @returns true if the query is fully answered.
388 */ 388 */
389 private def queryRSALowerBound(query: QueryRecord): Boolean = { 389 private def queryRSALowerBound(query: QueryRecord): Boolean = {
390 import uk.ac.ox.cs.acqua.implicits.RSACombAnswerTuples._ 390 lowerRSAEngine evaluate query
391 val answers = lowerRSAOntology ask query
392 query updateLowerBoundAnswers answers
393 query.isProcessed 391 query.isProcessed
394 } 392 }
395 393
@@ -399,9 +397,7 @@ class AcquaQueryReasoner(val ontology: Ontology)
399 * @returns true if the query is fully answered. 397 * @returns true if the query is fully answered.
400 */ 398 */
401 private def queryRSAUpperBound(query: QueryRecord): Boolean = { 399 private def queryRSAUpperBound(query: QueryRecord): Boolean = {
402 import uk.ac.ox.cs.acqua.implicits.RSACombAnswerTuples._ 400 upperRSAEngine evaluate query
403 val answers = upperRSAOntology ask query
404 query updateUpperBoundAnswers answers
405 query.isProcessed 401 query.isProcessed
406 } 402 }
407 403
diff --git a/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSACombQueryReasoner.scala b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSACombQueryReasoner.scala
index 6d89b7b..5acc7cd 100644
--- a/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSACombQueryReasoner.scala
+++ b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSACombQueryReasoner.scala
@@ -44,14 +44,15 @@ class RSACombQueryReasoner(
44 /* Nothing to do */ 44 /* Nothing to do */
45 } 45 }
46 46
47 /** Check consistency and returns whether the ontology is RSA. 47 /** Force computation of canonical model for combined approach in RSA.
48 * 48 *
49 * Preprocessing is performed on instance creation, so no actual work 49 * @returns whether the original ontolgy is RSA.
50 * is being done here.
51 * 50 *
52 * @note Implemented for compatibility with other reasoners. 51 * @note that it is not necessary to call this method since the
52 * preprocessing is performed "on demand" when evaluating a query.
53 */ 53 */
54 def preprocess(): Boolean = { 54 def preprocess(): Boolean = {
55 rsa.computeCanonicalModel()
55 origin.isRSA 56 origin.isRSA
56 } 57 }
57 58
@@ -73,12 +74,12 @@ class RSACombQueryReasoner(
73 * 74 *
74 * TODO: perform logging of answers 75 * TODO: perform logging of answers
75 */ 76 */
76 override def evaluate(queries: Collection[QueryRecord]): Unit = { 77 //override def evaluate(queries: Collection[QueryRecord]): Unit = {
77 val answers = rsa ask queries 78 // val answers = rsa ask queries
78 /* Perform logging */ 79 // /* Perform logging */
79 // Logger write answers 80 // // Logger write answers
80 // Logger.generateSimulationScripts(datapath, queries) 81 // // Logger.generateSimulationScripts(datapath, queries)
81 } 82 //}
82 83
83 /** Evaluates a single query. 84 /** Evaluates a single query.
84 * 85 *
@@ -88,11 +89,42 @@ class RSACombQueryReasoner(
88 * TODO: perform logging of answers 89 * TODO: perform logging of answers
89 */ 90 */
90 def evaluate(query: QueryRecord): Unit = { 91 def evaluate(query: QueryRecord): Unit = {
92 import uk.ac.ox.cs.acqua.implicits.RSACombAnswerTuples._
91 val answers = rsa ask query 93 val answers = rsa ask query
92 /* Perform logging */ 94 query updateLowerBoundAnswers answers
93 // Logger write answers 95 if (toRSA == Noop) {
94 // Logger.generateSimulationScripts(datapath, queries) 96 /* Perform logging
97 * In this case the engine is used as a standalone engine, meaning
98 * that it is time to print out query answers and other related
99 * logging routines.
100 */
101 //Logger write answers
102 //Logger.generateSimulationScripts(datapath, queries)
103 }
95 } 104 }
96 105
97 def evaluateUpper(record: QueryRecord): Unit= ??? 106 /** Evaluates a single query.
107 *
108 * Uses RSAComb internally to reuse part of the computation of
109 * multiple calls to [[uk.ac.ox.cs.rsacomb.RSAOntology.ask]].
110 *
111 * @note the result of the computation is saved in the "upper bound"
112 * of the input query record.
113 *
114 * TODO: perform logging of answers
115 */
116 def evaluateUpper(query: QueryRecord): Unit = {
117 import uk.ac.ox.cs.acqua.implicits.RSACombAnswerTuples._
118 val answers = rsa ask query
119 query updateUpperBoundAnswers answers
120 if (toRSA == Noop) {
121 /* Perform logging
122 * In this case the engine is used as a standalone engine, meaning
123 * that it is time to print out query answers and other related
124 * logging routines.
125 */
126 //Logger write answers
127 //Logger.generateSimulationScripts(datapath, queries)
128 }
129 }
98} 130}