diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-07-03 19:09:31 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-07-03 19:09:31 +0100 |
| commit | 39b60d4225f5efa4e0287a2c6ce69d90391c69db (patch) | |
| tree | 18c5b05726f39baa4d3ca8b228e24ad1f0182f2a /src | |
| parent | 133dab6e21f263df2baca913d3d0b7a4fd152d08 (diff) | |
| download | ACQuA-39b60d4225f5efa4e0287a2c6ce69d90391c69db.tar.gz ACQuA-39b60d4225f5efa4e0287a2c6ce69d90391c69db.zip | |
Many little changes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/resources/pagoda.properties | 1 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/Pagoda.java | 58 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/endomorph/plan/OpenEndPlan.java | 9 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/hermit/RuleHelper.java | 2 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | 26 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java | 5 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | 19 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java | 27 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/Program.java | 7 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java | 4 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/clauses/Clause.java | 100 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/clauses/Conjunction.java | 4 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/clauses/DLClause.java | 12 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java | 19 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java | 12 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java | 48 |
16 files changed, 299 insertions, 54 deletions
diff --git a/src/resources/pagoda.properties b/src/resources/pagoda.properties index 64de225..98f8628 100644 --- a/src/resources/pagoda.properties +++ b/src/resources/pagoda.properties | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | debug=true | 1 | debug=true |
| 2 | useAlwaysSimpleUpperBound=false | 2 | useAlwaysSimpleUpperBound=false |
| 3 | useSkolemUpperBound=true | 3 | useSkolemUpperBound=true |
| 4 | toCallHermit=true | ||
| 4 | 5 | ||
| 5 | statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file | 6 | statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file |
diff --git a/src/uk/ac/ox/cs/pagoda/Pagoda.java b/src/uk/ac/ox/cs/pagoda/Pagoda.java index f5dce15..7d2317d 100644 --- a/src/uk/ac/ox/cs/pagoda/Pagoda.java +++ b/src/uk/ac/ox/cs/pagoda/Pagoda.java | |||
| @@ -1,12 +1,21 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda; | 1 | package uk.ac.ox.cs.pagoda; |
| 2 | 2 | ||
| 3 | import org.apache.commons.cli.*; | 3 | import org.apache.commons.cli.*; |
| 4 | import org.apache.commons.io.FilenameUtils; | ||
| 5 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | ||
| 4 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; | 6 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; |
| 5 | import uk.ac.ox.cs.pagoda.util.PagodaProperties; | 7 | import uk.ac.ox.cs.pagoda.util.PagodaProperties; |
| 6 | import uk.ac.ox.cs.pagoda.util.Timer; | 8 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 7 | import uk.ac.ox.cs.pagoda.util.Utility; | 9 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 8 | 10 | ||
| 11 | import java.io.BufferedWriter; | ||
| 12 | import java.io.IOException; | ||
| 13 | import java.nio.file.Files; | ||
| 9 | import java.nio.file.Path; | 14 | import java.nio.file.Path; |
| 15 | import java.nio.file.Paths; | ||
| 16 | import java.util.Collection; | ||
| 17 | import java.util.HashMap; | ||
| 18 | import java.util.Map; | ||
| 10 | 19 | ||
| 11 | /** | 20 | /** |
| 12 | * Executable command line user interface. | 21 | * Executable command line user interface. |
| @@ -23,7 +32,7 @@ public class Pagoda implements Runnable { | |||
| 23 | 32 | ||
| 24 | /** | 33 | /** |
| 25 | * Do not use it | 34 | * Do not use it |
| 26 | * */ | 35 | */ |
| 27 | private Pagoda() { | 36 | private Pagoda() { |
| 28 | properties = new PagodaProperties(); | 37 | properties = new PagodaProperties(); |
| 29 | } | 38 | } |
| @@ -85,7 +94,7 @@ public class Pagoda implements Runnable { | |||
| 85 | 94 | ||
| 86 | /** | 95 | /** |
| 87 | * Get a builder. | 96 | * Get a builder. |
| 88 | * */ | 97 | */ |
| 89 | public static PagodaBuilder builder() { | 98 | public static PagodaBuilder builder() { |
| 90 | return new PagodaBuilder(); | 99 | return new PagodaBuilder(); |
| 91 | } | 100 | } |
| @@ -102,21 +111,48 @@ public class Pagoda implements Runnable { | |||
| 102 | try { | 111 | try { |
| 103 | Timer t = new Timer(); | 112 | Timer t = new Timer(); |
| 104 | pagoda = QueryReasoner.getInstance(properties); | 113 | pagoda = QueryReasoner.getInstance(properties); |
| 105 | if (pagoda == null) return; | 114 | if(pagoda == null) return; |
| 106 | 115 | ||
| 107 | Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); | 116 | Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); |
| 108 | 117 | ||
| 109 | if (properties.getQueryPath() != null) | 118 | if(properties.getQueryPath() != null) { |
| 110 | for (String queryFile: properties.getQueryPath().split(";")) | 119 | for(String queryFile : properties.getQueryPath().split(";")) { |
| 111 | pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile)); | 120 | Collection<QueryRecord> queryRecords = pagoda.getQueryManager().collectQueryRecords(queryFile); |
| 121 | pagoda.evaluate(queryRecords); | ||
| 122 | |||
| 123 | if(PagodaProperties.isDebuggingMode()) { | ||
| 124 | HashMap<String, Map<String, String>> statistics = new HashMap<>(); | ||
| 125 | for(QueryRecord queryRecord : queryRecords) { | ||
| 126 | statistics.put(queryRecord.getQueryID(), queryRecord.getStatistics()); | ||
| 127 | } | ||
| 128 | String statisticsFilename = getStatisticsFilename(properties, queryFile); | ||
| 129 | try(BufferedWriter writer = Files.newBufferedWriter(Paths.get(statisticsFilename))) { | ||
| 130 | QueryRecord.GsonCreator.getInstance().toJson(statistics, writer); | ||
| 131 | } catch(IOException e) { | ||
| 132 | Utility.logError("Unable to save statistics"); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | ||
| 136 | } | ||
| 112 | } finally { | 137 | } finally { |
| 113 | if (pagoda != null) pagoda.dispose(); | 138 | if(pagoda != null) pagoda.dispose(); |
| 114 | } | 139 | } |
| 115 | } | 140 | } |
| 116 | 141 | ||
| 142 | private String getStatisticsFilename(PagodaProperties properties, String queryFile) { | ||
| 143 | String statisticsFilename = "statistics_" + | ||
| 144 | FilenameUtils.removeExtension(FilenameUtils.getName(properties.getOntologyPath().replaceAll("_", "-"))); | ||
| 145 | statisticsFilename += "_" + FilenameUtils.removeExtension(FilenameUtils.getName(queryFile).replaceAll("_", "-")); | ||
| 146 | statisticsFilename += "_" + ((properties.getUseSkolemUpperBound()) ? "skolem" : ""); | ||
| 147 | statisticsFilename += ".json"; | ||
| 148 | statisticsFilename = FilenameUtils.concat(properties.getStatisticsDir().toString(), | ||
| 149 | statisticsFilename); | ||
| 150 | return statisticsFilename; | ||
| 151 | } | ||
| 152 | |||
| 117 | /** | 153 | /** |
| 118 | * Allows to set the parameters before creating a Pagoda instance. | 154 | * Allows to set the parameters before creating a Pagoda instance. |
| 119 | * */ | 155 | */ |
| 120 | public static class PagodaBuilder { | 156 | public static class PagodaBuilder { |
| 121 | 157 | ||
| 122 | private Pagoda instance; | 158 | private Pagoda instance; |
diff --git a/src/uk/ac/ox/cs/pagoda/endomorph/plan/OpenEndPlan.java b/src/uk/ac/ox/cs/pagoda/endomorph/plan/OpenEndPlan.java index 73a27bf..a46da85 100644 --- a/src/uk/ac/ox/cs/pagoda/endomorph/plan/OpenEndPlan.java +++ b/src/uk/ac/ox/cs/pagoda/endomorph/plan/OpenEndPlan.java | |||
| @@ -7,6 +7,7 @@ import uk.ac.ox.cs.pagoda.query.QueryRecord; | |||
| 7 | import uk.ac.ox.cs.pagoda.query.QueryRecord.Step; | 7 | import uk.ac.ox.cs.pagoda.query.QueryRecord.Step; |
| 8 | import uk.ac.ox.cs.pagoda.reasoner.full.Checker; | 8 | import uk.ac.ox.cs.pagoda.reasoner.full.Checker; |
| 9 | import uk.ac.ox.cs.pagoda.summary.NodeTuple; | 9 | import uk.ac.ox.cs.pagoda.summary.NodeTuple; |
| 10 | import uk.ac.ox.cs.pagoda.util.SimpleProgressBar; | ||
| 10 | import uk.ac.ox.cs.pagoda.util.Timer; | 11 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 11 | import uk.ac.ox.cs.pagoda.util.Utility; | 12 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 12 | 13 | ||
| @@ -40,7 +41,11 @@ public class OpenEndPlan implements CheckPlan { | |||
| 40 | Timer t = new Timer(); | 41 | Timer t = new Timer(); |
| 41 | 42 | ||
| 42 | AnswerTuple answerTuple; | 43 | AnswerTuple answerTuple; |
| 43 | while (!topo.isEmpty()) { | 44 | int initialTopoSize = topo.size(); |
| 45 | // TODO test progress bar | ||
| 46 | SimpleProgressBar progressBar = new SimpleProgressBar("Checking", initialTopoSize); | ||
| 47 | while (!topo.isEmpty()) { | ||
| 48 | progressBar.update(initialTopoSize - topo.size()); | ||
| 44 | if (flag) { | 49 | if (flag) { |
| 45 | clique = topo.removeFirst(); | 50 | clique = topo.removeFirst(); |
| 46 | if (redundant(clique)) continue; | 51 | if (redundant(clique)) continue; |
| @@ -70,6 +75,8 @@ public class OpenEndPlan implements CheckPlan { | |||
| 70 | } | 75 | } |
| 71 | } | 76 | } |
| 72 | } | 77 | } |
| 78 | progressBar.update(initialTopoSize - topo.size()); | ||
| 79 | progressBar.dispose(); | ||
| 73 | 80 | ||
| 74 | // Utility.logDebug("HermiT was called " + times + " times."); | 81 | // Utility.logDebug("HermiT was called " + times + " times."); |
| 75 | 82 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/hermit/RuleHelper.java b/src/uk/ac/ox/cs/pagoda/hermit/RuleHelper.java index 530b97f..81c99a4 100644 --- a/src/uk/ac/ox/cs/pagoda/hermit/RuleHelper.java +++ b/src/uk/ac/ox/cs/pagoda/hermit/RuleHelper.java | |||
| @@ -37,7 +37,7 @@ public class RuleHelper { | |||
| 37 | boolean lastSpace = true; | 37 | boolean lastSpace = true; |
| 38 | for (Atom headAtom: clause.getHeadAtoms()) { | 38 | for (Atom headAtom: clause.getHeadAtoms()) { |
| 39 | if ((atomText = getText(headAtom)) == null) continue; | 39 | if ((atomText = getText(headAtom)) == null) continue; |
| 40 | if (!lastSpace) buf.append(" | "); | 40 | if (!lastSpace) buf.append(" v "); |
| 41 | buf.append(atomText); | 41 | buf.append(atomText); |
| 42 | lastSpace = false; | 42 | lastSpace = false; |
| 43 | } | 43 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java index 291af27..d88376f 100644 --- a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java +++ b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | |||
| @@ -171,14 +171,10 @@ public class QueryRecord extends Disposable { | |||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | public String getQueryText() { | 173 | public String getQueryText() { |
| 174 | if(isDisposed()) throw new DisposedException(); | ||
| 175 | |||
| 176 | return queryText; | 174 | return queryText; |
| 177 | } | 175 | } |
| 178 | 176 | ||
| 179 | public String getQueryID() { | 177 | public String getQueryID() { |
| 180 | if(isDisposed()) throw new DisposedException(); | ||
| 181 | |||
| 182 | return stringQueryID; | 178 | return stringQueryID; |
| 183 | } | 179 | } |
| 184 | 180 | ||
| @@ -193,8 +189,6 @@ public class QueryRecord extends Disposable { | |||
| 193 | } | 189 | } |
| 194 | 190 | ||
| 195 | public String toString() { | 191 | public String toString() { |
| 196 | if(isDisposed()) throw new DisposedException(); | ||
| 197 | |||
| 198 | return queryText; | 192 | return queryText; |
| 199 | } | 193 | } |
| 200 | 194 | ||
| @@ -281,6 +275,20 @@ public class QueryRecord extends Disposable { | |||
| 281 | } | 275 | } |
| 282 | } | 276 | } |
| 283 | 277 | ||
| 278 | public Map<String, String> getStatistics() { | ||
| 279 | HashMap<String, String> result = new HashMap<>(); | ||
| 280 | |||
| 281 | double totalTime = 0.0; | ||
| 282 | for(Step step : Step.values()) { | ||
| 283 | result.put(step.toString(), Double.toString(timer[step.ordinal()])); | ||
| 284 | totalTime += timer[step.ordinal()]; | ||
| 285 | } | ||
| 286 | result.put("totalTime", Double.toString(totalTime)); | ||
| 287 | result.put("difficulty", difficulty.toString()); | ||
| 288 | |||
| 289 | return result; | ||
| 290 | } | ||
| 291 | |||
| 284 | public String outputSoundAnswerTuple() { | 292 | public String outputSoundAnswerTuple() { |
| 285 | if(isDisposed()) throw new DisposedException(); | 293 | if(isDisposed()) throw new DisposedException(); |
| 286 | 294 | ||
| @@ -359,6 +367,8 @@ public class QueryRecord extends Disposable { | |||
| 359 | Utility.logError("The answer (" + answer + ") cannot be removed, because it is not in the upper bound."); | 367 | Utility.logError("The answer (" + answer + ") cannot be removed, because it is not in the upper bound."); |
| 360 | gapAnswerTuples.remove(answer); | 368 | gapAnswerTuples.remove(answer); |
| 361 | } | 369 | } |
| 370 | int numOfUpperBoundAnswers = soundAnswerTuples.size() + gapAnswerTuples.size(); | ||
| 371 | Utility.logInfo("Upper bound answers updated: " + numOfUpperBoundAnswers); | ||
| 362 | } | 372 | } |
| 363 | 373 | ||
| 364 | public void addLowerBoundAnswers(Collection<AnswerTuple> answers) { | 374 | public void addLowerBoundAnswers(Collection<AnswerTuple> answers) { |
| @@ -722,7 +732,9 @@ public class QueryRecord extends Disposable { | |||
| 722 | 732 | ||
| 723 | @Override | 733 | @Override |
| 724 | public String toString() { | 734 | public String toString() { |
| 725 | return WordUtils.capitalizeFully(super.toString(), new char[]{'_'}).replace("_", ""); | 735 | String s = super.toString(); |
| 736 | if(s == null) return null; | ||
| 737 | return WordUtils.capitalizeFully(s, new char[]{'_'}).replace("_", ""); | ||
| 726 | } | 738 | } |
| 727 | } | 739 | } |
| 728 | 740 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java b/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java index a09cf5b..116e724 100644 --- a/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java +++ b/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java | |||
| @@ -102,16 +102,17 @@ public class QueryGraph { | |||
| 102 | // return axioms; | 102 | // return axioms; |
| 103 | // } | 103 | // } |
| 104 | 104 | ||
| 105 | public Set<OWLAxiom> getExistentialAxioms() { | 105 | public Set<OWLAxiom> getExistentialAxioms(Map<Variable, Term> assignment) { |
| 106 | if(!rollable_edges.isEmpty()) return null; | 106 | if(!rollable_edges.isEmpty()) return null; |
| 107 | 107 | ||
| 108 | Visitor visitor = new Visitor(factory, assignment); | ||
| 108 | Set<OWLAxiom> axioms = new HashSet<>(); | 109 | Set<OWLAxiom> axioms = new HashSet<>(); |
| 109 | for(Map.Entry<Term, Set<OWLClassExpression>> entry : concepts.map.entrySet()) { | 110 | for(Map.Entry<Term, Set<OWLClassExpression>> entry : concepts.map.entrySet()) { |
| 110 | if(existVars.contains(entry.getKey())) { | 111 | if(existVars.contains(entry.getKey())) { |
| 111 | OWLClassExpression conjunction = | 112 | OWLClassExpression conjunction = |
| 112 | factory.getOWLObjectIntersectionOf(factory.getOWLThing()); | 113 | factory.getOWLObjectIntersectionOf(factory.getOWLThing()); |
| 113 | for(OWLClassExpression owlClassExpression : entry.getValue()) { | 114 | for(OWLClassExpression owlClassExpression : entry.getValue()) { |
| 114 | conjunction = factory.getOWLObjectIntersectionOf(conjunction, owlClassExpression); | 115 | conjunction = factory.getOWLObjectIntersectionOf(conjunction, owlClassExpression.accept(visitor)); |
| 115 | } | 116 | } |
| 116 | axioms.add(factory.getOWLSubClassOfAxiom(conjunction, factory.getOWLNothing())); | 117 | axioms.add(factory.getOWLSubClassOfAxiom(conjunction, factory.getOWLNothing())); |
| 117 | } | 118 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index e5074d5..b419289 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |||
| @@ -68,9 +68,9 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 68 | 68 | ||
| 69 | ontology = o; | 69 | ontology = o; |
| 70 | program = new DatalogProgram(ontology, properties.getToClassify()); | 70 | program = new DatalogProgram(ontology, properties.getToClassify()); |
| 71 | program.getLower().save(); | 71 | // program.getLower().save(); |
| 72 | program.getUpper().save(); | 72 | // program.getUpper().save(); |
| 73 | program.getGeneral().save(); | 73 | // program.getGeneral().save(); |
| 74 | 74 | ||
| 75 | if(!program.getGeneral().isHorn()) | 75 | if(!program.getGeneral().isHorn()) |
| 76 | lazyUpperStore = new MultiStageQueryEngine("lazy-upper-bound", true); | 76 | lazyUpperStore = new MultiStageQueryEngine("lazy-upper-bound", true); |
| @@ -195,19 +195,24 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 195 | 195 | ||
| 196 | Utility.logInfo("Summarisation..."); | 196 | Utility.logInfo("Summarisation..."); |
| 197 | HermitSummaryFilter summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); | 197 | HermitSummaryFilter summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); |
| 198 | if(summarisedChecker.check(queryRecord.getGapAnswers()) == 0) | 198 | if(summarisedChecker.check(queryRecord.getGapAnswers()) == 0) { |
| 199 | summarisedChecker.dispose(); | ||
| 199 | return; | 200 | return; |
| 201 | } | ||
| 200 | 202 | ||
| 201 | if(properties.getUseSkolemUpperBound() && | 203 | if(properties.getUseSkolemUpperBound() && |
| 202 | querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) | 204 | querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) { |
| 205 | summarisedChecker.dispose(); | ||
| 203 | return; | 206 | return; |
| 207 | } | ||
| 204 | 208 | ||
| 205 | Utility.logInfo("Full reasoning..."); | 209 | Utility.logInfo("Full reasoning..."); |
| 206 | Timer t = new Timer(); | 210 | Timer t = new Timer(); |
| 207 | summarisedChecker.checkByFullReasoner(queryRecord.getGapAnswers()); | 211 | summarisedChecker.checkByFullReasoner(queryRecord.getGapAnswers()); |
| 208 | Utility.logDebug("Total time for full reasoner: " + t.duration()); | 212 | Utility.logDebug("Total time for full reasoner: " + t.duration()); |
| 209 | 213 | ||
| 210 | queryRecord.markAsProcessed(); | 214 | if(properties.getToCallHermiT()) |
| 215 | queryRecord.markAsProcessed(); | ||
| 211 | summarisedChecker.dispose(); | 216 | summarisedChecker.dispose(); |
| 212 | } | 217 | } |
| 213 | 218 | ||
| @@ -377,7 +382,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 377 | relevantStore.importDataFromABoxOf(relevantSubset); | 382 | relevantStore.importDataFromABoxOf(relevantSubset); |
| 378 | String relevantOriginalMarkProgram = OWLHelper.getOriginalMarkProgram(relevantSubset); | 383 | String relevantOriginalMarkProgram = OWLHelper.getOriginalMarkProgram(relevantSubset); |
| 379 | 384 | ||
| 380 | int queryDependentMaxTermDepth = 5; // TODO make it dynamic | 385 | int queryDependentMaxTermDepth = 1; // TODO make it dynamic |
| 381 | relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram); | 386 | relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram); |
| 382 | int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null, | 387 | int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null, |
| 383 | queryDependentMaxTermDepth); | 388 | queryDependentMaxTermDepth); |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java index cfae88b..9574845 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java | |||
| @@ -99,7 +99,6 @@ public class HermitChecker extends Checker { | |||
| 99 | 99 | ||
| 100 | if(!toCheck) return false; | 100 | if(!toCheck) return false; |
| 101 | ++noOfCalls; | 101 | ++noOfCalls; |
| 102 | |||
| 103 | if(tag != 0) return tag == 1; | 102 | if(tag != 0) return tag == 1; |
| 104 | if(hermit == null) initialiseReasoner(); | 103 | if(hermit == null) initialiseReasoner(); |
| 105 | 104 | ||
| @@ -107,19 +106,19 @@ public class HermitChecker extends Checker { | |||
| 107 | Map<Variable, Term> sub = answerTuple.getAssignment(answerVariable[1]); | 106 | Map<Variable, Term> sub = answerTuple.getAssignment(answerVariable[1]); |
| 108 | Set<OWLAxiom> toCheckAxioms = qGraph.getAssertions(sub); | 107 | Set<OWLAxiom> toCheckAxioms = qGraph.getAssertions(sub); |
| 109 | 108 | ||
| 110 | // TODO complete | 109 | // // TODO complete |
| 111 | Set<OWLAxiom> toCheckExistentialAxioms = qGraph.getExistentialAxioms(); | 110 | // Set<OWLAxiom> toCheckExistentialAxioms = qGraph.getExistentialAxioms(sub); |
| 112 | 111 | // | |
| 113 | // TODO possibly inefficient | 112 | // // TODO possibly inefficient |
| 114 | for(OWLAxiom subclassAxiom : toCheckExistentialAxioms) { | 113 | // for(OWLAxiom subclassAxiom : toCheckExistentialAxioms) { |
| 115 | Utility.logDebug("Checking consistency of ontology union " + subclassAxiom); | 114 | // Utility.logInfo("Checking consistency of ontology union " + subclassAxiom); |
| 116 | ontology.getOWLOntologyManager().addAxiom(ontology, subclassAxiom); | 115 | // ontology.getOWLOntologyManager().addAxiom(ontology, subclassAxiom); |
| 117 | if(hermit.isConsistent()) { | 116 | // if(hermit.isConsistent()) { |
| 118 | Utility.logDebug("@TIME to check one tuple: " + t.duration()); | 117 | // Utility.logDebug("@TIME to check one tuple: " + t.duration()); |
| 119 | return false; | 118 | // return false; |
| 120 | } | 119 | // } |
| 121 | ontology.getOWLOntologyManager().removeAxiom(ontology, subclassAxiom); | 120 | // ontology.getOWLOntologyManager().removeAxiom(ontology, subclassAxiom); |
| 122 | } | 121 | // } |
| 123 | 122 | ||
| 124 | 123 | ||
| 125 | // for (OWLAxiom axiom: toCheckAxioms) System.out.println(axiom.toString()); | 124 | // for (OWLAxiom axiom: toCheckAxioms) System.out.println(axiom.toString()); |
diff --git a/src/uk/ac/ox/cs/pagoda/rules/Program.java b/src/uk/ac/ox/cs/pagoda/rules/Program.java index 85000e3..a0edf85 100644 --- a/src/uk/ac/ox/cs/pagoda/rules/Program.java +++ b/src/uk/ac/ox/cs/pagoda/rules/Program.java | |||
| @@ -316,9 +316,10 @@ protected PredicateDependency dependencyGraph; | |||
| 316 | private Atom getAtom(OWLObjectPropertyExpression exp, Variable x, Variable y) { | 316 | private Atom getAtom(OWLObjectPropertyExpression exp, Variable x, Variable y) { |
| 317 | if(exp instanceof OWLObjectProperty) | 317 | if(exp instanceof OWLObjectProperty) |
| 318 | return Atom.create(AtomicRole.create(((OWLObjectProperty) exp).toStringID()), x, y); | 318 | return Atom.create(AtomicRole.create(((OWLObjectProperty) exp).toStringID()), x, y); |
| 319 | OWLObjectInverseOf inverseOf; | 319 | // TODO fixed, test it |
| 320 | if(exp instanceof OWLObjectInverseOf && (inverseOf = | 320 | OWLObjectPropertyExpression inverseOf; |
| 321 | (OWLObjectInverseOf) exp).getInverse() instanceof OWLObjectProperty) | 321 | if(exp instanceof OWLObjectInverseOf && (inverseOf = ( |
| 322 | (OWLObjectInverseOf) exp).getInverse()) instanceof OWLObjectProperty) | ||
| 322 | return Atom.create(AtomicRole.create(((OWLObjectProperty) inverseOf).toStringID()), x, y); | 323 | return Atom.create(AtomicRole.create(((OWLObjectProperty) inverseOf).toStringID()), x, y); |
| 323 | return null; | 324 | return null; |
| 324 | } | 325 | } |
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 dfe1e59..d694b61 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 | for(Tuple<Individual> violationTuple : violationTuples) | 67 | for(Tuple<Individual> violationTuple : violationTuples) { |
| 68 | if(getMaxDepth(violationTuple) < maxTermDepth) { | 68 | if(getMaxDepth(violationTuple) < maxTermDepth) { |
| 69 | result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); | 69 | result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); |
| 70 | Utility.logDebug("Approximating maximal individual by a constant in rule:" + originalClause); | 70 | Utility.logDebug("Approximating maximal individual by a constant in rule:" + originalClause); |
| 71 | } | 71 | } |
| 72 | else | 72 | else |
| 73 | result.addAll(alternativeApproximator.convert(clause, originalClause, null)); | 73 | result.addAll(alternativeApproximator.convert(clause, originalClause, null)); |
| 74 | 74 | } | |
| 75 | 75 | ||
| 76 | return result; | 76 | return result; |
| 77 | } | 77 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/rules/clauses/Clause.java b/src/uk/ac/ox/cs/pagoda/rules/clauses/Clause.java new file mode 100644 index 0000000..2adb66b --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/rules/clauses/Clause.java | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.rules.clauses; | ||
| 2 | |||
| 3 | public class Clause { | ||
| 4 | |||
| 5 | // public static final String IF = ":-"; | ||
| 6 | // public static final String OR = "|"; | ||
| 7 | // public static final String AND = ","; | ||
| 8 | // | ||
| 9 | // protected final List<List<Atom>> head; | ||
| 10 | // protected final List<Atom> body; | ||
| 11 | // | ||
| 12 | // protected Clause(Atom[] headAtoms, Atom[] bodyAtoms) { | ||
| 13 | // this.head = Collections.singletonList(Arrays.asList(headAtoms)); | ||
| 14 | // this.body= Arrays.asList(bodyAtoms); | ||
| 15 | // } | ||
| 16 | // | ||
| 17 | // protected Clause(String s) { | ||
| 18 | // this.headAtoms = null; | ||
| 19 | // this.bodyAtoms = null; | ||
| 20 | // } | ||
| 21 | // | ||
| 22 | // public int getHeadLength() { | ||
| 23 | // return headAtoms.length; | ||
| 24 | // } | ||
| 25 | // | ||
| 26 | // public Atom getHeadAtom(int atomIndex) { | ||
| 27 | // return headAtoms[atomIndex]; | ||
| 28 | // } | ||
| 29 | // | ||
| 30 | // public Atom[] getHeadAtoms() { | ||
| 31 | // return headAtoms.clone(); | ||
| 32 | // } | ||
| 33 | // | ||
| 34 | // public int getBodyLength() { | ||
| 35 | // return bodyAtoms.length; | ||
| 36 | // } | ||
| 37 | // | ||
| 38 | // public Atom getBodyAtom(int atomIndex) { | ||
| 39 | // return bodyAtoms[atomIndex]; | ||
| 40 | // } | ||
| 41 | // | ||
| 42 | // public Atom[] getBodyAtoms() { | ||
| 43 | // return bodyAtoms.clone(); | ||
| 44 | // } | ||
| 45 | // | ||
| 46 | // public String toString(Prefixes prefixes) { | ||
| 47 | // StringBuilder buffer = new StringBuilder(); | ||
| 48 | // for(int headIndex = 0; headIndex < headAtoms.length; headIndex++) { | ||
| 49 | // if(headIndex != 0) | ||
| 50 | // buffer.append(" ").append(OR).append(" "); | ||
| 51 | // buffer.append(headAtoms[headIndex].toString(prefixes)); | ||
| 52 | // } | ||
| 53 | // buffer.append(" ").append(IF).append(" "); | ||
| 54 | // for(int bodyIndex = 0; bodyIndex < bodyAtoms.length; bodyIndex++) { | ||
| 55 | // if(bodyIndex != 0) | ||
| 56 | // buffer.append(AND).append(" "); | ||
| 57 | // buffer.append(bodyAtoms[bodyIndex].toString(prefixes)); | ||
| 58 | // } | ||
| 59 | // return buffer.toString(); | ||
| 60 | // } | ||
| 61 | // | ||
| 62 | // public String toString() { | ||
| 63 | // return toString(Prefixes.STANDARD_PREFIXES); | ||
| 64 | // } | ||
| 65 | // | ||
| 66 | // protected static InterningManager<? extends Clause> s_interningManager = new InterningManager<Clause>() { | ||
| 67 | // protected boolean equal(Clause object1, Clause object2) { | ||
| 68 | // if(object1.head.length != object2.headAtoms.length | ||
| 69 | // || object1.bodyAtoms.length != object2.bodyAtoms.length) | ||
| 70 | // return false; | ||
| 71 | // for(int index = object1.headAtoms.length - 1; index >= 0; --index) | ||
| 72 | // if(object1.headAtoms[index] != object2.headAtoms[index]) | ||
| 73 | // return false; | ||
| 74 | // for(int index = object1.bodyAtoms.length - 1; index >= 0; --index) | ||
| 75 | // if(object1.bodyAtoms[index] != object2.bodyAtoms[index]) | ||
| 76 | // return false; | ||
| 77 | // return true; | ||
| 78 | // } | ||
| 79 | // | ||
| 80 | // protected int getHashCode(Clause object) { | ||
| 81 | // int hashCode = 0; | ||
| 82 | // for(int index = object.bodyAtoms.length - 1; index >= 0; --index) | ||
| 83 | // hashCode += object.bodyAtoms[index].hashCode(); | ||
| 84 | // for(int index = object.headAtoms.length - 1; index >= 0; --index) | ||
| 85 | // hashCode += object.headAtoms[index].hashCode(); | ||
| 86 | // return hashCode; | ||
| 87 | // } | ||
| 88 | // }; | ||
| 89 | // | ||
| 90 | // /** | ||
| 91 | // * Creates a clause from a string. | ||
| 92 | // * | ||
| 93 | // * @param s | ||
| 94 | // * @return | ||
| 95 | // */ | ||
| 96 | // public static Clause create(String s) { | ||
| 97 | // return s_interningManager.intern(new Clause(s)); | ||
| 98 | // } | ||
| 99 | |||
| 100 | } | ||
diff --git a/src/uk/ac/ox/cs/pagoda/rules/clauses/Conjunction.java b/src/uk/ac/ox/cs/pagoda/rules/clauses/Conjunction.java new file mode 100644 index 0000000..91bb3e7 --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/rules/clauses/Conjunction.java | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.rules.clauses; | ||
| 2 | |||
| 3 | public class Conjunction { | ||
| 4 | } | ||
diff --git a/src/uk/ac/ox/cs/pagoda/rules/clauses/DLClause.java b/src/uk/ac/ox/cs/pagoda/rules/clauses/DLClause.java new file mode 100644 index 0000000..7394be0 --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/rules/clauses/DLClause.java | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.rules.clauses; | ||
| 2 | |||
| 3 | public class DLClause extends Clause { | ||
| 4 | |||
| 5 | // private DLClause(Atom[] headAtoms, Atom[] bodyAtoms) { | ||
| 6 | // super(headAtoms, bodyAtoms); | ||
| 7 | // } | ||
| 8 | // | ||
| 9 | // public static DLClause create(Atom[] headAtoms, Atom[] bodyAtoms) { | ||
| 10 | // return s_interningManager.intern(new DLClause(headAtoms, bodyAtoms)); | ||
| 11 | // } | ||
| 12 | } | ||
diff --git a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java index 2d2198f..6fcf887 100644 --- a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java +++ b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java | |||
| @@ -6,12 +6,12 @@ import uk.ac.ox.cs.pagoda.endomorph.Endomorph; | |||
| 6 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | 6 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; |
| 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; |
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; |
| 9 | import uk.ac.ox.cs.pagoda.query.AnswerTuplesImp; | ||
| 10 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | 9 | import uk.ac.ox.cs.pagoda.query.QueryRecord; |
| 11 | import uk.ac.ox.cs.pagoda.query.QueryRecord.Step; | 10 | import uk.ac.ox.cs.pagoda.query.QueryRecord.Step; |
| 12 | import uk.ac.ox.cs.pagoda.reasoner.full.Checker; | 11 | import uk.ac.ox.cs.pagoda.reasoner.full.Checker; |
| 13 | import uk.ac.ox.cs.pagoda.reasoner.full.HermitChecker; | 12 | import uk.ac.ox.cs.pagoda.reasoner.full.HermitChecker; |
| 14 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; | 13 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; |
| 14 | import uk.ac.ox.cs.pagoda.util.SimpleProgressBar; | ||
| 15 | import uk.ac.ox.cs.pagoda.util.Timer; | 15 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 16 | import uk.ac.ox.cs.pagoda.util.Utility; | 16 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 17 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | 17 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; |
| @@ -122,12 +122,12 @@ public class HermitSummaryFilter extends Checker { | |||
| 122 | if(m_record.isProcessed()) | 122 | if(m_record.isProcessed()) |
| 123 | return 0; | 123 | return 0; |
| 124 | 124 | ||
| 125 | Utility.logDebug("The number of answers to be checked with HermiT: " + passed.size() + "/" + counter); | 125 | // Utility.logDebug("The number of answers to be checked with HermiT: " + passed.size() + "/" + counter); |
| 126 | m_record.setDifficulty(Step.FULL_REASONING); | 126 | m_record.setDifficulty(Step.FULL_REASONING); |
| 127 | 127 | ||
| 128 | if(summarisedConsistency) | 128 | // if(summarisedConsistency) |
| 129 | return endomorphismChecker.check(new AnswerTuplesImp(m_record.getAnswerVariables(), passed)); | 129 | // return endomorphismChecker.check(new AnswerTuplesImp(m_record.getAnswerVariables(), passed)); |
| 130 | else | 130 | // else |
| 131 | return endomorphismChecker.check(answers); | 131 | return endomorphismChecker.check(answers); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| @@ -145,9 +145,17 @@ public class HermitSummaryFilter extends Checker { | |||
| 145 | Set<AnswerTuple> succ = new HashSet<AnswerTuple>(); | 145 | Set<AnswerTuple> succ = new HashSet<AnswerTuple>(); |
| 146 | Set<AnswerTuple> falsified = new HashSet<AnswerTuple>(), fail = new HashSet<AnswerTuple>(); | 146 | Set<AnswerTuple> falsified = new HashSet<AnswerTuple>(), fail = new HashSet<AnswerTuple>(); |
| 147 | 147 | ||
| 148 | int numOfAnswers = 0; | ||
| 149 | for(; answers.isValid(); answers.moveNext()) { | ||
| 150 | numOfAnswers++; | ||
| 151 | } | ||
| 152 | answers.reset(); | ||
| 153 | |||
| 148 | counter = 0; | 154 | counter = 0; |
| 149 | AnswerTuple representative; | 155 | AnswerTuple representative; |
| 156 | SimpleProgressBar progressBar = new SimpleProgressBar("Summarised checking", numOfAnswers); | ||
| 150 | for(AnswerTuple answer; answers.isValid(); answers.moveNext()) { | 157 | for(AnswerTuple answer; answers.isValid(); answers.moveNext()) { |
| 158 | progressBar.update(counter); | ||
| 151 | ++counter; | 159 | ++counter; |
| 152 | answer = answers.getTuple(); | 160 | answer = answers.getTuple(); |
| 153 | representative = summary.getSummary(answer); | 161 | representative = summary.getSummary(answer); |
| @@ -164,6 +172,7 @@ public class HermitSummaryFilter extends Checker { | |||
| 164 | falsified.add(answer); | 172 | falsified.add(answer); |
| 165 | } | 173 | } |
| 166 | } | 174 | } |
| 175 | progressBar.dispose(); | ||
| 167 | answers.dispose(); | 176 | answers.dispose(); |
| 168 | 177 | ||
| 169 | Utility.logDebug("@TIME to filter out non-answers by summarisation: " + t.duration()); | 178 | Utility.logDebug("@TIME to filter out non-answers by summarisation: " + t.duration()); |
diff --git a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java index 4991d0d..7b68400 100644 --- a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java +++ b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java | |||
| @@ -15,6 +15,7 @@ public class PagodaProperties { | |||
| 15 | public static final boolean DEFAULT_DEBUG = false; | 15 | public static final boolean DEFAULT_DEBUG = false; |
| 16 | private static final boolean DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; | 16 | private static final boolean DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; |
| 17 | private static final boolean DEFAULT_USE_SKOLEM_UPPER_BOUND; | 17 | private static final boolean DEFAULT_USE_SKOLEM_UPPER_BOUND; |
| 18 | private static final boolean DEFAULT_TO_CALL_HERMIT; | ||
| 18 | private static final Path DEFAULT_STATISTICS_DIR; | 19 | private static final Path DEFAULT_STATISTICS_DIR; |
| 19 | 20 | ||
| 20 | public static boolean shellModeDefault = false; | 21 | public static boolean shellModeDefault = false; |
| @@ -23,6 +24,7 @@ public class PagodaProperties { | |||
| 23 | static { | 24 | static { |
| 24 | boolean defaultUseAlwaysSimpleUpperBound = false; | 25 | boolean defaultUseAlwaysSimpleUpperBound = false; |
| 25 | boolean defaultUseSkolemUpperBound = true; | 26 | boolean defaultUseSkolemUpperBound = true; |
| 27 | boolean toCallHermit = true; | ||
| 26 | Path defaultStatisticsDir = null; | 28 | Path defaultStatisticsDir = null; |
| 27 | 29 | ||
| 28 | try(InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) { | 30 | try(InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) { |
| @@ -52,12 +54,20 @@ public class PagodaProperties { | |||
| 52 | else | 54 | else |
| 53 | logger.debug("By default the Skolem upper bound is disabled"); | 55 | logger.debug("By default the Skolem upper bound is disabled"); |
| 54 | } | 56 | } |
| 57 | if(config.containsKey("toCallHermit")) { | ||
| 58 | toCallHermit = Boolean.parseBoolean(config.getProperty("toCallHermit")); | ||
| 59 | if(toCallHermit) | ||
| 60 | logger.debug("By default Hermit is enabled"); | ||
| 61 | else | ||
| 62 | logger.debug("By default Hermit is disabled"); | ||
| 63 | } | ||
| 55 | 64 | ||
| 56 | } catch(IOException e) { | 65 | } catch(IOException e) { |
| 57 | e.printStackTrace(); | 66 | e.printStackTrace(); |
| 58 | } | 67 | } |
| 59 | DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND = defaultUseAlwaysSimpleUpperBound; | 68 | DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND = defaultUseAlwaysSimpleUpperBound; |
| 60 | DEFAULT_USE_SKOLEM_UPPER_BOUND = defaultUseSkolemUpperBound; | 69 | DEFAULT_USE_SKOLEM_UPPER_BOUND = defaultUseSkolemUpperBound; |
| 70 | DEFAULT_TO_CALL_HERMIT = toCallHermit; | ||
| 61 | DEFAULT_STATISTICS_DIR = defaultStatisticsDir; | 71 | DEFAULT_STATISTICS_DIR = defaultStatisticsDir; |
| 62 | } | 72 | } |
| 63 | 73 | ||
| @@ -66,7 +76,7 @@ public class PagodaProperties { | |||
| 66 | String queryPath = null; | 76 | String queryPath = null; |
| 67 | String answerPath = null; | 77 | String answerPath = null; |
| 68 | boolean toClassify = true; | 78 | boolean toClassify = true; |
| 69 | boolean toCallHermiT = true; | 79 | boolean toCallHermiT = DEFAULT_TO_CALL_HERMIT; |
| 70 | boolean shellMode = shellModeDefault; | 80 | boolean shellMode = shellModeDefault; |
| 71 | private boolean useAlwaysSimpleUpperBound = DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; | 81 | private boolean useAlwaysSimpleUpperBound = DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; |
| 72 | private boolean useSkolemUpperBound = DEFAULT_USE_SKOLEM_UPPER_BOUND; | 82 | private boolean useSkolemUpperBound = DEFAULT_USE_SKOLEM_UPPER_BOUND; |
diff --git a/src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java b/src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java new file mode 100644 index 0000000..3c4aad7 --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | ||
| 2 | |||
| 3 | import uk.ac.ox.cs.pagoda.util.disposable.Disposable; | ||
| 4 | |||
| 5 | public class SimpleProgressBar extends Disposable { | ||
| 6 | |||
| 7 | private final String name; | ||
| 8 | private int lastPercent; | ||
| 9 | private int maxValue; | ||
| 10 | |||
| 11 | public SimpleProgressBar() { | ||
| 12 | this(""); | ||
| 13 | } | ||
| 14 | |||
| 15 | public SimpleProgressBar(String name) { | ||
| 16 | this(name, 100); | ||
| 17 | } | ||
| 18 | |||
| 19 | public SimpleProgressBar(String name, int maxValue) { | ||
| 20 | this.name = name; | ||
| 21 | this.maxValue = maxValue; | ||
| 22 | } | ||
| 23 | |||
| 24 | public void update(int value) { | ||
| 25 | int percent = value * 100 / maxValue; | ||
| 26 | StringBuilder template = new StringBuilder("\r" + name + " ["); | ||
| 27 | for (int i = 0; i < 50; i++) { | ||
| 28 | if (i < percent * .5) { | ||
| 29 | template.append("="); | ||
| 30 | } else if (i == percent * .5) { | ||
| 31 | template.append(">"); | ||
| 32 | } else { | ||
| 33 | template.append(" "); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | template.append("] %s "); | ||
| 37 | System.out.printf(template.toString(), percent + "%"); | ||
| 38 | System.out.flush(); | ||
| 39 | lastPercent = percent; | ||
| 40 | } | ||
| 41 | |||
| 42 | @Override | ||
| 43 | public void dispose() { | ||
| 44 | super.dispose(); | ||
| 45 | |||
| 46 | System.out.println(); | ||
| 47 | } | ||
| 48 | } | ||
