The reasoning never ends?

60 views
Skip to first unread message

Ehsan Majidi

unread,
Oct 31, 2016, 5:24:14 AM10/31/16
to HermiT Users
I have created several ontologies and almost all of them can be reasoned using the following code (OWL api and Hermit) except the ontology attached here which is not very different from the other ones in size and structure.

package Reasoning.ReasonRDF;

import java.io.File;
import java.util.*;

import org.semanticweb.HermiT.Configuration;
import org.semanticweb.HermiT.Reasoner;
import org.semanticweb.HermiT.ReasonerFactory;
//import org.semanticweb.HermiT.Reasoner;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLIndividualAxiom;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.model.OWLOntologyStorageException;
import org.semanticweb.owlapi.reasoner.*;
import org.semanticweb.owlapi.reasoner.ConsoleProgressMonitor;
import org.semanticweb.owlapi.reasoner.NodeSet;
import org.semanticweb.owlapi.reasoner.OWLReasoner;
import org.semanticweb.owlapi.reasoner.OWLReasonerConfiguration;
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
import org.semanticweb.owlapi.reasoner.SimpleConfiguration;
import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory;
import org.semanticweb.owlapi.util.InferredAxiomGenerator;
import org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator;
import org.semanticweb.owlapi.util.InferredClassAxiomGenerator;
import org.semanticweb.owlapi.util.InferredDataPropertyCharacteristicAxiomGenerator;
import org.semanticweb.owlapi.util.InferredEquivalentClassAxiomGenerator;
import org.semanticweb.owlapi.util.InferredIndividualAxiomGenerator;
import org.semanticweb.owlapi.util.InferredInverseObjectPropertiesAxiomGenerator;
import org.semanticweb.owlapi.util.InferredObjectPropertyCharacteristicAxiomGenerator;
import org.semanticweb.owlapi.util.InferredOntologyGenerator;
import org.semanticweb.owlapi.util.InferredPropertyAssertionGenerator;
import org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator;
import org.semanticweb.owlapi.util.InferredSubDataPropertyAxiomGenerator;
import org.semanticweb.owlapi.util.InferredSubObjectPropertyAxiomGenerator;




public class ReasonRDF {

   
public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException {
       
// TODO Auto-generated method stub
        readRDF
("directory/newNDVB4.owl");

   
}
   
public static void readRDF(String address) throws OWLOntologyCreationException, OWLOntologyStorageException{
       
OWLOntologyManager manager =OWLManager.createOWLOntologyManager();
       
File file = new File (address);
         
OWLOntology ont = manager.loadOntologyFromOntologyDocument(IRI.create(file));
         
System.out.println("Ontology Loaded...");
         
System.out.println("Logical IRI   : " + ont.getOntologyID().getOntologyIRI().get());
         
System.out.println("Format        : " + manager.getOntologyFormat(ont));
         
System.out.println("Runtime memory: " + Runtime.getRuntime().totalMemory());          

         
OWLReasonerFactory reasonerFactory = new ReasonerFactory();
         
ConsoleProgressMonitor progressMonitor = new ConsoleProgressMonitor();
         
Configuration config = new Configuration();
          config
.ignoreUnsupportedDatatypes=true;
          config
.reasonerProgressMonitor= progressMonitor;
         
OWLReasoner reasoner = reasonerFactory.createReasoner(ont, config);
         
         
long t0 = System.nanoTime();
         
         
OWLDataFactory datafactory = manager.getOWLDataFactory();
         
List<InferredAxiomGenerator<? extends OWLAxiom>> inferredAxioms = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
          inferredAxioms
.add(new InferredSubClassAxiomGenerator());
          inferredAxioms
.add(new InferredClassAssertionAxiomGenerator());
          inferredAxioms
.add(new InferredEquivalentClassAxiomGenerator());
          inferredAxioms
.add(new InferredPropertyAssertionGenerator());
          inferredAxioms
.add(new InferredInverseObjectPropertiesAxiomGenerator());        
          inferredAxioms
.add(new InferredSubDataPropertyAxiomGenerator());
          inferredAxioms
.add(new InferredSubObjectPropertyAxiomGenerator());

         
// for writing inferred axioms to the new ontology
         
OWLOntology infOnt = manager.createOntology(IRI.create(ont.getOntologyID().getOntologyIRI().get()+"_inferred"));

         
// use generator and reasoner to infer some axioms
         
InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, inferredAxioms);
         
//InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner);
          iog
.fillOntology(datafactory,infOnt);
         
long elapsed_time = System.nanoTime()-t0;
         
System.out.println(elapsed_time);

         
// save the ontology
          manager
.saveOntology(infOnt, IRI.create("file:///C:/Users/Ehsan.abdolmajidi/ontologies/NVDB4_4.rdf"));
       
         
System.out.println(reasoner.isConsistent());

   
}
}

I have given 10GB of memory to JAVA and am not inferring the disjoint classes as I guess it is very time consuming.
Could someone please take a look at my code and see if I can improve the processing time? Or could someone take a look at my ontology and maybe reason it on his or her machine?

Thanks for you help and time in advance!


Regards,
Ehsan
newNDVB4.owl

Ignazio Palmisano

unread,
Oct 31, 2016, 4:40:30 PM10/31/16
to Ehsan Majidi, HermiT Users
On 31 October 2016 at 10:24, Ehsan Majidi <ehsan...@gmail.com> wrote:
I have created several ontologies and almost all of them can be reasoned using the following code (OWL api and Hermit) except the ontology attached here which is not very different from the other ones in size and structure.


Unfortunately estimating how difficult an ontology is to classify/query is difficult :-) size and structure correlate with it but there's a lot of variance (and different reasoners have different optimizations).

My first attempt here would be to try the axiom generators separately and see if that helps pinpointing the slowness - for example, the disjoint class axiom generator used to be quite slow itself (the strategy used was very naive). This has been fixed in recent OWLAPI versions. Other generators might have similar issues, or this might be down to the ontology - but either way it will help restrict the search space.

Cheers,
I.

 

--
You received this message because you are subscribed to the Google Groups "HermiT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hermit-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ehsan Majidi

unread,
Nov 2, 2016, 7:02:08 AM11/2/16
to HermiT Users, ehsan...@gmail.com
Thanks for your reply,
I am using 4.1.3 version of OWL api. I also skipped the disjoint axiom generatore for the same reasoner you mention but still is very long process.
Could you please reason it on your machine?
To unsubscribe from this group and stop receiving emails from it, send an email to hermit-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages