You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Jan Schäfer <ja...@hs-rm.de> on 2012/07/12 20:14:22 UTC

Slow reasoner update and SWRL problem

Hi all,

I'm having difficulties with my Jena/Pellet environment, as the reasoning after individual removals 
is very slow and my SWRL rules are not evaluated.

This is my setup. I'm using an inferencing model atop a non-inferencing model:
OntModel baseModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
baseModel.addSubModel(onto1.owl);
baseModel.addSubModel(onto2.owl);
baseModel.addSubModel(onto3.owl);
OntModel infModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, baseModel);
infModel.prepare();
// ...add/remove individuals to/from baseModel...
infModel.rebind();
// ...query infModel...

I use the baseModel for adding/removing individuals including their properties and the infModel for 
queries. Here I found out that if I want the reasoner to find inconsistencies, I need a 
infModel.rebind() after each modification to the baseModel (add/remove some individuals). However, 
the rebind() call is fast after adding individuals (it's done almost instantly) and *very* slow 
after individuals have been removed (in my case, sometimes more than 1min), even after only a few 
statements are (bulk) removed. Is there a way to increase the reasoner update speed? Do I really 
have to rebind after each modification (before the next query)?

Maybe a related problem is that the SWRL rules contained in my ontologies are not evaluated at 
runtime (at least I can't query them, nor do i see them in the serialized models). If I serialize my 
runtime ontologies (both baseModel.write() or infModel.write()), I can load either into Protege, run 
Pellet and get the expected results from the rules. Do you know what I'm doing wrong?

Thanks for your help!
Jan

Re: Slow reasoner update and SWRL problem

Posted by Dave Reynolds <da...@gmail.com>.
On 13/07/12 07:58, Jan Schäfer wrote:
> Hi Dave,
>
> thank you for your answer. I'll comment below:
>
> Am 12.07.2012 22:50, schrieb Dave Reynolds:
>> You'll have to ask on the Pellet list for such hints.
> I tried that before posting here, but so far no reaction.
>
>> It's common in other reasoners to be able to process additions
>> incrementally (because the semantics
>> is monotonic) but to process a remove you often have to just start
>> over from scratch. Hence the
>> asymmetry in speed.
> I thought that could be the reason but found it strange that the
> reasoner is able to process the models much faster when it's run first
> (or in Protege) compared to the update after individual removal.

That is very strange. I would have expected rebind to be identical to 
starting with a fresh model. I wonder if the fact that you have changed 
the data "behind the reasoners back" is upsetting it.

You could always try creating a new InfModel over the same base model in 
place of the rebind. If that's also slow then that suggests there is 
something problematic about the specific post-changes data.

>> Normal practice to do do changes through the infModel rather than
>> through the base model. In that
>> case you don't need to do a rebind. It is up to the reasoner to decide
>> when to process the changes.
> The reason I chose to do changes behind the reasoner's back was that I
> thought it might be better to be able to decide myself when to let the
> inference model know about changes. I'll have to think about my approach
> now.

Yes, there's nothing wrong with your approach. Having control yourself 
is good.  The potential trouble with rebind is that it is telling the 
reasoner to start over and so defeats any incremental processing 
options. But it certainly shouldn't be slower than starting over afresh.

Dave



Re: Slow reasoner update and SWRL problem

Posted by Jan Schäfer <ja...@hs-rm.de>.
Hi Dave,

thank you for your answer. I'll comment below:

Am 12.07.2012 22:50, schrieb Dave Reynolds:
> You'll have to ask on the Pellet list for such hints.
I tried that before posting here, but so far no reaction.

> It's common in other reasoners to be able to process additions incrementally (because the semantics
> is monotonic) but to process a remove you often have to just start over from scratch. Hence the
> asymmetry in speed.
I thought that could be the reason but found it strange that the reasoner is able to process the 
models much faster when it's run first (or in Protege) compared to the update after individual 
removal. Also, I saw this approach described on one of the last slides of Evren Sirin's Pellet 
tutorial (http://clarkparsia.com/pellet/tutorial/).

> Normal practice to do do changes through the infModel rather than through the base model. In that
> case you don't need to do a rebind. It is up to the reasoner to decide when to process the changes.
The reason I chose to do changes behind the reasoner's back was that I thought it might be better to 
be able to decide myself when to let the inference model know about changes. I'll have to think 
about my approach now.

Regards,
Jan

Re: Slow reasoner update and SWRL problem

Posted by Dave Reynolds <da...@gmail.com>.
On 12/07/12 19:14, Jan Schäfer wrote:
> Hi all,
>
> I'm having difficulties with my Jena/Pellet environment, as the
> reasoning after individual removals is very slow and my SWRL rules are
> not evaluated.
>
> This is my setup. I'm using an inferencing model atop a non-inferencing
> model:
> OntModel baseModel =
> ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
> baseModel.addSubModel(onto1.owl);
> baseModel.addSubModel(onto2.owl);
> baseModel.addSubModel(onto3.owl);
> OntModel infModel =
> ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC,
> baseModel);
> infModel.prepare();
> // ...add/remove individuals to/from baseModel...
> infModel.rebind();
> // ...query infModel...
>
> I use the baseModel for adding/removing individuals including their
> properties and the infModel for queries. Here I found out that if I want
> the reasoner to find inconsistencies, I need a infModel.rebind() after
> each modification to the baseModel (add/remove some individuals).
> However, the rebind() call is fast after adding individuals (it's done
> almost instantly) and *very* slow after individuals have been removed
> (in my case, sometimes more than 1min), even after only a few statements
> are (bulk) removed. Is there a way to increase the reasoner update
> speed?

You'll have to ask on the Pellet list for such hints.

It's common in other reasoners to be able to process additions 
incrementally (because the semantics is monotonic) but to process a 
remove you often have to just start over from scratch. Hence the 
asymmetry in speed.

> Do I really have to rebind after each modification (before the
> next query)?

Normal practice to do do changes through the infModel rather than 
through the base model. In that case you don't need to do a rebind. It 
is up to the reasoner to decide when to process the changes.

> Maybe a related problem is that the SWRL rules contained in my
> ontologies are not evaluated at runtime (at least I can't query them,
> nor do i see them in the serialized models). If I serialize my runtime
> ontologies (both baseModel.write() or infModel.write()), I can load
> either into Protege, run Pellet and get the expected results from the
> rules. Do you know what I'm doing wrong?

Sorry, again this is a question for the Pellet folks.

Dave