From 07335ce047405c009ba5efe33298c27a3342bb3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 22 Mar 2012 23:24:09 +0000 Subject: [PATCH] clp(bn) support --- packages/CLPBN/clpbn/bdd.yap | 15 ++++++++------- packages/bdd/cudd.c | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/CLPBN/clpbn/bdd.yap b/packages/CLPBN/clpbn/bdd.yap index a4670da8e..7b8826f57 100644 --- a/packages/CLPBN/clpbn/bdd.yap +++ b/packages/CLPBN/clpbn/bdd.yap @@ -260,20 +260,21 @@ skim_for_theta([[P|Other]], not(P), [Other], _) :- !. skim_for_theta([[P|Other]|More], Ps*not(P), [Other|Left], New ) :- skim_for_theta(More, Ps, Left, New ). -get_evidence(V, Tree, Values, F0, F) :- +get_evidence(V, Tree, Values, F0, (Tree=Outs).F0) :- clpbn:get_atts(V, [evidence(Pos)]), !, - zero_pos(0, Pos, Tree, Values, F0, F). + zero_pos(0, Pos, Values), + get_outs(F0, Outs). %% no evidence !!! get_evidence(_V, Tree, _Values, F0, (Tree=Outs).F0) :- get_outs(F0, Outs). -zero_pos(_, _Pos, _Tree, [], [], []) :- !. -zero_pos(Pos, Pos, Tree, 1.Values, [Tree=Vs|F], [Tree=Vs]) :- +zero_pos(_, _Pos, []). +zero_pos(Pos, Pos, 1.Values) :- !, I is Pos+1, - zero_pos(I, Pos, Tree, Values, F, []). -zero_pos(I0, Pos, Tree, 0.Values, _.F, NF) :- + zero_pos(I, Pos, Values). +zero_pos(I0, Pos, 0.Values) :- I is I0+1, - zero_pos(I, Pos, Tree, Values, F, NF). + zero_pos(I, Pos, Values). get_outs([V=_F], V) :- !. get_outs((V=_F).Outs, (V + F0)) :- diff --git a/packages/bdd/cudd.c b/packages/bdd/cudd.c index 1cf157093..867e82e69 100644 --- a/packages/bdd/cudd.c +++ b/packages/bdd/cudd.c @@ -163,7 +163,7 @@ term_to_cudd(DdManager *manager, YAP_Term t) else if (i==1.0) return Cudd_ReadOne(manager); } else if (YAP_IsVarTerm(t)) { - fprintf(stderr,"Unbound Variable should be input argument to BDD\n"); + fprintf(stderr,"Unbound Variable should not be input argument to BDD\n"); } return NULL; }