Class AlchemyMlnReasoner
- java.lang.Object
-
- net.sf.tweety.logics.mln.reasoner.AbstractMlnReasoner
-
- net.sf.tweety.logics.mln.reasoner.AlchemyMlnReasoner
-
- All Implemented Interfaces:
QuantitativeReasoner<MarkovLogicNetwork,FolFormula>
,Reasoner<java.lang.Double,MarkovLogicNetwork,FolFormula>
public class AlchemyMlnReasoner extends AbstractMlnReasoner
This class implements a wrapper for Alchemy in order to reason with MLNs. Note: implementation inspired by AlchemyWrapper of KReator (http://kreator-ide.sourceforge.net)- Author:
- Matthias Thimm
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
inferCmd
The console command for Alchemy inference.
-
Constructor Summary
Constructors Constructor Description AlchemyMlnReasoner()
-
Method Summary
Modifier and Type Method Description private java.lang.String
alchemyStringForFormula(RelationalFormula formula)
Returns the string in Alchemy syntax representing the given formula.private java.lang.String
alchemyStringForTerm(Term<?> t)
Returns the string in Alchemy syntax representing the given term.double
doQuery(MarkovLogicNetwork mln, FolFormula query, FolSignature signature)
Performs the actual querying.void
setAlchemyInferenceCommand(java.lang.String inferCmd)
Sets the console command for Alchemy inference (default is 'infer').private java.io.File
writeAlchemyMlnFile(MarkovLogicNetwork mln, FolSignature signature, FolFormula formula)
Writes the given MLN wrt.-
Methods inherited from class net.sf.tweety.logics.mln.reasoner.AbstractMlnReasoner
computeWeight, numberOfGroundSatisfactions, query, query
-
-
-
-
Method Detail
-
setAlchemyInferenceCommand
public void setAlchemyInferenceCommand(java.lang.String inferCmd)
Sets the console command for Alchemy inference (default is 'infer').- Parameters:
inferCmd
- the console command for Alchemy inference.
-
doQuery
public double doQuery(MarkovLogicNetwork mln, FolFormula query, FolSignature signature)
Description copied from class:AbstractMlnReasoner
Performs the actual querying.- Specified by:
doQuery
in classAbstractMlnReasoner
- Parameters:
mln
- an MLNquery
- a fol formula guaranteed to be ground.signature
- the signature- Returns:
- the answer of the query.
-
writeAlchemyMlnFile
private java.io.File writeAlchemyMlnFile(MarkovLogicNetwork mln, FolSignature signature, FolFormula formula) throws java.io.IOException
Writes the given MLN wrt. the given signature to a temporary file in Alchemy syntax.- Parameters:
mln
- some MLN.signature
- some fol signature.formula
- the query formula that has to be encoded as well.- Returns:
- the file object of the Alchemy MLN file.
- Throws:
java.io.IOException
- if file writing fails.
-
alchemyStringForFormula
private java.lang.String alchemyStringForFormula(RelationalFormula formula)
Returns the string in Alchemy syntax representing the given formula.- Parameters:
formula
- some FOL formula- Returns:
- the string in Alchemy syntax representing the given formula.
-
alchemyStringForTerm
private java.lang.String alchemyStringForTerm(Term<?> t)
Returns the string in Alchemy syntax representing the given term.- Parameters:
t
- some FOL tern- Returns:
- the string in Alchemy syntax representing the given term.
-
-