Reference¶
- tddlog.solve(program, *, format='problog', evidence=None, vtree='auto', evidence_probability=False, queries=True, arguments=None)¶
Read
program, text informat, then ground, compile and count it, and return the answers to its queries.formatnames what the text is, as the command line tells it by the file’s extension:"problog", the default (an LPAD where it holds:- begin_lpad.),"dice","circulette"(a.cqlnetlist), or a network’s:"bif","hugin"(.net),"xdsl"or"uai". A network’s variables are each queried at every value, andevidenceis the text of its evidence file, as the command line’s--evidencereads it: a UAI.evidfile for a UAI network, an Ace.instfile for any other.vtreeis the command line’s--vtree:"auto", the default, or one of the layouts it lists.evidence_probability=Truealso computesP(e), compiling the evidence no query depends on rather than dropping it.queries=Falseleaves out the program’s queries, as--no-queriesdoes, and needsevidence_probability=True.arguments, a list of strings, are a ProbLog program’s, an LPAD’s or a Dice program’s arguments, the values the command line takes after the program’s file: each the text of a term that takes the places$1,$2, … of the program, as insolve("$1::a. query(a).", arguments=["0.3"]); in a Dice program a place stands for an integer, and its argument is a natural number.An unknown
formatorvtree,evidencefor a program that is not a network,argumentsfor a network, an argument that is not a term (for a Dice program, not a natural number) or that no place takes, or options that ask for nothing raiseValueError; a place without an argument raisestddlog.ParseError; a program tddlog cannot answer raises a subclass oftddlog.Error. The interpreter lock is released for the whole run.
- class tddlog.Solution¶
The answers to a program’s queries, and the probability of its evidence where
solvewas asked for it.- answers¶
A dict from each query, as ProbLog prints it (
\+before a negative one), to its probability, in the program’s order;Nonewhere the evidence is inconsistent.
- evidence_probability¶
P(e), the probability of the evidence: 1.0 with none, 0.0 where it is inconsistent, and 0.0 too where it is under the least float, whichlog10_evidence_probabilitystill gives. For a UAI network, the partition function given the evidence, as the command line’sZ:line.Noneunlesssolvewas called withevidence_probability=True.
- log10_evidence_probability¶
The base-10 logarithm of
P(e), exact beyond a float’s range:-infwhere the evidence is inconsistent.Noneunlesssolvewas called withevidence_probability=True.
- exception tddlog.Error¶
A program tddlog could not answer: the base of ParseError, GroundingError and CompilationError.
- exception tddlog.ParseError¶
The program is not in the language or the format it is said to be in.
- exception tddlog.GroundingError¶
The program parses but cannot be ground: an unsupported construct or a rule that is not range restricted.
- exception tddlog.CompilationError¶
The ground program could not be compiled and counted under the vtree strategy asked for, or the well-founded model of some world leaves an atom undefined.