applyThenExpansion

fun <T : Comparable<T>, E> BinaryDecisionDiagram<T>.applyThenExpansion(unaryOp: (Boolean) -> Boolean, expansionFalseTerminal: E, expansionTrueTerminal: E, expansionOperator: (node: T, low: E, high: E) -> E): Pair<BinaryDecisionDiagram<T>, E>

Applies the "Apply" construction algorithm over BinaryDecisionDiagrams using a given unary boolean operator, and computes a value using the Shannon Expansion over the result. The result is an instance of Pair of which Pair.first is the Reduced Ordered Binary Decision Diagram (ROBDD) produced by the operation, and Pair.second is the value of type E computed with the Shannon Expansion.

By definition, invoking apply and then expansion should produce the same result as calling this function directly, but in one bottom-up pass instead of two. This is what the *ThenExpansion family of operators (e.g. andThenExpansion, notThenExpansion) is built on, and is used e.g. by it.unibo.tuprolog.solve.problog.lib.knowledge.impl.BinaryDecisionDiagramExplanation to combine probabilistic explanations while incrementally caching their probability.

Return

a Pair of the resulting ROBDD and the Shannon-Expansion result.

Parameters

unaryOp

the unary boolean operator applied to Terminal values.

expansionFalseTerminal

the E value associated to a false Terminal.

expansionTrueTerminal

the E value associated to a true Terminal.

expansionOperator

combines a BinaryDecisionDiagram.Variable's value with the already computed E values of its low and high sub-diagrams.

Throws


fun <T : Comparable<T>, E> BinaryDecisionDiagram<T>.applyThenExpansion(that: BinaryDecisionDiagram<T>, binaryOp: (Boolean, Boolean) -> Boolean, expansionFalseTerminal: E, expansionTrueTerminal: E, expansionOperator: (node: T, low: E, high: E) -> E): Pair<BinaryDecisionDiagram<T>, E>

Applies the "Apply" construction algorithm over two BinaryDecisionDiagrams using a given binary boolean operator, and computes a value using the Shannon Expansion over the result. The result is an instance of Pair of which Pair.first is the Reduced Ordered Binary Decision Diagram (ROBDD) produced by the operation, and Pair.second is the value of type E computed with the Shannon Expansion.

By definition, invoking apply and then expansion should produce the same result as calling this function directly, but in one bottom-up pass instead of two. See andThenExpansion/orThenExpansion for concrete instantiations, and it.unibo.tuprolog.solve.problog.lib.knowledge.impl.BinaryDecisionDiagramExplanation for their usage to combine probabilistic explanations.

Return

a Pair of the resulting ROBDD and the Shannon-Expansion result.

Parameters

that

the other diagram to combine this one with.

binaryOp

the binary boolean operator combining Terminal values from this diagram and that.

expansionFalseTerminal

the E value associated to a false Terminal.

expansionTrueTerminal

the E value associated to a true Terminal.

expansionOperator

combines a BinaryDecisionDiagram.Variable's value with the already computed E values of its low and high sub-diagrams.

Throws