Several whitespace fixes

This commit is contained in:
Tiago Gomes 2012-12-17 17:57:00 +00:00
parent 409a230826
commit 2f2f88e571
27 changed files with 667 additions and 666 deletions

View File

@ -246,7 +246,8 @@ project_attributes(GVars0, _AVars0) :-
generate_network(GVars0, GKeys, Keys, Factors, Evidence), generate_network(GVars0, GKeys, Keys, Factors, Evidence),
b_setval(clpbn_query_variables, f(GVars0,Evidence)), b_setval(clpbn_query_variables, f(GVars0,Evidence)),
simplify_query(GVars0, GVars), simplify_query(GVars0, GVars),
( GKeys = [] (
GKeys = []
-> ->
GVars0 = [V|_], GVars0 = [V|_],
clpbn_display:put_atts(V, [posterior([],[],[],[])]) clpbn_display:put_atts(V, [posterior([],[],[],[])])

View File

@ -273,7 +273,9 @@ include_qevidence(_, MAT, MAT, NewParents, NewParents, _, Vs, Vs).
check_consistency(L1, Ev, MAT0, MAT1, L1, MAT, NewParents0, NewParents, Vs, IVs, NewVs) :- check_consistency(L1, Ev, MAT0, MAT1, L1, MAT, NewParents0, NewParents, Vs, IVs, NewVs) :-
sumlist(L1, Tot), sumlist(L1, Tot),
nth0(Ev, L1, Val), nth0(Ev, L1, Val),
(Val == Tot -> (
Val == Tot
->
MAT1 = MAT, MAT1 = MAT,
NewParents = [], NewParents = [],
Vs = NewVs Vs = NewVs

View File

@ -428,4 +428,3 @@ mk_evidence_query([V|L], [H|T], [ar(1,Pos,El)|LN]) :-
nth(El,D,H), nth(El,D,H),
mk_evidence_query(L, T, LN). mk_evidence_query(L, T, LN).

View File

@ -92,7 +92,8 @@ process_new_variable(V, Evs, G, RG, Vs0, Vs2) :-
throw_below(Evs, G, RG, Child, Vs0, Vs1) :- throw_below(Evs, G, RG, Child, Vs0, Vs1) :-
rb_lookup(Child, [_|B], Vs0), !, rb_lookup(Child, [_|B], Vs0), !,
( (
B == b -> B == b
->
Vs0 = Vs1 % been there before Vs0 = Vs1 % been there before
; ;
B = b, % mark it B = b, % mark it
@ -122,7 +123,8 @@ handle_ball_from_above(V, Evs, G, RG, Vs0, Vs1) :-
throw_above(Evs, G, RG, Parent, Vs0, Vs1) :- throw_above(Evs, G, RG, Parent, Vs0, Vs1) :-
rb_lookup(Parent, [T|_], Vs0), !, rb_lookup(Parent, [T|_], Vs0), !,
( (
T == t -> T == t
->
Vs1 = Vs0 % been there before Vs1 = Vs0 % been there before
; ;
T = t, % mark it T = t, % mark it

View File

@ -1,3 +1,4 @@
:- module(clpbn_display, :- module(clpbn_display,
[clpbn_bind_vals/3]). [clpbn_bind_vals/3]).

View File

@ -84,7 +84,6 @@ add_links([K0|TVs],K) :-
assert(edge(K,K0)), assert(edge(K,K0)),
add_links(TVs,K). add_links(TVs,K).
incorporate_evidence(Vs,AllVs) :- incorporate_evidence(Vs,AllVs) :-
rb_new(Cache0), rb_new(Cache0),
create_open_list(Vs, OL, FL, Cache0, CacheI), create_open_list(Vs, OL, FL, Cache0, CacheI),

View File

@ -50,18 +50,15 @@ hmm_state(N/A,Mod) :-
(First > 2 -> (First > 2 ->
Last = Key, ! Last = Key, !
; ;
nb_getval(trie, Trie), trie_check_entry(Trie, Key, _) nb_getval(trie, Trie), trie_check_entry(Trie, Key, _) ->
->
% leave work for solver! % leave work for solver!
%
Last = Key, ! Last = Key, !
; ;
% first time we saw this entry % first time we saw this entry
nb_getval(trie, Trie), trie_put_entry(Trie, Key, _), nb_getval(trie, Trie), trie_put_entry(Trie, Key, _),
fail fail
) )
) )).
).
build_args(4,[A,B,C,D],[A,B,C],A,D). build_args(4,[A,B,C,D],[A,B,C],A,D).
build_args(3, [A,B,C], [A,B],A,C). build_args(3, [A,B,C], [A,B],A,C).

View File

@ -294,8 +294,7 @@ add_clique_edges([], _, _, Edges, Edges).
add_clique_edges([Clique1|Cliques], Clique, Sz, Edges0, EdgesF) :- add_clique_edges([Clique1|Cliques], Clique, Sz, Edges0, EdgesF) :-
ord_intersection(Clique1, Clique, Int), ord_intersection(Clique1, Clique, Int),
Int \== Clique, Int \== Clique,
( (Int = [] ->
Int = [] ->
add_clique_edges(Cliques, Clique, Sz, Edges0, EdgesF) add_clique_edges(Cliques, Clique, Sz, Edges0, EdgesF)
; ;
% we connect % we connect

View File

@ -1,3 +1,4 @@
:- module(clpbn_matrix_utils, :- module(clpbn_matrix_utils,
[init_CPT/3, [init_CPT/3,
project_from_CPT/3, project_from_CPT/3,

View File

@ -108,8 +108,7 @@ clpbn_table(F/N,M) :-
L0 = [_|Args0], L0 = [_|Args0],
IGoal =.. [NF|Args0], IGoal =.. [NF|Args0],
asserta(clpbn_table(S, M, IGoal)), asserta(clpbn_table(S, M, IGoal)),
assert( assert((M:S :-
(M:S :-
!, !,
% write(S: ' ' ), % write(S: ' ' ),
b_getval(clpbn_tables, Tab), b_getval(clpbn_tables, Tab),
@ -130,8 +129,7 @@ clpbn_table(F/N,M) :-
; ;
throw(error(tabled_clpbn_predicate_should_never_fail,S)) throw(error(tabled_clpbn_predicate_should_never_fail,S))
) )
) )).
).
take_tail([V], V, [], V1, [V1]) :- !. take_tail([V], V, [], V1, [V1]) :- !.
take_tail([A|L0], V, [A|L1], V1, [A|L2]) :- take_tail([A|L0], V, [A|L1], V1, [A|L2]) :-
@ -154,8 +152,7 @@ clpbn_tableallargs(F/N,M) :-
atom_concat(F, '___tabled', NF), atom_concat(F, '___tabled', NF),
NKey =.. [NF|Args], NKey =.. [NF|Args],
asserta(clpbn_table(Key, M, NKey)), asserta(clpbn_table(Key, M, NKey)),
assert( assert((M:Key :-
(M:Key :-
!, !,
b_getval(clpbn_tables, Tab), b_getval(clpbn_tables, Tab),
(b_hash_lookup(Key, Out, Tab) -> (b_hash_lookup(Key, Out, Tab) ->
@ -165,8 +162,7 @@ clpbn_tableallargs(F/N,M) :-
b_setval(clpbn_tables, NewTab), b_setval(clpbn_tables, NewTab),
once(M:NKey) once(M:NKey)
) )
) )).
).
clpbn_table_nondet(M:X) :- !, clpbn_table_nondet(M:X) :- !,
clpbn_table_nondet(X,M). clpbn_table_nondet(X,M).
@ -185,8 +181,8 @@ clpbn_table_nondet(F/N,M) :-
atom_concat(F, '___tabled', NF), atom_concat(F, '___tabled', NF),
NKey =.. [NF|Args], NKey =.. [NF|Args],
asserta(clpbn_table(Key, M, NKey)), asserta(clpbn_table(Key, M, NKey)),
assert( assert((M:Key :-
(M:Key :- % writeln(in:Key), % writeln(in:Key),
b_getval(clpbn_tables, Tab), b_getval(clpbn_tables, Tab),
(b_hash_lookup(Key, Out, Tab) -> (b_hash_lookup(Key, Out, Tab) ->
fail fail
@ -195,8 +191,7 @@ clpbn_table_nondet(F/N,M) :-
b_setval(clpbn_tables, NewTab), b_setval(clpbn_tables, NewTab),
M:NKey M:NKey
) )
) )).
).
user:term_expansion((P :- Gs), NC) :- user:term_expansion((P :- Gs), NC) :-
clpbn_table(P, M, NP), clpbn_table(P, M, NP),

View File

@ -54,12 +54,10 @@ get_keys([_|AVars], KeysVars) :- % may be non-CLPBN vars.
merge_same_key([], [], _, []). merge_same_key([], [], _, []).
merge_same_key([K1-V1,K2-V2|Vs], SortedAVars, Ks, UnifiableVars) :- merge_same_key([K1-V1,K2-V2|Vs], SortedAVars, Ks, UnifiableVars) :-
K1 == K2, !, K1 == K2, !,
(clpbn:get_atts(V1, [evidence(E)]) (clpbn:get_atts(V1, [evidence(E)]) ->
->
clpbn:put_atts(V2, [evidence(E)]) clpbn:put_atts(V2, [evidence(E)])
; ;
clpbn:get_atts(V2, [evidence(E)]) clpbn:get_atts(V2, [evidence(E)]) ->
->
clpbn:put_atts(V1, [evidence(E)]) clpbn:put_atts(V1, [evidence(E)])
; ;
true true

View File

@ -11,7 +11,8 @@
% %
:- module(clpbn_aleph, :- module(clpbn_aleph,
[init_clpbn_cost/0, [init_clpbn_cost/0,
random_type/2]). random_type/2
]).
:- dynamic rt/2, inited/1. :- dynamic rt/2, inited/1.
@ -19,7 +20,8 @@
[{}/1, [{}/1,
clpbn_flag/2, clpbn_flag/2,
clpbn_flag/3, clpbn_flag/3,
set_clpbn_flag/2]). set_clpbn_flag/2
]).
:- use_module(library('clpbn/learning/em')). :- use_module(library('clpbn/learning/em')).
@ -42,7 +44,8 @@
clpbn_tabled_number_of_clauses/2, clpbn_tabled_number_of_clauses/2,
clpbn_is_tabled/1, clpbn_is_tabled/1,
clpbn_reset_tables/0, clpbn_reset_tables/0,
clpbn_tabled_dynamic/1]). clpbn_tabled_dynamic/1
]).
% %
% Tell Aleph not to use default solver during saturation % Tell Aleph not to use default solver during saturation

View File

@ -8,20 +8,20 @@
:- module(bnt_parameters, [learn_parameters/2]). :- module(bnt_parameters, [learn_parameters/2]).
:- use_module(library('clpbn'), [ :- use_module(library('clpbn'),
clpbn_flag/3]). [clpbn_flag/3]).
:- use_module(library('clpbn/bnt'), [ :- use_module(library('clpbn/bnt'),
create_bnt_graph/2]). [create_bnt_graph/2]).
:- use_module(library('clpbn/display'), [ :- use_module(library('clpbn/display'),
clpbn_bind_vals/3]). [clpbn_bind_vals/3]).
:- use_module(library('clpbn/dists'), [ :- use_module(library('clpbn/dists'),
get_dist_domain/2 [get_dist_domain/2]).
]).
:- use_module(library(matlab), [matlab_initialized_cells/4, :- use_module(library(matlab),
[matlab_initialized_cells/4,
matlab_call/2, matlab_call/2,
matlab_get_variable/2 matlab_get_variable/2
]). ]).

View File

@ -129,8 +129,7 @@ setup_em_network(Items, state(AllDists, AllDistInstances, MargVars, SolverState)
run_examples(user:Exs, Keys, Factors, EList) :- run_examples(user:Exs, Keys, Factors, EList) :-
Exs = [_:_|_], !, Exs = [_:_|_], !,
findall(ex(EKs, EFs, EEs), run_example(Exs, EKs, EFs, EEs), findall(ex(EKs, EFs, EEs), run_example(Exs, EKs, EFs, EEs), VExs),
VExs),
foldl4(join_example, VExs, [], Keys, [], Factors, [], EList, 0, _). foldl4(join_example, VExs, [], Keys, [], Factors, [], EList, 0, _).
run_examples(Items, Keys, Factors, EList) :- run_examples(Items, Keys, Factors, EList) :-
run_ex(Items, Keys, Factors, EList). run_ex(Items, Keys, Factors, EList).

View File

@ -2,12 +2,14 @@
% Utilities for learning % Utilities for learning
% %
:- module(clpbn_learn_utils, [run_all/1, :- module(clpbn_learn_utils,
[run_all/1,
clpbn_vars/2, clpbn_vars/2,
normalise_counts/2, normalise_counts/2,
compute_likelihood/3, compute_likelihood/3,
soften_sample/2, soften_sample/2,
soften_sample/3]). soften_sample/3
]).
:- use_module(library(clpbn), :- use_module(library(clpbn),
[clpbn_flag/2]). [clpbn_flag/2]).

View File

@ -5,9 +5,11 @@
% This assumes we have a single big example. % This assumes we have a single big example.
% %
:- module(clpbn_mle, [learn_parameters/2, :- module(clpbn_mle,
[learn_parameters/2,
learn_parameters/3, learn_parameters/3,
parameters_from_evidence/3]). parameters_from_evidence/3
]).
:- use_module(library('clpbn')). :- use_module(library('clpbn')).
@ -16,11 +18,13 @@
clpbn_vars/2, clpbn_vars/2,
normalise_counts/2, normalise_counts/2,
soften_table/2, soften_table/2,
normalise_counts/2]). normalise_counts/2
]).
:- use_module(library('clpbn/dists'), :- use_module(library('clpbn/dists'),
[empty_dist/2, [empty_dist/2,
dist_new_table/2]). dist_new_table/2
]).
:- use_module(library(matrix), :- use_module(library(matrix),
[matrix_inc/2]). [matrix_inc/2]).

View File

@ -168,8 +168,7 @@ interface_predicate(Sk) :-
evidence(Sk,Ev) -> Ev = Var; evidence(Sk,Ev) -> Ev = Var;
var(Var) -> insert_atts(Var,Sk) ; var(Var) -> insert_atts(Var,Sk) ;
add_evidence(Sk,Var) add_evidence(Sk,Var)
) )).
).
insert_atts(Var,Sk) :- insert_atts(Var,Sk) :-
clpbn:put_atts(Var,[key(Sk)]). clpbn:put_atts(Var,[key(Sk)]).