Package-level declarations

Properties

Link copied to clipboard

The BinaryDecisionDiagram attached to this Solution via setBinaryDecisionDiagram, or null if none was attached (see hasBinaryDecisionDiagram). Where present, the diagram is the Boolean formula (over the probabilistic facts/clauses used to prove the query) that a probabilistic solver derived this solution's probability from via Weighted Model Counting — see it.unibo.tuprolog.bdd.BinaryDecisionDiagram for how such a diagram is built up and expanded.

Link copied to clipboard

The default value of SolveOptions.isProbabilistic: probabilistic resolution is opt-in, so plain logic-programming queries are unaffected unless a caller explicitly turns it on via SolveOptions.setProbabilistic or SolveOptions.probabilistic.

Link copied to clipboard
const val DEFAULT_PROBABILITY: Double = 1.0

The probability assigned to a Taggable object (e.g. a Term or a Solution) that has never had setProbability called on it, i.e. one that is treated as certain (probability 1.0). This is also the fallback used by ProblogSolver-like solvers when SolveOptions.isProbabilistic is false.

Link copied to clipboard

Whether this Solution was tagged with a BinaryDecisionDiagram via setBinaryDecisionDiagram, i.e. whether binaryDecisionDiagram would return a non-null value. A probabilistic solver only attaches one when it actually managed to compute an explanation for the solution's probability; e.g. a solution obtained while SolveOptions.isProbabilistic is false never carries one.

Link copied to clipboard

Whether the probabilistic-computation option is enabled on these SolveOptions (false by default, see DEFAULT_PROBABILISTIC_OPTION). This is a "best effort" option: a solver that supports probabilistic resolution attempts to solve the query in probabilistic mode when this is true, tagging each Solution with its computed probability (and possibly a binaryDecisionDiagram explaining it); a solver that does not support it falls back to plain logic-programming resolution, in which case every solution's probability reads back the DEFAULT_PROBABILITY stub rather than an actually computed value.

Link copied to clipboard
val <T : Taggable<T>, U : T> U.probability: Double

The probability value assigned to this object via setProbability, or DEFAULT_PROBABILITY (certainty) if none was ever assigned. Any it.unibo.tuprolog.utils.Taggable object can carry a probability this way; in practice this is read off it.unibo.tuprolog.core.Terms representing probabilistic facts/clauses (e.g. by :solve-problog's knowledge-base primitives) and off Solutions produced by a probabilistic solver.

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

JS-callable equivalent of SolveOptions.isProbabilistic.

Link copied to clipboard

Returns a copy of these SolveOptions with the probabilistic-computation option (isProbabilistic) turned on. Shorthand for setProbabilistic(true).

Link copied to clipboard
fun <T : Taggable<T>, U : T> probability(taggable: U): Double

JS-callable equivalent of Taggable.probability.

Link copied to clipboard

Returns a new Solution, otherwise equivalent to this one, tagged with value as its binaryDecisionDiagram. Used by probabilistic solvers to attach the explanation a solution's probability was computed from, so that callers can inspect (or recompute against) it later without re-deriving it from the original goal.

Link copied to clipboard

Returns a copy of these SolveOptions with the probabilistic-computation option (isProbabilistic) set to value.

Link copied to clipboard
fun <T : Taggable<T>, U : T> U.setProbability(value: Double): U

Returns a new instance, otherwise equivalent to this one, tagged with value as its probability. value is clamped into the [0.0, 1.0] range before being stored (e.g. 1.5 is stored as 1.0, -1.0 as 0.0), so probability always reads back a valid probability — with the notable exception of Double.NaN, which normalizeProbability's min/max comparisons let through unchanged (used by :solve-problog's ProblogSolver to flag a solution whose probability could not be computed).