aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java114
1 files changed, 56 insertions, 58 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java
index 409a2c9..ef9338a 100644
--- a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java
+++ b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java
@@ -30,43 +30,42 @@ public class ConsistencyManager {
30 protected MyQueryReasoner m_reasoner; 30 protected MyQueryReasoner m_reasoner;
31 protected QueryManager m_queryManager; 31 protected QueryManager m_queryManager;
32 32
33 Timer t = new Timer(); 33 Timer t = new Timer();
34 QueryRecord fullQueryRecord;
35 QueryRecord[] botQueryRecords;
36 LinkedList<DLClause> toAddClauses;
37 boolean fragmentExtracted = false;
34 38
35 public ConsistencyManager(MyQueryReasoner reasoner) { 39 public ConsistencyManager(MyQueryReasoner reasoner) {
36 m_reasoner = reasoner; 40 m_reasoner = reasoner;
37 m_queryManager = reasoner.getQueryManager(); 41 m_queryManager = reasoner.getQueryManager();
38 } 42 }
39 43
40 QueryRecord fullQueryRecord;
41 QueryRecord[] botQueryRecords;
42
43 LinkedList<DLClause> toAddClauses;
44
45 boolean checkRLLowerBound() { 44 boolean checkRLLowerBound() {
46 fullQueryRecord = m_queryManager.create(QueryRecord.botQueryText, 0); 45 fullQueryRecord = m_queryManager.create(QueryRecord.botQueryText, 0);
47 AnswerTuples iter = null; 46 AnswerTuples iter = null;
48 47
49 try { 48 try {
50 iter = m_reasoner.rlLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); 49 iter = m_reasoner.rlLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables());
51 fullQueryRecord.updateLowerBoundAnswers(iter); 50 fullQueryRecord.updateLowerBoundAnswers(iter);
52 } finally { 51 } finally {
53 iter.dispose(); 52 iter.dispose();
54 } 53 }
55 54
56 if (fullQueryRecord.getNoOfSoundAnswers() > 0) { 55 if (fullQueryRecord.getNoOfSoundAnswers() > 0) {
57 Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); 56 Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple());
58 return false; 57 return false;
59 } 58 }
60 return true; 59 return true;
61 } 60 }
62 61
63 boolean checkELLowerBound() { 62 boolean checkELLowerBound() {
64 fullQueryRecord.updateLowerBoundAnswers(m_reasoner.elLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables())); 63 fullQueryRecord.updateLowerBoundAnswers(m_reasoner.elLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()));
65 if (fullQueryRecord.getNoOfSoundAnswers() > 0) { 64 if (fullQueryRecord.getNoOfSoundAnswers() > 0) {
66 Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); 65 Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple());
67 return true; 66 return true;
68 } 67 }
69 return true; 68 return true;
70 } 69 }
71 70
72 boolean checkUpper(BasicQueryEngine upperStore) { 71 boolean checkUpper(BasicQueryEngine upperStore) {
@@ -91,65 +90,64 @@ public class ConsistencyManager {
91 fullQueryRecord.dispose(); 90 fullQueryRecord.dispose();
92 } 91 }
93 92
93// protected boolean unsatisfiability(double duration) {
94// fullQueryRecord.dispose();
95// Utility.logDebug("The ontology and dataset is unsatisfiable.");
96// return false;
97// }
98
99// protected boolean satisfiability(double duration) {
100// fullQueryRecord.dispose();
101// Utility.logDebug("The ontology and dataset is satisfiable.");
102// return true;
103// }
104
94 boolean check() { 105 boolean check() {
95// if (!checkRLLowerBound()) return false; 106// if (!checkRLLowerBound()) return false;
96// if (!checkELLowerBound()) return false; 107// if (!checkELLowerBound()) return false;
97// if (checkLazyUpper()) return true; 108// if (checkLazyUpper()) return true;
98 AnswerTuples iter = null; 109 AnswerTuples iter = null;
99 110
100 try { 111 try {
101 iter = m_reasoner.trackingStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); 112 iter =
113 m_reasoner.trackingStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables());
102 fullQueryRecord.updateUpperBoundAnswers(iter); 114 fullQueryRecord.updateUpperBoundAnswers(iter);
103 } finally { 115 } finally {
104 if (iter != null) iter.dispose(); 116 if(iter != null) iter.dispose();
105 } 117 }
106 118
107 if (fullQueryRecord.getNoOfCompleteAnswers() == 0) 119 if(fullQueryRecord.getNoOfCompleteAnswers() == 0)
108 return true; 120 return true;
109 121
110 extractBottomFragment(); 122 extractBottomFragment();
111 123
112 try { 124 try {
113 extractAxioms4Full(); 125 extractAxioms4Full();
114 } catch (OWLOntologyCreationException e) { 126 } catch(OWLOntologyCreationException e) {
115 e.printStackTrace(); 127 e.printStackTrace();
116 } 128 }
117// fullQueryRecord.saveRelevantClause(); 129// fullQueryRecord.saveRelevantClause();
118 130
119 boolean satisfiability; 131 boolean satisfiability;
120 132
121 Checker checker; 133 Checker checker;
122 for (QueryRecord r: getQueryRecords()) { 134 for(QueryRecord r : getQueryRecords()) {
123 // TODO to be removed ... 135 // TODO to be removed ...
124// r.saveRelevantOntology("bottom" + r.getQueryID() + ".owl"); 136// r.saveRelevantOntology("bottom" + r.getQueryID() + ".owl");
125 checker = new HermitSummaryFilter(r, true); // m_reasoner.factory.getSummarisedReasoner(r); 137 checker = new HermitSummaryFilter(r, true); // m_reasoner.factory.getSummarisedReasoner(r);
126 satisfiability = checker.isConsistent(); 138 satisfiability = checker.isConsistent();
127 checker.dispose(); 139 checker.dispose();
128 if (!satisfiability) return false; 140 if(!satisfiability) return false;
129 } 141 }
130 142
131// Checker checker = m_reasoner.factory.getSummarisedReasoner(fullQueryRecord); 143// Checker checker = m_reasoner.factory.getSummarisedReasoner(fullQueryRecord);
132// boolean satisfiable = checker.isConsistent(); 144// boolean satisfiable = checker.isConsistent();
133// checker.dispose(); 145// checker.dispose();
134// if (!satisfiable) return unsatisfiability(t.duration()); 146// if (!satisfiable) return unsatisfiability(t.duration());
135 147
136 return true; 148 return true;
137 } 149 }
138 150
139// protected boolean unsatisfiability(double duration) {
140// fullQueryRecord.dispose();
141// Utility.logDebug("The ontology and dataset is unsatisfiable.");
142// return false;
143// }
144
145// protected boolean satisfiability(double duration) {
146// fullQueryRecord.dispose();
147// Utility.logDebug("The ontology and dataset is satisfiable.");
148// return true;
149// }
150
151 boolean fragmentExtracted = false;
152
153 public void extractBottomFragment() { 151 public void extractBottomFragment() {
154 if (fragmentExtracted) return ; 152 if (fragmentExtracted) return ;
155 fragmentExtracted = true; 153 fragmentExtracted = true;
@@ -179,7 +177,7 @@ public class ConsistencyManager {
179 int[] group = new int[number - 1]; 177 int[] group = new int[number - 1];
180 for (int i = 0; i < number - 1; ++i) group[i] = i; 178 for (int i = 0; i < number - 1; ++i) group[i] = i;
181 for (int i = 0; i < number - 1; ++i) 179 for (int i = 0; i < number - 1; ++i)
182 if (tempQueryRecords[i].processed()) tempQueryRecords[i].dispose(); 180 if(tempQueryRecords[i].isProcessed()) tempQueryRecords[i].dispose();
183 else if (group[i] == i) { 181 else if (group[i] == i) {
184 ++bottomNumber; 182 ++bottomNumber;
185 record = tempQueryRecords[i]; 183 record = tempQueryRecords[i];
@@ -193,8 +191,8 @@ public class ConsistencyManager {
193 int bottomCounter = 0; 191 int bottomCounter = 0;
194 botQueryRecords = new QueryRecord[bottomNumber]; 192 botQueryRecords = new QueryRecord[bottomNumber];
195 Variable X = Variable.create("X"); 193 Variable X = Variable.create("X");
196 for (int i = 0; i < number - 1; ++i) 194 for (int i = 0; i < number - 1; ++i)
197 if (!tempQueryRecords[i].processed()) 195 if(!tempQueryRecords[i].isProcessed())
198 if (group[i] == i) { 196 if (group[i] == i) {
199 botQueryRecords[bottomCounter] = record = tempQueryRecords[i]; 197 botQueryRecords[bottomCounter] = record = tempQueryRecords[i];
200 record.resetInfo(QueryRecord.botQueryText.replace("Nothing", "Nothing_final" + (++bottomCounter)), 0, group[i] = bottomCounter); 198 record.resetInfo(QueryRecord.botQueryText.replace("Nothing", "Nothing_final" + (++bottomCounter)), 0, group[i] = bottomCounter);