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
This commit is contained in:
rzf 2008-03-06 07:11:18 +00:00
parent 9c54e6c7bb
commit b55a9bd8f9
5 changed files with 18 additions and 7 deletions

View File

@ -59,7 +59,7 @@ G <-- Y :-
bnt_solver(jtree). bnt_solver(jtree).
% likelihood_weighting % 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), add_els(Els,N,Dag),
Dag=..[_|L], Dag=..[_|L],
addzeros(L), addzeros(L),
format("prova",[]),
matlab_matrix(N,N,L,dag). matlab_matrix(N,N,L,dag).
add_els([],_,_). add_els([],_,_).

View File

@ -5,6 +5,8 @@
:- use_module(library(clpbn)). :- use_module(library(clpbn)).
cg(P,P1):-cg(s,1,P),cg(f,1,P1).
cg(X,1,C):- cg(X,1,C):-
father(Y,X), father(Y,X),
cg(Y,1,C1),cg(Y,2,C2), cg(Y,1,C1),cg(Y,2,C2),

View File

@ -8,7 +8,7 @@
*/ */
:- module(lpadclpbn, [p/1, :- 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. :-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 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 */ not appearing in the head, the body represents an existential event */
setting(cpt_zero,0.0001).
/* end of list of parameters */ /* end of list of parameters */
/* s(GoalsList,Prob) compute the probability of a list of goals /* s(GoalsList,Prob) compute the probability of a list of goals
@ -214,7 +216,8 @@ build_col_conj([],Tr,Final,Row0,Row1):-
(Tr=Final-> (Tr=Final->
append(Row0,[1.0],Row1) 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):-!, build_col_conj([\+H|RP],Tr,Final,Row0,Row2):-!,
@ -233,7 +236,8 @@ build_col(A,[],Tr,Found,Row0,Row1):-
(Tr=Found-> (Tr=Found->
append(Row0,[1.0],Row1) 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):- 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_col(L,t,P,1.0,Row).
build_table([HP|TP],L,Tab):- 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), append(Row,Row1,Tab),
build_table(TP,L,Row1). build_table(TP,L,Row1).

View File

@ -57,9 +57,9 @@ init_bnt :-
matlab_on, !. matlab_on, !.
init_bnt :- init_bnt :-
getcwd(D), getcwd(D),
cd('~/Yap/CLPBN/FullBNT/BNT'), % cd('~/Yap/CLPBN/FullBNT/BNT'),
start_matlab('matlab -nojvm -nosplash'), start_matlab('matlab -nojvm -nosplash'),
matlab_eval_string("add_BNT_to_path",_), % matlab_eval_string("add_BNT_to_path",_),
cd(D). cd(D).
mk2s(0, []) :- !. mk2s(0, []) :- !.
@ -73,6 +73,7 @@ mkdag(N,Els) :-
add_els(Els,N,Dag), add_els(Els,N,Dag),
Dag=..[_|L], Dag=..[_|L],
addzeros(L), addzeros(L),
format("priova",[]),
matlab_matrix(N,N,L,dag). matlab_matrix(N,N,L,dag).
add_els([],_,_). add_els([],_,_).

View File

@ -19,6 +19,8 @@
#include "YapInterface.h" #include "YapInterface.h"
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <stdio.h>
#if defined(__MINGW32__) || _MSC_VER #if defined(__MINGW32__) || _MSC_VER
#include <windows.h> #include <windows.h>
#endif #endif