fix log(0.0) and log10(0.0) to be SICStus compatible.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1245 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2005-02-18 21:34:02 +00:00
parent 755c60a7ca
commit 18f0de5486
13 changed files with 76 additions and 40 deletions

View File

@@ -122,7 +122,9 @@ sort_vars_by_key(AVars,SortedAVars, UnifiableVars) :-
get_keys([], []).
get_keys([V|AVars], [K-V|KeysVars]) :-
get_atts(V, [key(K)]),
get_atts(V, [key(K)]), !,
get_keys(AVars, KeysVars).
get_keys([V|AVars], KeysVars) :- % may be non-CLPBN vars.
get_keys(AVars, KeysVars).
merge_same_key([], [], _, []).
@@ -130,7 +132,7 @@ merge_same_key([K1-V1,K2-V2|Vs], SortedAVars, Ks, UnifiableVars) :-
K1 == K2, !, V1 = V2,
merge_same_key([K1-V1|Vs], SortedAVars, Ks, UnifiableVars).
merge_same_key([K1-V1,K2-V2|Vs], [V1|SortedAVars], Ks, [K1|UnifiableVars]) :-
(in_keys(K1, Ks) ; \+ \+ K1 = K2), !,
(in_keys(K1, Ks) ; \+ \+ K1 == K2), !,
add_to_keys(K1, Ks, NKs),
merge_same_key([K2-V2|Vs], SortedAVars, NKs, UnifiableVars).
merge_same_key([K-V|Vs], [V|SortedAVars], Ks, UnifiableVars) :-
@@ -219,27 +221,29 @@ bind_clpbn(T, Var, Key, Domain, Table, Parents) :- var(T),
bind_evidence_from_extra_var(Ev,T)
;
true).
bind_clpbn(_, Var, _, _) :-
bind_clpbn(_, Var, _, _, _, _) :-
use(bnt),
check_if_bnt_done(Var), !.
bind_clpbn(_, Var, _, _) :-
bind_clpbn(_, Var, _, _, _, _) :-
use(vel),
check_if_vel_done(Var), !.
bind_clpbn(T, Var, Key0, _) :-
bind_clpbn(T, Var, Key0, _, _, _) :-
get_atts(Var, [key(Key0)]), !,
(
Key = Key0 -> true
;
format(user_error, "trying to force evidence ~w through unification with key ~w~n",[T, Key])
add_evidence(Var,T)
).
fresh_attvar(Var, NVar) :-
get_atts(Var, LAtts),
put_atts(NVar, LAtts).
% I will now allow two CLPBN variables to be bound together.
%bind_clpbns(Key, Domain, Table, Parents, Key, Domain, Table, Parents).
bind_clpbns(Key, Domain, Table, Parents, Key1, Domain1, Table1, Parents1) :-
Key == Key1, !,
( Domain == Domain1, Table == Table1, Parents == Parents1 -> true ; throw(error(domain_error(bayesian_domain),bind_clpbns))).
( Domain == Domain1, Table == Table1, Parents == Parents1 -> true ; throw(error(domain_error(bayesian_domain),bind_clpbns(var(Key, Domain, Table, Parents),var(Key1, Domain1, Table1, Parents1))))).
bind_clpbns(_, _, _, _, _, _, _, _) :-
format(user_error, "unification of two bayesian vars not supported~n").

View File

@@ -14,6 +14,7 @@ check_for_hidden_vars([V|Vs], AllVs0, [V|NVs]) :-
check_for_hidden_vars(IVs, AllVs, NVs).
check_for_extra_variables(V,AllVs0, AllVs, Vs, IVs) :-
var(V),
clpbn:get_atts(V, [dist(_,_,[V1|LV])]), !,
add_old_variables([V1|LV], AllVs0, AllVs, Vs, IVs).
check_for_extra_variables(_,AllVs, AllVs, Vs, Vs).

View File

@@ -39,7 +39,8 @@ check_if_vel_done(Var) :-
get_atts(Var, [size(_)]), !.
vel(LVs0,Vs0,AllDiffs) :-
get_rid_of_ev_vars(LVs0,LVs),
sort(LVs0,LVs1),
get_rid_of_ev_vars(LVs1,LVs),
do_vel(LVs,Vs0,AllDiffs).
do_vel([],_,_) :- !.