Module for manipulating Binary Decision Diagrams.
It contains programs for building BDDs, for computing probabilities and for performing Expectation Maximization.
- author
- - Fabrizio Riguzzi
- copyright
- - Fabrizio Riguzzi
- license
- - Artistic License 2.0 https://opensource.org/licenses/Artistic-2.0
- init_em(--Context:int) is det
- Initializes a data structure for performing parameter learning.
It returns an integer in Context that is a pointer to a
context data structure for performing the EM algorithm.
- end_em(++Context:int) is det
- Terminates the context data structure for performing parameter learning.
Context is a pointer to a context data structure for performing
the EM algorithm.
Context must have been returned by a call to init_em/1.
It frees the memory occupied by Context.
- init_ex(++Context:int, --Environment:int) is det
- Initializes an enviroment data structure for storing a BDD.
Context is an integer that is a pointer to a context data structure
created using init_em/1.
Returns an integer Environment that is a pointer to a data structure for
storing a single BDD to be used for the EM algorithm.
- end_ex(++Environment:int) is det
- Terminates the evnironment data structure for storing a BDD.
Environment is a pointer to a data structure returned by init_ex/2.
It frees the memory occupied by the BDD.
- init(--Environment:int) is det
- Initializes a data structure for storing a single BDD.
Returns an integer Environment that is a pointer to a data structure for
storing a single BDD to be used for inference only (no learning).
- end(++Environment:int) is det
- Terminates the environment data structure for storing a single BDD.
Environment is a pointer to a data structure returned by a call
to init/1.
- one(++Environment:int, --One:int) is det
- Returns in One a pointer to a BDD belonging to environment Environment
representing the one Boolean function.
- zero(++Environment:int, --Zero:int) is det
- Returns in Zero a pointer to a BDD belonging to environment Environment
representing the zero Boolean function.
- and(++Environment:int, ++A:int, ++B:int, --AandB:int) is det
- Returns in AandB a pointer to a BDD belonging to environment Environment
representing the conjunction of BDDs A and B.
- or(++Environment:int, ++A:int, ++B:int, --AorB:int) is det
- Returns in AorB a pointer to a BDD belonging to environment Environment
representing the disjunction of BDDs A and B.
- ret_prob(++Environment:int, ++BDD:int, -Probability:float) is det
- Returns the Probability of BDD belonging to environment Environment.
- ret_map_prob(++Environment:int, ++BDD:int, -Probability:float, -MAPState:list) is det
- Returns the MAP state MPAState of BDD and its Probability.
BDD belongs to environment Environment.
- ret_abd_prob(++Environment:int, ++BDD:int, -Probability:float, -Explanation:list) is det
- Returns the abductive Explanation of BDD and its Probability.
BDD belongs to environment Environment.
- ret_vit_prob(++Environment:int, ++BDD:int, -Probability:float, -MPEState:list) is det
- Returns the MPE (Viterbi) state MPEState of BDD and its Probability.
BDD belongs to environment Environment.
- bdd_not(++Environment:int, ++A:int, --NotA:int) is det
- Returns in NotA a pointer to a BDD belonging to environment Environment
representing the negation of BDD A.
- equality(++Environment:int, ++Variable:int, ++Value:int, --BDD:int) is det
- Returns in BDD the BDD belonging to environment Environment
that represents the equation Variable=Value.
- em(++Context:int, ++RuleInfo:list, ++ListOfBDDs:list, ++EA:float, ++ER:float, ++Iterations:int, -LL:float, -Parameters:list, -ExampleProbabilities:list) is det
- NumberOfHeads is a list of terms, one for each rule. Each term is either
an integer, indicating the number
of head atoms in the rule, or a list [N] where N
is the number of head atoms. In the first case, the parameters of the rule are tunable,
in the latter they are fixed.
Performs EM learning.
Takes as input the Context, information on the rules,
a list of BDDs each representing one example,
the minimum absolute difference EA and relative difference ER between the
log likelihood of examples in two different iterations and the maximum number of iterations
Iterations.
RuleInfo is a list of elements, one for each rule, with are either
- an integer, indicating the number of heads, in which case the parameters of the
corresponding rule should be randomized,
- a list of floats, in which case the parameters should be set to those indicated
in the list and not changed during learning (fixed parameters)
- [a list of floats], in which case the initial values of the parameters should
be set to those indicated
in the list and changed during learning (initial values of the parameters)
Returns the final log likelihood of examples LL, the list of new Parameters
and a list with the final probabilities of each example.
Parameters is a list whose elements are of the form [N,P] where N is the rule
number and P is a list of probabilities, one for each head atom of rule N,
in reverse order.
- add_var(++Environment:int, ++ProbabilityDistribution:list, ++Rule:int, -Variable:int) is det
- Returns in Variable the index of a new random variable in Environment with
NumberOHeads values and probability distribution ProbabilityDistribution.
- add_abd_var(++Environment:int, ++ProbabilityDistribution:list, ++Rule:int, -Variable:int) is det
- Returns in Variable the index of a new abducible random variable in Environment with
NumberOHeads values and probability distribution ProbabilityDistribution.
- add_query_var(++Environment:int, ++ProbabilityDistribution:list, ++Rule:int, -Variable:int) is det
- Returns in Variable the index of a new random variable to be queried in MAP inference with
NumberOHeads values and probability distribution ProbabilityDistribution.
The variable belongs to Environment.
- make_query_var(++Environment:int, +Variable:int, --BDD:int) is det
- Makes Variable belonging to Environment a query random variable for MAP inference.
Returns in BDD the diagram of the formula encoding the required constraints among the
Boolean random variable that represent Variable.
- create_dot_string(++Env:int, ++BDD:int, -Dot:string) is det
- The predicate returns the BDD in dot format.
- create_dot(++Env:int, ++BDD:int, ++File:string) is det
- The predicate writes the BDD in dot format to
to file FileName.
- rand_seed(+Seed:int) is det
- The pseudo-random number generator is initialized using the argument passed as Seed.
It calls the C function srand.
- orc(++A:couple, ++B:couple, --AorB:couple) is det
- A and B are couples (Environment, BDDA) and (Environment, BDDB) respectively
Returns in AorB a couple (Environment, BDDAorB) where BDDAorB is pointer to a BDD belonging to environment Environment
representing the disjunction of BDDs BDDA and BDDB.
- onec(++Environment:int, --One:couple) is det
- Returns in One a couple (Environment,BDD) where BDD is pointer to a BDD belonging to environment Environment
representing the one Boolean function
- zeroc(++Environment:int, --Zero:couple) is det
- Returns in Zero a couple (Environment,BDD) where BDD is pointer to a BDD belonging to environment Environment
representing the zero Boolean function
- andc(++Environment:int, ++A:couple, ++B:couple, --AandB:couple) is semidet
- A and B are couples (Environment, BDDA) and (Environment, BDDB) respectively
Returns in AandB a couple (Environment, BDDAandB) where BDDAandB is pointer to a BDD belonging to environment Environment
representing the conjunction of BDDs BDDA and BDDB.
fails if BDDB represents the zero function
- bdd_notc(++Environment:int, ++EBDD:couple, --NotEBDD:couple) is det
- EBDD is a couple (Environment,A)
Returns in NotEBDD a couple (Environment,NotA) where NotA is
pointer to a BDD belonging to environment Environment
representing the negation of BDD A
- equalityc(++Environment:int, ++Variable:int, ++Value:int, --EBDD:couple) is det
- Returns in EBDD a couple (Environment,BDD) where BDD belongs to environment Environment
and represents the equation Variable=Value.
- ret_probc(++Environment:int, ++EBDD:couple, -Probability:float) is det
- EBDD is a couple (Environment,BDD)
Returns the Probability of BDD belonging to environment Environment
Uses
- initial_values(++Environment:int, ++Alpha:float) is det
- Sets the type of parameter initialization for EM on Environment:
if Alpha is 0.0, it uses a truncated Dirichlet process
if Alpha is a float > 0.0, it uses a symmetric Dirichlet distribution
with that value as parameter
- or_list(++ListOfBDDs:list, ++Environment, --BDD:int) is det
- Returns in BDD a pointer to a BDD belonging to environment Environment
representing the disjunction of all the BDDs in ListOfBDDs
- or_listc(++ListOfBDDs:list, ++Environment, --BDD:int) is det
- Returns in BDD a couple (Env,B) with B a pointer to a
BDD belonging to environment Environment
representing the disjunction of all the BDDs in
ListOfBDDs (a list of couples (Env,BDD))
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
- andcnf(Arg1, Arg2, Arg3, Arg4)
- gamma_sample(Arg1, Arg2, Arg3)
- gauss_sample(Arg1, Arg2, Arg3)
- uniform_sample(Arg1)
- dirichlet_sample(Arg1, Arg2)
- symmetric_dirichlet_sample(Arg1, Arg2, Arg3)
- discrete_sample(Arg1, Arg2)
- add_decision_var(Arg1, Arg2, Arg3)
- probability_dd(Arg1, Arg2, Arg3)
- add_prod(Arg1, Arg2, Arg3, Arg4)
- add_sum(Arg1, Arg2, Arg3, Arg4)
- ret_strategy(Arg1, Arg2, Arg3, Arg4)
- compute_best_strategy(Arg1, Arg2, Arg3, Arg4, Arg5)
- debug_cudd_var(Arg1, Arg2)