-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuntimeEvaluation.java
More file actions
69 lines (56 loc) · 2.29 KB
/
RuntimeEvaluation.java
File metadata and controls
69 lines (56 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.ai.cre.evaluation;
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import com.ai.cre.algo.RefExpRetrieval;
import com.ai.cre.representation.ConceptReferringExpression;
/**
* Performance test of algorithm where several Horn-ALC ontologies are processed
* and the resulting runtimes measured
*
*/
public class RuntimeEvaluation {
public static void main(String[] args) {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
// load test ontologies from files
List<OWLOntology> ontologies = new LinkedList<>();
File folder = new File("resources/performance");
File[] files = folder.listFiles();
for (File file : files) {
try {
ontologies.add(manager.loadOntologyFromOntologyDocument(file));
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
}
}
// use Top as query, i.e., find every (named and anonymous) individual
OWLClassExpression query = factory.getOWLThing();
// state if existential and universal restrictions should be sorted by means of
// subsumption hierarchies
boolean apply_sorting = true;
int repetitions = 5;
System.out.println("Runtime measurements (average of " + repetitions + " runs):");
System.out.println(
(apply_sorting ? " with" : " without") + " subsumption hierarchies for exist. + univ. restrictions");
Collection<ConceptReferringExpression> answers = null;
for (OWLOntology ontology : ontologies) {
long start = System.currentTimeMillis();
for (int i = 0; i < repetitions; i++) {
answers = new RefExpRetrieval(apply_sorting).getInstanceReferringExpressions(ontology, query);
}
long end = System.currentTimeMillis();
System.out.println(ontology.getOntologyID().getOntologyIRI().get());
System.out.println("time: " + (end - start) / repetitions + " ms");
System.out.println("#answers: " + answers.size());
System.out.println();
}
}
}