Don't pass around the Solver in run_horus_ground_solver

This commit is contained in:
Tiago Gomes 2012-12-15 15:56:05 +00:00
parent ea931f2f93
commit 81ac6f1913
2 changed files with 19 additions and 19 deletions

View File

@ -49,7 +49,7 @@
[call_horus_ground_solver/6, [call_horus_ground_solver/6,
check_if_horus_ground_solver_done/1, check_if_horus_ground_solver_done/1,
init_horus_ground_solver/5, init_horus_ground_solver/5,
run_horus_ground_solver/4, run_horus_ground_solver/3,
finalize_horus_ground_solver/1 finalize_horus_ground_solver/1
]). ]).
@ -606,6 +606,11 @@ pfl_init_solver(QueryKeys, AllKeys, Factors, Evidence, State, bp) :-
pfl_init_solver(QueryKeys, AllKeys, Factors, Evidence, State, cbp) :- pfl_init_solver(QueryKeys, AllKeys, Factors, Evidence, State, cbp) :-
clpbn_horus:set_horus_flag(ground_solver, cbp), clpbn_horus:set_horus_flag(ground_solver, cbp),
init_horus_ground_solver(QueryKeys, AllKeys, Factors, Evidence, State). init_horus_ground_solver(QueryKeys, AllKeys, Factors, Evidence, State).
pfl_init_solver(_, _, _, _, _, Solver) :-
write('Error: solver `'),
write(Solver),
write('\' cannot be used for learning').
pfl_run_solver(LVs, LPs, State, ve) :- pfl_run_solver(LVs, LPs, State, ve) :-
run_ve_ground_solver(LVs, LPs, State). run_ve_ground_solver(LVs, LPs, State).
@ -613,14 +618,14 @@ pfl_run_solver(LVs, LPs, State, ve) :-
pfl_run_solver(LVs, LPs, State, bdd) :- pfl_run_solver(LVs, LPs, State, bdd) :-
run_bdd_ground_solver(LVs, LPs, State). run_bdd_ground_solver(LVs, LPs, State).
pfl_run_solver(LVs, LPs, State, hve), pfl_run_solver(LVs, LPs, State, hve) :-
run_horus_ground_solver(LVs, LPs, State, hve). run_horus_ground_solver(LVs, LPs, State).
pfl_run_solver(LVs, LPs, State, bp) :- pfl_run_solver(LVs, LPs, State, bp) :-
run_horus_ground_solver(LVs, LPs, State, bp). run_horus_ground_solver(LVs, LPs, State).
pfl_run_solver(LVs, LPs, State, cbp) :- pfl_run_solver(LVs, LPs, State, cbp) :-
run_horus_ground_solver(LVs, LPs, State, cbp). run_horus_ground_solver(LVs, LPs, State).
add_keys(Key1+V1,_Key2,Key1+V1). add_keys(Key1+V1,_Key2,Key1+V1).

View File

@ -11,7 +11,7 @@
[call_horus_ground_solver/6, [call_horus_ground_solver/6,
check_if_horus_ground_solver_done/1, check_if_horus_ground_solver_done/1,
init_horus_ground_solver/5, init_horus_ground_solver/5,
run_horus_ground_solver/4, run_horus_ground_solver/3,
finalize_horus_ground_solver/1 finalize_horus_ground_solver/1
]). ]).
@ -53,9 +53,16 @@
call_horus_ground_solver(QueryVars, QueryKeys, AllKeys, Factors, Evidence, Output) :- call_horus_ground_solver(QueryVars, QueryKeys, AllKeys, Factors, Evidence, Output) :-
init_horus_ground_solver(QueryKeys, AllKeys, Factors, Evidence, State), init_horus_ground_solver(QueryKeys, AllKeys, Factors, Evidence, State),
run_solver(State, [QueryKeys], Solutions), run_horus_ground_solver([QueryKeys], Solutions, State),
clpbn_bind_vals([QueryVars], Solutions, Output), clpbn_bind_vals([QueryVars], Solutions, Output),
finalize_horus_ground_solver(State). finalize_horus_ground_solver(State).
run_horus_ground_solver(QueryKeys, Solutions, state(Network,Hash,Id)) :-
%get_dists_parameters(DistIds, DistsParams),
%cpp_set_factors_params(Network, DistsParams),
lists_of_keys_to_ids(QueryKeys, QueryIds, Hash, _, Id, _),
cpp_run_ground_solver(Network, QueryIds, Solutions).
init_horus_ground_solver(QueryKeys, AllKeys, Factors, Evidence, state(Network,Hash4,Id4)) :- init_horus_ground_solver(QueryKeys, AllKeys, Factors, Evidence, state(Network,Hash4,Id4)) :-
@ -68,23 +75,11 @@ init_horus_ground_solver(QueryKeys, AllKeys, Factors, Evidence, state(Network,Ha
cpp_set_vars_information(KeysAtoms, StatesNames). cpp_set_vars_information(KeysAtoms, StatesNames).
run_horus_ground_solver(_QueryVars, Solutions, horus(GKeys, Keys, Factors, Evidence), Solver) :-
set_solver(Solver),
call_horus_ground_solver_for_probabilities(GKeys, Keys, Factors, Evidence, Solutions).
% TODO this is not beeing called! % TODO this is not beeing called!
finalize_horus_ground_solver(state(Network,_Hash,_Id)) :- finalize_horus_ground_solver(state(Network,_Hash,_Id)) :-
cpp_free_ground_network(Network). cpp_free_ground_network(Network).
run_solver(state(Network,Hash,Id), QueryKeys, Solutions) :-
%get_dists_parameters(DistIds, DistsParams),
%cpp_set_factors_params(Network, DistsParams),
lists_of_keys_to_ids(QueryKeys, QueryIds, Hash, _, Id, _),
cpp_run_ground_solver(Network, QueryIds, Solutions).
get_factors_type([f(bayes, _, _)|_], bayes) :- ! . get_factors_type([f(bayes, _, _)|_], bayes) :- ! .
get_factors_type([f(markov, _, _)|_], markov) :- ! . get_factors_type([f(markov, _, _)|_], markov) :- ! .