使用Pellet作为推理器的OutOfMemoryError

时间:2012-04-23 11:44:55

标签: rdf jena ontology reasoning pellet

我正在尝试使用Pellet推断数据,但我的应用程序总是崩溃 在推理期间由于“OutOfMemoryError:Java堆空间”。

正如其他地方所建议的,我已经尝试过增加堆大小 目前我正在使用这些VM参数:“ - XX:MaxPermSize = 256m -Xmx6144m“。此外,我要设置'PelletOptions.USE_CONTINUOUS = 真的',但到目前为止我只能将崩溃延迟几分钟。 (到目前为止最长的时间:30分钟。)

我将数据存储在Jena TDB triplestore中。它的总大小是170 MB 并包含962117条陈述。本体已经建模了 保护并且在与隐士或者隐士合理时没有任何不一致 事实++(当然在那时没有数据存在)。我的陈述 喜欢推断已使用等效类建模(例如:A和 (hasX some X)),逆属性(hasX< - > isXOf)和一些传递 属性。共有55个类:14个根类,11个等价类 (一个根类的所有子类型)。目前有14个班级的实例 已被添加到tripestore。

我也用pellint来分析我的本体,但我不确定是哪一个 从这个结果中得出结论:

[Untyped classes]
- http://www.w3.org/2002/07/owl#AllDisjointClasses

[Untyped object roles]
- http://www.w3.org/2002/07/owl#topObjectPriority
- http://www.w3.org/2002/07/owl#members

[Untyped datatype roles]
- http://www.w3.org/2002/07/owl#qualifiedCardinality

[Untyped individuals]
- 4 BNodes

这是我创建InfModel的代码:

 Dataset dataset = TDBFactory.createDataset(..);
 Model model = dataset.getDefaultModel();

 OntModel ont = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC,model);
 ont.read("file:.." , "RDF/XML");

 PelletOptions.USE_CONTINUOUS_RULES = true;
 Reasoner reasoner = PelletReasonerFactory.theInstance().create();
 reasoner = reasoner.bindSchema(ont);

 InfModel infModel = infModel = ModelFactory.createInfModel(reasoner, model);

这基本上就是我查询数据的方式:

 QueryExecution qe = QueryExecutionFactory.create("SELECT ...", infModel);
 Resultset rs = qe.execSelect();

 while(rs.hasNext())
 {
     QuerySolution sol = rs.nextSolution();
     ...
 }
 qe.close();

正如您所看到的,我在查询时收到了各种异常 数据,准备或验证InfModel。你有什么想法,什么 否则我可以尝试解决这个错误?

 java.lang.OutOfMemoryError: Java heap space
 at java.util.Arrays.copyOf(Unknown Source)
 at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source)
 at java.lang.AbstractStringBuilder.append(Unknown Source)
 at java.lang.StringBuilder.append(Unknown Source)
 at java.net.URLStreamHandler.parseURL(Unknown Source)
 at sun.net.www.protocol.file.Handler.parseURL(Unknown Source)
 at java.net.URL.<init>(Unknown Source)
 at java.net.URL.<init>(Unknown Source)
 at sun.misc.URLClassPath$FileLoader.getResource(Unknown Source)
 at sun.misc.URLClassPath.getResource(Unknown Source)
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCheck.warn(QueryIteratorCheck.java:114)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCheck.dump(QueryIteratorCheck.java:95)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCheck.checkForOpenIterators(QueryIteratorCheck.java:68)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCheck.close(QueryIteratorCheck.java:50)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorWrapper.closeIterator(QueryIteratorWrapper.java:50)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.close(QueryIteratorBase.java:184)
 at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorCloseable.close(QueryIteratorCloseable.java:39)
 at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.close(QueryExecutionBase.java:180)


 java.lang.OutOfMemoryError: Java heap space
 at shared.SharedObjectFactory.build(SharedObjectFactory.java:303)
 at aterm.pure.PureFactory.makeAppl(PureFactory.java:191)
 at aterm.pure.PureFactory.makeAppl(PureFactory.java:185)
 at aterm.pure.PureFactory.makeAppl(PureFactory.java:228)
 at org.mindswap.pellet.utils.ATermUtils.makeLiteral(ATermUtils.java:245)
 at org.mindswap.pellet.ABox.addLiteral(ABox.java:1696)
 at org.mindswap.pellet.tableau.completion.rule.SomeValuesRule.applySomeValuesRule(SomeValuesRule.java:174)
 at org.mindswap.pellet.tableau.completion.rule.SomeValuesRule.apply(SomeValuesRule.java:64)
 at org.mindswap.pellet.tableau.completion.rule.AbstractTableauRule.apply(AbstractTableauRule.java:64)
 at org.mindswap.pellet.tableau.completion.SROIQStrategy.complete(SROIQStrategy.java:157)
 at org.mindswap.pellet.ABox.isConsistent(ABox.java:1423)
 at org.mindswap.pellet.ABox.isConsistent(ABox.java:1260)
 at org.mindswap.pellet.KnowledgeBase.consistency(KnowledgeBase.java:1987)
 at org.mindswap.pellet.KnowledgeBase.isConsistent(KnowledgeBase.java:2061)
 at org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:247)
 at org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:230)
 at com.hp.hpl.jena.rdf.model.impl.InfModelImpl.prepare(InfModelImpl.java:89)


 java.lang.OutOfMemoryError: Java heap space
 at org.mindswap.pellet.tableau.branch.DisjunctionBranch.tryBranch(DisjunctionBranch.java:197)
 at org.mindswap.pellet.tableau.branch.Branch.tryNext(Branch.java:117)
 at org.mindswap.pellet.tableau.completion.rule.ChooseRule.apply(ChooseRule.java:82)
 at org.mindswap.pellet.tableau.completion.rule.ChooseRule.apply(ChooseRule.java:56)
 at org.mindswap.pellet.tableau.completion.rule.AbstractTableauRule.apply(AbstractTableauRule.java:64)
 at org.mindswap.pellet.tableau.completion.SROIQStrategy.complete(SROIQStrategy.java:157)
 at org.mindswap.pellet.ABox.isConsistent(ABox.java:1423)
 at org.mindswap.pellet.ABox.isConsistent(ABox.java:1260)
 at org.mindswap.pellet.KnowledgeBase.consistency(KnowledgeBase.java:1987)
 at org.mindswap.pellet.KnowledgeBase.isConsistent(KnowledgeBase.java:2061)
 at org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:247)
 at org.mindswap.pellet.jena.PelletInfGraph.prepare(PelletInfGraph.java:230)
 at org.mindswap.pellet.jena.PelletInfGraph.validate(PelletInfGraph.java:564)
 at com.hp.hpl.jena.rdf.model.impl.InfModelImpl.validate(InfModelImpl.java:111)

1 个答案:

答案 0 :(得分:1)

查询infModel显然导致Pellet生成数百个owl:differentFrom语句。解决方案是使用ModelExtractor

ModelExtractor ext = new ModelExtractor(inf); 
Model m = ext.extractModel();
QueryExecution qe = QueryExecutionFactory.create("SELECT ...", m);