From b55a9bd8f9df8c5515687ab63d763283aef8ed6e Mon Sep 17 00:00:00 2001 From: rzf Date: Thu, 6 Mar 2008 07:11:18 +0000 Subject: [PATCH] added option for setting the value of zeros in cpt table. By using a small value rather than 0.0 some errors with jt and vel are avoided git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2123 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- CLPBN/clpbn/bnt.yap | 3 ++- CLPBN/clpbn/examples/cg.yap | 2 ++ cplint/lpadclpbn.pl | 13 +++++++++---- library/matlab/bnt_example.yap | 5 +++-- library/matlab/matlab.c | 2 ++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CLPBN/clpbn/bnt.yap b/CLPBN/clpbn/bnt.yap index 9d7641cae..d37df652e 100644 --- a/CLPBN/clpbn/bnt.yap +++ b/CLPBN/clpbn/bnt.yap @@ -59,7 +59,7 @@ G <-- Y :- bnt_solver(jtree). % likelihood_weighting -bnt_path("$HOME/Yap/CLPBN/FullBNT-1.0.4/BNT"). +bnt_path("/home/fabrizio/Desktop/cplint/cplint/trunk/FullBNT-1.0.4/BNT"). % @@ -259,6 +259,7 @@ mkdag(N,Els) :- add_els(Els,N,Dag), Dag=..[_|L], addzeros(L), + format("prova",[]), matlab_matrix(N,N,L,dag). add_els([],_,_). diff --git a/CLPBN/clpbn/examples/cg.yap b/CLPBN/clpbn/examples/cg.yap index 04423248a..a534aa23b 100644 --- a/CLPBN/clpbn/examples/cg.yap +++ b/CLPBN/clpbn/examples/cg.yap @@ -5,6 +5,8 @@ :- use_module(library(clpbn)). +cg(P,P1):-cg(s,1,P),cg(f,1,P1). + cg(X,1,C):- father(Y,X), cg(Y,1,C1),cg(Y,2,C2), diff --git a/cplint/lpadclpbn.pl b/cplint/lpadclpbn.pl index e8fa8e75c..ee64bad13 100644 --- a/cplint/lpadclpbn.pl +++ b/cplint/lpadclpbn.pl @@ -8,7 +8,7 @@ */ :- module(lpadclpbn, [p/1, - s/2,sc/3,s/6,sc/7]). + s/2,sc/3,s/6,sc/7,set/2,setting/2]). :-dynamic rule/4,def_rule/2,setting/2. @@ -33,6 +33,8 @@ if true, both the head and the body of each clause will be grounded, otherwise only the head is grounded. In the case in which the body contains variables not appearing in the head, the body represents an existential event */ +setting(cpt_zero,0.0001). + /* end of list of parameters */ /* s(GoalsList,Prob) compute the probability of a list of goals @@ -214,7 +216,8 @@ build_col_conj([],Tr,Final,Row0,Row1):- (Tr=Final-> append(Row0,[1.0],Row1) ; - append(Row0,[0.0],Row1) + setting(cpt_zero,Zero), + append(Row0,[Zero],Row1) ). build_col_conj([\+H|RP],Tr,Final,Row0,Row2):-!, @@ -233,7 +236,8 @@ build_col(A,[],Tr,Found,Row0,Row1):- (Tr=Found-> append(Row0,[1.0],Row1) ; - append(Row0,[0.0],Row1) + setting(cpt_zero,Zero), + append(Row0,[Zero],Row1) ). build_col(A,[(N,H)|RP],Tr,Found,Row0,Row1):- @@ -277,7 +281,8 @@ build_table([P],L,Row):-!, build_col(L,t,P,1.0,Row). build_table([HP|TP],L,Tab):- - build_col(L,t,HP,0.0,Row), + setting(cpt_zero,Zero), + build_col(L,t,HP,Zero,Row), append(Row,Row1,Tab), build_table(TP,L,Row1). diff --git a/library/matlab/bnt_example.yap b/library/matlab/bnt_example.yap index fcba4bc53..7a42d6771 100644 --- a/library/matlab/bnt_example.yap +++ b/library/matlab/bnt_example.yap @@ -57,9 +57,9 @@ init_bnt :- matlab_on, !. init_bnt :- getcwd(D), - cd('~/Yap/CLPBN/FullBNT/BNT'), +% cd('~/Yap/CLPBN/FullBNT/BNT'), start_matlab('matlab -nojvm -nosplash'), - matlab_eval_string("add_BNT_to_path",_), +% matlab_eval_string("add_BNT_to_path",_), cd(D). mk2s(0, []) :- !. @@ -73,6 +73,7 @@ mkdag(N,Els) :- add_els(Els,N,Dag), Dag=..[_|L], addzeros(L), +format("priova",[]), matlab_matrix(N,N,L,dag). add_els([],_,_). diff --git a/library/matlab/matlab.c b/library/matlab/matlab.c index 40aecca06..691aeb944 100644 --- a/library/matlab/matlab.c +++ b/library/matlab/matlab.c @@ -19,6 +19,8 @@ #include "YapInterface.h" #include #include +#include +#include #if defined(__MINGW32__) || _MSC_VER #include #endif