some renamings
This commit is contained in:
parent
d91e91b97e
commit
6cb718942a
@ -39,20 +39,19 @@
|
||||
]).
|
||||
|
||||
:- use_module('clpbn/horus_ground',
|
||||
[bp/3,
|
||||
check_if_bp_done/1,
|
||||
init_bp_solver/4,
|
||||
run_bp_solver/3,
|
||||
call_bp_ground/6,
|
||||
finalize_bp_solver/1
|
||||
[call_horus_ground_solver/6,
|
||||
check_if_horus_ground_solver_done/1,
|
||||
init_horus_ground_solver/4,
|
||||
run_horus_ground_solver/3,
|
||||
finalize_horus_ground_solver/1
|
||||
]).
|
||||
|
||||
:- use_module('clpbn/horus_lifted',
|
||||
[fove/3,
|
||||
check_if_fove_done/1,
|
||||
init_fove_solver/4,
|
||||
run_fove_solver/3,
|
||||
finalize_fove_solver/1
|
||||
[call_horus_lifted_solver/3,
|
||||
check_if_horus_lifted_solver_done/1,
|
||||
init_horus_lifted_solver/4,
|
||||
run_horus_lifted_solver/3,
|
||||
finalize_horus_lifted_solver/1
|
||||
]).
|
||||
|
||||
:- use_module('clpbn/jt',
|
||||
@ -300,18 +299,19 @@ write_out(jt, GVars, AVars, DiffVars) :-
|
||||
jt(GVars, AVars, DiffVars).
|
||||
write_out(bdd, GVars, AVars, DiffVars) :-
|
||||
bdd(GVars, AVars, DiffVars).
|
||||
write_out(bp, GVars, AVars, DiffVars) :-
|
||||
bp(GVars, AVars, DiffVars).
|
||||
write_out(bp, _GVars, _AVars, _DiffVars) :-
|
||||
writeln('interface not supported anymore').
|
||||
%bp(GVars, AVars, DiffVars).
|
||||
write_out(gibbs, GVars, AVars, DiffVars) :-
|
||||
gibbs(GVars, AVars, DiffVars).
|
||||
write_out(bnt, GVars, AVars, DiffVars) :-
|
||||
do_bnt(GVars, AVars, DiffVars).
|
||||
write_out(fove, GVars, AVars, DiffVars) :-
|
||||
fove(GVars, AVars, DiffVars).
|
||||
call_horus_lifted_solver(GVars, AVars, DiffVars).
|
||||
|
||||
% call a solver with keys, not actual variables
|
||||
call_ground_solver(bp, GVars, GoalKeys, Keys, Factors, Evidence, Answ) :-
|
||||
call_bp_ground(GVars, GoalKeys, Keys, Factors, Evidence, Answ).
|
||||
call_horus_ground_solver(GVars, GoalKeys, Keys, Factors, Evidence, Answ).
|
||||
|
||||
|
||||
get_bnode(Var, Goal) :-
|
||||
@ -394,7 +394,7 @@ bind_clpbn(_, Var, _, _, _, _, []) :-
|
||||
check_if_ve_done(Var), !.
|
||||
bind_clpbn(_, Var, _, _, _, _, []) :-
|
||||
use(bp),
|
||||
check_if_bp_done(Var), !.
|
||||
check_if_horus_ground_solver_done(Var), !.
|
||||
bind_clpbn(_, Var, _, _, _, _, []) :-
|
||||
use(jt),
|
||||
check_if_ve_done(Var), !.
|
||||
@ -469,7 +469,7 @@ clpbn_init_solver(gibbs, LVs, Vs0, VarsWithUnboundKeys, State) :-
|
||||
clpbn_init_solver(ve, LVs, Vs0, VarsWithUnboundKeys, State) :-
|
||||
init_ve_solver(LVs, Vs0, VarsWithUnboundKeys, State).
|
||||
clpbn_init_solver(bp, LVs, Vs0, VarsWithUnboundKeys, State) :-
|
||||
init_bp_solver(LVs, Vs0, VarsWithUnboundKeys, State).
|
||||
init_horus_ground_solver(LVs, Vs0, VarsWithUnboundKeys, State).
|
||||
clpbn_init_solver(jt, LVs, Vs0, VarsWithUnboundKeys, State) :-
|
||||
init_jt_solver(LVs, Vs0, VarsWithUnboundKeys, State).
|
||||
clpbn_init_solver(bdd, LVs, Vs0, VarsWithUnboundKeys, State) :-
|
||||
@ -495,7 +495,7 @@ clpbn_run_solver(ve, LVs, LPs, State) :-
|
||||
run_ve_solver(LVs, LPs, State).
|
||||
|
||||
clpbn_run_solver(bp, LVs, LPs, State) :-
|
||||
run_bp_solver(LVs, LPs, State).
|
||||
run_horus_ground_solver(LVs, LPs, State).
|
||||
|
||||
clpbn_run_solver(jt, LVs, LPs, State) :-
|
||||
run_jt_solver(LVs, LPs, State).
|
||||
@ -516,7 +516,7 @@ clpbn_finalize_solver(State) :-
|
||||
solver(bp), !,
|
||||
functor(State, _, Last),
|
||||
arg(Last, State, Info),
|
||||
finalize_bp_solver(Info).
|
||||
finalize_horus_ground_solver(Info).
|
||||
clpbn_finalize_solver(_State).
|
||||
|
||||
probability(Goal, Prob) :-
|
||||
|
@ -8,7 +8,7 @@
|
||||
[set_solver/1,
|
||||
set_horus_flag/1,
|
||||
cpp_create_lifted_network/3,
|
||||
cpp_ground_network/4,
|
||||
cpp_create_ground_network/4,
|
||||
cpp_set_parfactors_params/2,
|
||||
cpp_set_factors_params/2,
|
||||
cpp_run_lifted_solver/3,
|
||||
|
@ -8,16 +8,15 @@
|
||||
********************************************************/
|
||||
|
||||
:- module(clpbn_horus_ground,
|
||||
[bp/3,
|
||||
check_if_bp_done/1,
|
||||
init_bp_solver/4,
|
||||
run_bp_solver/3,
|
||||
call_bp_ground/6,
|
||||
finalize_bp_solver/1
|
||||
[call_horus_ground_solver/6,
|
||||
check_if_horus_ground_solver_done/1,
|
||||
init_horus_ground_solver/4,
|
||||
run_horus_ground_solver/3,
|
||||
finalize_horus_ground_solver/1
|
||||
]).
|
||||
|
||||
:- use_module(horus,
|
||||
[cpp_ground_network/4,
|
||||
[cpp_create_ground_network/4,
|
||||
cpp_set_factors_params/2,
|
||||
cpp_run_ground_solver/3,
|
||||
cpp_set_vars_information/2,
|
||||
@ -52,7 +51,7 @@
|
||||
:- use_module(library(bhash)).
|
||||
|
||||
|
||||
call_bp_ground(QueryVars, QueryKeys, AllKeys, Factors, Evidence, Output) :-
|
||||
call_horus_ground_solver(QueryVars, QueryKeys, AllKeys, Factors, Evidence, Output) :-
|
||||
b_hash_new(Hash0),
|
||||
keys_to_ids(AllKeys, 0, Hash0, Hash),
|
||||
get_factors_type(Factors, Type),
|
||||
@ -65,7 +64,7 @@ call_bp_ground(QueryVars, QueryKeys, AllKeys, Factors, Evidence, Output) :-
|
||||
%writeln(factorIds:FactorIds), writeln(''),
|
||||
%writeln(evidence:Evidence), writeln(''),
|
||||
%writeln(evidenceIds:EvidenceIds), writeln(''),
|
||||
cpp_ground_network(Type, FactorIds, EvidenceIds, Network),
|
||||
cpp_create_ground_network(Type, FactorIds, EvidenceIds, Network),
|
||||
%get_vars_information(AllKeys, StatesNames),
|
||||
%terms_to_atoms(AllKeys, KeysAtoms),
|
||||
%cpp_set_vars_information(KeysAtoms, StatesNames),
|
||||
@ -109,7 +108,7 @@ factors_to_ids([f(_, DistId, Keys, CPT)|Fs], Hash, [f(Ids, Ranges, CPT, DistId)|
|
||||
|
||||
|
||||
get_ranges([],[]).
|
||||
get_ranges(K.Ks, Range.Rs) :- !,
|
||||
get_ranges(K.Ks, Range.Rs) :- !,
|
||||
skolem(K,Domain),
|
||||
length(Domain,Range),
|
||||
get_ranges(Ks, Rs).
|
||||
@ -133,31 +132,34 @@ terms_to_atoms(K.Ks, Atom.As) :-
|
||||
terms_to_atoms(Ks,As).
|
||||
|
||||
|
||||
finalize_bp_solver(bp(Network, _)) :-
|
||||
finalize_horus_ground_solver(bp(Network, _)) :-
|
||||
cpp_free_ground_network(Network).
|
||||
|
||||
|
||||
bp([[]],_,_) :- !.
|
||||
bp([QueryVars], AllVars, Output) :-
|
||||
init_bp_solver(_, AllVars, _, Network),
|
||||
run_bp_solver([QueryVars], LPs, Network),
|
||||
finalize_bp_solver(Network),
|
||||
clpbn_bind_vals([QueryVars], LPs, Output).
|
||||
init_horus_ground_solver(_, _AllVars0, _, bp(_BayesNet, _DistIds)) :- !.
|
||||
|
||||
run_horus_ground_solver(_QueryVars, _Solutions, bp(_Network, _DistIds)) :- !.
|
||||
|
||||
init_bp_solver(_, AllVars0, _, bp(BayesNet, DistIds)) :-
|
||||
%check_for_agg_vars(AllVars0, AllVars),
|
||||
get_vars_info(AllVars0, VarsInfo, DistIds0),
|
||||
sort(DistIds0, DistIds),
|
||||
cpp_ground_network(VarsInfo, BayesNet),
|
||||
true.
|
||||
|
||||
|
||||
run_bp_solver(QueryVars, Solutions, bp(Network, DistIds)) :-
|
||||
get_dists_parameters(DistIds, DistsParams),
|
||||
cpp_set_factors_params(Network, DistsParams),
|
||||
vars_to_ids(QueryVars, QueryVarsIds),
|
||||
cpp_run_ground_solver(Network, QueryVarsIds, Solutions).
|
||||
%bp([[]],_,_) :- !.
|
||||
%bp([QueryVars], AllVars, Output) :-
|
||||
% init_horus_ground_solver(_, AllVars, _, Network),
|
||||
% run_horus_ground_solver([QueryVars], LPs, Network),
|
||||
% finalize_horus_ground_solver(Network),
|
||||
% clpbn_bind_vals([QueryVars], LPs, Output).
|
||||
%
|
||||
%init_horus_ground_solver(_, AllVars0, _, bp(BayesNet, DistIds)) :-
|
||||
% %check_for_agg_vars(AllVars0, AllVars),
|
||||
% get_vars_info(AllVars0, VarsInfo, DistIds0),
|
||||
% sort(DistIds0, DistIds),
|
||||
% cpp_create_ground_network(VarsInfo, BayesNet),
|
||||
% true.
|
||||
%
|
||||
%
|
||||
%run_horus_ground_solver(QueryVars, Solutions, bp(Network, DistIds)) :-
|
||||
% get_dists_parameters(DistIds, DistsParams),
|
||||
% cpp_set_factors_params(Network, DistsParams),
|
||||
% vars_to_ids(QueryVars, QueryVarsIds),
|
||||
% cpp_run_ground_solver(Network, QueryVarsIds, Solutions).
|
||||
|
||||
|
||||
get_dists_parameters([],[]).
|
||||
|
@ -6,11 +6,11 @@
|
||||
********************************************************/
|
||||
|
||||
:- module(clpbn_horus_lifted,
|
||||
[fove/3,
|
||||
check_if_fove_done/1,
|
||||
init_fove_solver/4,
|
||||
run_fove_solver/3,
|
||||
finalize_fove_solver/1
|
||||
[call_horus_lifted_solver/3,
|
||||
check_if_horus_lifted_solver_done/1,
|
||||
init_horus_lifted_solver/4,
|
||||
run_horus_lifted_solver/3,
|
||||
finalize_horus_lifted_solver/1
|
||||
]).
|
||||
|
||||
:- use_module(horus,
|
||||
@ -33,15 +33,15 @@
|
||||
]).
|
||||
|
||||
|
||||
fove([[]], _, _) :- !.
|
||||
fove([QueryVars], AllVars, Output) :-
|
||||
init_fove_solver(_, AllVars, _, ParfactorList),
|
||||
run_fove_solver([QueryVars], LPs, ParfactorList),
|
||||
finalize_fove_solver(ParfactorList),
|
||||
call_horus_lifted_solver([[]], _, _) :- !.
|
||||
call_horus_lifted_solver([QueryVars], AllVars, Output) :-
|
||||
init_horus_lifted_solver(_, AllVars, _, ParfactorList),
|
||||
run_horus_lifted_solver([QueryVars], LPs, ParfactorList),
|
||||
finalize_horus_lifted_solver(ParfactorList),
|
||||
clpbn_bind_vals([QueryVars], LPs, Output).
|
||||
|
||||
|
||||
init_fove_solver(_, AllAttVars, _, fove(ParfactorList, DistIds)) :-
|
||||
init_horus_lifted_solver(_, AllAttVars, _, fove(ParfactorList, DistIds)) :-
|
||||
get_parfactors(Parfactors),
|
||||
get_dist_ids(Parfactors, DistIds0),
|
||||
sort(DistIds0, DistIds),
|
||||
@ -134,7 +134,7 @@ get_dists_parameters([Id|Ids], [dist(Id, Params)|DistsInfo]) :-
|
||||
get_dists_parameters(Ids, DistsInfo).
|
||||
|
||||
|
||||
run_fove_solver(QueryVarsAtts, Solutions, fove(ParfactorList, DistIds)) :-
|
||||
run_horus_lifted_solver(QueryVarsAtts, Solutions, fove(ParfactorList, DistIds)) :-
|
||||
get_query_vars(QueryVarsAtts, QueryVars),
|
||||
%writeln(queryVars:QueryVars), writeln(''),
|
||||
get_dists_parameters(DistIds, DistsParams),
|
||||
@ -143,6 +143,6 @@ run_fove_solver(QueryVarsAtts, Solutions, fove(ParfactorList, DistIds)) :-
|
||||
cpp_run_lifted_solver(ParfactorList, QueryVars, Solutions).
|
||||
|
||||
|
||||
finalize_fove_solver(fove(ParfactorList, _)) :-
|
||||
finalize_horus_lifted_solver(fove(ParfactorList, _)) :-
|
||||
cpp_free_parfactors(ParfactorList).
|
||||
|
||||
|
@ -572,7 +572,7 @@ extern "C" void
|
||||
init_predicates (void)
|
||||
{
|
||||
YAP_UserCPredicate ("cpp_create_lifted_network", createLiftedNetwork, 3);
|
||||
YAP_UserCPredicate ("cpp_ground_network", createGroundNetwork, 4);
|
||||
YAP_UserCPredicate ("cpp_create_ground_network", createGroundNetwork, 4);
|
||||
YAP_UserCPredicate ("cpp_run_lifted_solver", runLiftedSolver, 3);
|
||||
YAP_UserCPredicate ("cpp_run_ground_solver", runGroundSolver, 3);
|
||||
YAP_UserCPredicate ("cpp_set_parfactors_params", setParfactorsParams, 2);
|
||||
|
Reference in New Issue
Block a user