[Pellet-users] Slow reasoning & getting status info

Evren Sirin evren at clarkparsia.com
Thu Mar 29 16:24:25 UTC 2007


Sorry, being late to the discussion. See by reply below...

On 3/29/07 11:26 AM, Rinke Hoekstra wrote:
> Hi Holger, others,
>
> Holger Knublauch wrote:
>> Rinke Hoekstra wrote:
>
>  * snip *
>
>>
>> Here is a test case to illustrate this:
>>
>> public class RinkeTestCase extends TestCase {
>>
>>     public void testRinke() {
>>         OntModel ontModel = 
>> ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
>>         
>> ontModel.read("http://www.estrellaproject.org/lkif-core/lkif-core.owl");
>>         OntModelSpec spec = PelletReasonerFactory.THE_SPEC;
>>         InfModel infModel = ModelFactory.createOntologyModel(spec, 
>> ontModel);
>>         long startTime = System.currentTimeMillis();
>>         int count = 0;
>>         StmtIterator it = infModel.listStatements();
>>         while(it.hasNext()) {
>>             it.nextStatement();
>>             count++;
>>         }
>>         long endTime = System.currentTimeMillis();
>>         System.out.println("Elapsed: " + (endTime - startTime));
>>     }
>> }
>
> I had a look at your code and compared it to Pellet.java in the Pellet 
> 1.4 distribution. Differences are that TB creates an OntModel, loads 
> the file, then creates an InfModel with a PeleltReasoner, and iterates 
> over all statements. Pellet on the other hand, loads the file into a 
> regular Model and then creates an OntModel with the reasoner and the 
> Model, but does not iterate over the statements in that model. 
Yes, that's correct. model.listStatements will reuten *all* possible 
inferences that Pellet can find. This includes subclasses, equivalent 
classes, disjoints, complements, types for individuals, property 
relations, etc. It is normal that this function call is slow and I don't 
recommend using it unless you really need all the information, e.g. you 
might do it if you want to materialize all the inferences in a plain RDF 
model.
> They rather 'extract' the reasoner from the created OntModel, call 
> classify() and realize(), again extract a model from the reasoner and 
> *then* iterate over the statements.
Yes, the command line version only classifies and realizes (finds the 
types for individuals) and nothing more.
>
> See testRinke2 and testRinke3 below. The first just adjusts the TB way 
> of handling the model to the Pellet way, but still iterates over the 
> original model (slow). The second only iterates over the model which 
> is given back by the reasoner (really fast).
>
> The first gives back thousands of statements (I added a counter), and 
> the second returns only 11 (?).
The first number makes sense but the second one is not right simply 
because you are missing a oModel.prepare(); after creating the ontology 
model. Accessing the KnowledgeBase inside PelletInfGraph can be tricky. 
If you don't explicitly call the prepare function the underlying KB will 
not see anything that has been read into the Jena model.

It might be easier to stick to Jena model rather than going into the 
details of Pellet classes. You only need to ask a more concentrated 
query as in model.listStatements( null, RDF.subClassOf, null) which will 
only trigger a classification and return all the inferred subclass 
relations.

Also since LKIF contains imported ontologies retrieving each ontology, 
parsing and processing RDF statements takes considerable time (network 
latency, XML parsing, etc.). When I tried right now, loading seemed to 
take more than the classification itself.

Cheers,
Evren
>
> Hmmm
>
>
> -Rinke
>
>
>
>     public void testRinke2() {
>         Model pModel = null;
>         ModelReader modelReader = new ModelReader();
>         pModel = 
> modelReader.read("http://www.estrellaproject.org/lkif-core/lkif-core.owl"); 
>
>         System.out.println("Read ontology");
>
>         long startTime1 = System.currentTimeMillis();       
>         OntModel oModel;
>
>         oModel = 
> ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, pModel);
>         System.out.println("Created Ontology Model");
>         OWLReasoner reasoner = ((PelletInfGraph) 
> oModel.getGraph()).getOWLReasoner();
>         System.out.println("Got back my reasoner");
>         long endTime1 = System.currentTimeMillis();
>         System.out.println("Elapsed: " + (endTime1 - startTime1));
>        
>         long startTime = System.currentTimeMillis();
>         int count = 0;
>         StmtIterator it = oModel.listStatements();
>        
>         while(it.hasNext()) {
>             it.nextStatement();
>             count++;
>             System.out.println(count);
>         }
>         long endTime = System.currentTimeMillis();
>         System.out.println("Elapsed: " + (endTime - startTime));
>        
>        
>     }
>
>
>     public void testRinke3() {
>         Model pModel = null;
>         ModelReader modelReader = new ModelReader();
>         pModel = 
> modelReader.read("http://www.estrellaproject.org/lkif-core/lkif-core.owl"); 
>
>         System.out.println("Read ontology");
>
>         long startTime1 = System.currentTimeMillis();       
>         OntModel oModel;
>
>         oModel = 
> ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, pModel);
>         System.out.println("Created Ontology Model");
>         OWLReasoner reasoner = ((PelletInfGraph) 
> oModel.getGraph()).getOWLReasoner();
>         System.out.println("Got back my reasoner");
>         long endTime1 = System.currentTimeMillis();
>         System.out.println("Elapsed: " + (endTime1 - startTime1));
>        
>         long startTime = System.currentTimeMillis();
>         int count = 0;
>        
>         reasoner.classify();
>         reasoner.realize();
>        
>         Model eModel = reasoner.extractModel(false); // not verbose
>        
>         StmtIterator it = eModel.listStatements();
>        
>         while(it.hasNext()) {
>             it.nextStatement();
>             count++;
>             System.out.println(count);
>         }
>         long endTime = System.currentTimeMillis();
>         System.out.println("Elapsed: " + (endTime - startTime));
>        
>        
>     }
>
>
>
>>
>> This is similar to what we are doing in TopBraid, and it really takes 
>> minutes to list all triples.  The messages
>>
>> Sub Count: 13786
>> Sat Count: 83
>>
>> are printed out after 30 seconds, similar to what Rinke states, but 
>> then it becomes very slow.
>>
>> Assuming Rinke's command line test does a comparable job, then either 
>> the Pellet-Jena bridge is very inefficient or I am creating the model 
>> in a wrong way.  Please advise.
>>
>> Thanks,
>> Holger
>> _______________________________________________
>> Pellet-users mailing list
>> Pellet-users at lists.owldl.com
>> http://lists.owldl.com/mailman/listinfo/pellet-users
>> _______________________________________________
>>
>> Sponsored by Clark & Parsia, LLC http://clarkparsia.com/
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pellet-users mailing list
> Pellet-users at lists.owldl.com
> http://lists.owldl.com/mailman/listinfo/pellet-users
> _______________________________________________
>
> Sponsored by Clark & Parsia, LLC http://clarkparsia.com/



More information about the Pellet-users mailing list