improve evidence handling in CLP(BN).
This commit is contained in:
parent
0688fb4d68
commit
307446d000
@ -77,9 +77,10 @@
|
|||||||
:- use_module('clpbn/evidence',
|
:- use_module('clpbn/evidence',
|
||||||
[
|
[
|
||||||
store_evidence/1,
|
store_evidence/1,
|
||||||
|
add_evidence/2,
|
||||||
incorporate_evidence/2,
|
incorporate_evidence/2,
|
||||||
check_stored_evidence/2,
|
check_stored_evidence/2,
|
||||||
add_evidence/2
|
put_evidence/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
:- use_module('clpbn/utils',
|
:- use_module('clpbn/utils',
|
||||||
@ -284,17 +285,17 @@ process_var(V, _) :- throw(error(instantiation_error,clpbn(attribute_goal(V)))).
|
|||||||
%
|
%
|
||||||
% unify a CLPBN variable with something.
|
% unify a CLPBN variable with something.
|
||||||
%
|
%
|
||||||
verify_attributes(Var, T, Goals) :-
|
verify_attributes(Var, T, Goal) :-
|
||||||
get_atts(Var, [key(Key),dist(Dist,Parents)]), !,
|
get_atts(Var, [key(Key),dist(Dist,Parents)]), !,
|
||||||
/* oops, someone trying to bind a clpbn constrained variable */
|
/* oops, someone trying to bind a clpbn constrained variable */
|
||||||
Goals = [],
|
bind_clpbn(T, Var, Key, Dist, Parents, Goal).
|
||||||
bind_clpbn(T, Var, Key, Dist, Parents).
|
|
||||||
verify_attributes(_, _, []).
|
verify_attributes(_, _, []).
|
||||||
|
|
||||||
|
|
||||||
bind_clpbn(T, Var, _, _, _) :- nonvar(T),
|
bind_clpbn(T, Var, _, _, _, do_not_bind_variable([put_evidence(T,Var)])) :-
|
||||||
!, ( add_evidence(Var,T) -> true ; writeln(T:Var), fail ).
|
nonvar(T),
|
||||||
bind_clpbn(T, Var, Key, Dist, Parents) :- var(T),
|
!.
|
||||||
|
bind_clpbn(T, Var, Key, Dist, Parents, []) :- var(T),
|
||||||
get_atts(T, [key(Key1),dist(Dist1,Parents1)]),
|
get_atts(T, [key(Key1),dist(Dist1,Parents1)]),
|
||||||
(
|
(
|
||||||
bind_clpbns(Key, Dist, Parents, Key1, Dist1, Parents1)
|
bind_clpbns(Key, Dist, Parents, Key1, Dist1, Parents1)
|
||||||
@ -311,22 +312,22 @@ bind_clpbn(T, Var, Key, Dist, Parents) :- var(T),
|
|||||||
;
|
;
|
||||||
fail
|
fail
|
||||||
).
|
).
|
||||||
bind_clpbn(_, Var, _, _, _, _) :-
|
bind_clpbn(_, Var, _, _, _, _, []) :-
|
||||||
use(bnt),
|
use(bnt),
|
||||||
check_if_bnt_done(Var), !.
|
check_if_bnt_done(Var), !.
|
||||||
bind_clpbn(_, Var, _, _, _, _) :-
|
bind_clpbn(_, Var, _, _, _, _, []) :-
|
||||||
use(vel),
|
use(vel),
|
||||||
check_if_vel_done(Var), !.
|
check_if_vel_done(Var), !.
|
||||||
bind_clpbn(_, Var, _, _, _, _) :-
|
bind_clpbn(_, Var, _, _, _, _, []) :-
|
||||||
use(jt),
|
use(jt),
|
||||||
check_if_vel_done(Var), !.
|
check_if_vel_done(Var), !.
|
||||||
bind_clpbn(T, Var, Key0, _, _, _) :-
|
bind_clpbn(T, Var, Key0, _, _, _, []) :-
|
||||||
get_atts(Var, [key(Key)]), !,
|
get_atts(Var, [key(Key)]), !,
|
||||||
(
|
(
|
||||||
Key = Key0 -> true
|
Key = Key0 -> true
|
||||||
;
|
;
|
||||||
% let us not loose whatever we had.
|
% let us not loose whatever we had.
|
||||||
add_evidence(Var,T)
|
put_evidence(T,Var)
|
||||||
).
|
).
|
||||||
|
|
||||||
fresh_attvar(Var, NVar) :-
|
fresh_attvar(Var, NVar) :-
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
additive_dists/6
|
additive_dists/6
|
||||||
]).
|
]).
|
||||||
|
|
||||||
:- use_module(library(lists),[is_list/1,nth0/3,append/3]).
|
:- use_module(library(lists),[nth0/3,append/3]).
|
||||||
|
|
||||||
:- use_module(library(matrix),
|
:- use_module(library(matrix),
|
||||||
[matrix_new/4,
|
[matrix_new/4,
|
||||||
|
@ -215,8 +215,8 @@ process(LV0, _, Out) :-
|
|||||||
multiply_tables(WorkTables, Out).
|
multiply_tables(WorkTables, Out).
|
||||||
|
|
||||||
|
|
||||||
write_tables([]).
|
write_tables([]).
|
||||||
write_tables([tab(Mat,_,_)|WorkTables]) :-
|
write_tables([tab(Mat,_,_)|WorkTables]) :-
|
||||||
matrix:matrix_to_list(Mat,L),
|
matrix:matrix_to_list(Mat,L),
|
||||||
writeln(L),
|
writeln(L),
|
||||||
write_tables(WorkTables).
|
write_tables(WorkTables).
|
||||||
|
Reference in New Issue
Block a user