prefix calls to c++ functions with cpp_
This commit is contained in:
parent
2b896aecb4
commit
d91e91b97e
@ -6,16 +6,17 @@
|
||||
|
||||
:- module(clpbn_horus,
|
||||
[set_solver/1,
|
||||
create_lifted_network/3,
|
||||
create_ground_network/4,
|
||||
set_parfactors_params/2,
|
||||
set_factors_params/2,
|
||||
run_lifted_solver/3,
|
||||
run_ground_solver/3,
|
||||
set_vars_information/2,
|
||||
set_horus_flag/2,
|
||||
free_parfactors/1,
|
||||
free_ground_network/1
|
||||
set_horus_flag/1,
|
||||
cpp_create_lifted_network/3,
|
||||
cpp_ground_network/4,
|
||||
cpp_set_parfactors_params/2,
|
||||
cpp_set_factors_params/2,
|
||||
cpp_run_lifted_solver/3,
|
||||
cpp_run_ground_solver/3,
|
||||
cpp_set_vars_information/2,
|
||||
cpp_set_horus_flag/2,
|
||||
cpp_free_parfactors/1,
|
||||
cpp_free_ground_network/1
|
||||
]).
|
||||
|
||||
|
||||
@ -24,7 +25,7 @@
|
||||
|
||||
|
||||
patch_things_up :-
|
||||
assert_static(clpbn_horus:set_horus_flag(_,_)).
|
||||
assert_static(clpbn_horus:cpp_set_horus_flag(_,_)).
|
||||
|
||||
|
||||
warning :-
|
||||
@ -39,24 +40,27 @@ set_solver(ve) :- set_pfl_flag(solver,ve).
|
||||
set_solver(jt) :- set_pfl_flag(solver,jt).
|
||||
set_solver(gibbs) :- set_pfl_flag(solver,gibbs).
|
||||
set_solver(fove) :- set_pfl_flag(solver,fove).
|
||||
set_solver(hve) :- set_pfl_flag(solver,bp), set_horus_flag(inf_alg, ve).
|
||||
set_solver(bp) :- set_pfl_flag(solver,bp), set_horus_flag(inf_alg, bp).
|
||||
set_solver(cbp) :- set_pfl_flag(solver,bp), set_horus_flag(inf_alg, cbp).
|
||||
set_solver(hve) :- set_pfl_flag(solver,bp), cpp_set_horus_flag(inf_alg, ve).
|
||||
set_solver(bp) :- set_pfl_flag(solver,bp), cpp_set_horus_flag(inf_alg, bp).
|
||||
set_solver(cbp) :- set_pfl_flag(solver,bp), cpp_set_horus_flag(inf_alg, cbp).
|
||||
set_solver(S) :- throw(error('unknow solver ', S)).
|
||||
|
||||
%:- set_horus_flag(inf_alg, ve).
|
||||
%:- set_horus_flag(inf_alg, bp).
|
||||
%: -set_horus_flag(inf_alg, cbp).
|
||||
|
||||
:- set_horus_flag(schedule, seq_fixed).
|
||||
%:- set_horus_flag(schedule, seq_random).
|
||||
%:- set_horus_flag(schedule, parallel).
|
||||
%:- set_horus_flag(schedule, max_residual).
|
||||
set_horus_flag(K,V) :- cpp_set_horus_flag(K,V).
|
||||
|
||||
:- set_horus_flag(accuracy, 0.0001).
|
||||
%:- cpp_set_horus_flag(inf_alg, ve).
|
||||
%:- cpp_set_horus_flag(inf_alg, bp).
|
||||
%: -cpp_set_horus_flag(inf_alg, cbp).
|
||||
|
||||
:- set_horus_flag(max_iter, 1000).
|
||||
:- cpp_set_horus_flag(schedule, seq_fixed).
|
||||
%:- cpp_set_horus_flag(schedule, seq_random).
|
||||
%:- cpp_set_horus_flag(schedule, parallel).
|
||||
%:- cpp_set_horus_flag(schedule, max_residual).
|
||||
|
||||
:- set_horus_flag(use_logarithms, false).
|
||||
% :- set_horus_flag(use_logarithms, true).
|
||||
:- cpp_set_horus_flag(accuracy, 0.0001).
|
||||
|
||||
:- cpp_set_horus_flag(max_iter, 1000).
|
||||
|
||||
:- cpp_set_horus_flag(use_logarithms, false).
|
||||
% :- cpp_set_horus_flag(use_logarithms, true).
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
||||
]).
|
||||
|
||||
:- use_module(horus,
|
||||
[create_ground_network/4,
|
||||
set_factors_params/2,
|
||||
run_ground_solver/3,
|
||||
set_vars_information/2,
|
||||
free_ground_network/1
|
||||
[cpp_ground_network/4,
|
||||
cpp_set_factors_params/2,
|
||||
cpp_run_ground_solver/3,
|
||||
cpp_set_vars_information/2,
|
||||
cpp_free_ground_network/1
|
||||
]).
|
||||
|
||||
:- use_module(library('clpbn/dists'),
|
||||
@ -65,23 +65,23 @@ call_bp_ground(QueryVars, QueryKeys, AllKeys, Factors, Evidence, Output) :-
|
||||
%writeln(factorIds:FactorIds), writeln(''),
|
||||
%writeln(evidence:Evidence), writeln(''),
|
||||
%writeln(evidenceIds:EvidenceIds), writeln(''),
|
||||
create_ground_network(Type, FactorIds, EvidenceIds, Network),
|
||||
cpp_ground_network(Type, FactorIds, EvidenceIds, Network),
|
||||
%get_vars_information(AllKeys, StatesNames),
|
||||
%terms_to_atoms(AllKeys, KeysAtoms),
|
||||
%set_vars_information(KeysAtoms, StatesNames),
|
||||
%cpp_set_vars_information(KeysAtoms, StatesNames),
|
||||
run_solver(ground(Network,Hash), QueryKeys, Solutions),
|
||||
clpbn_bind_vals([QueryVars], Solutions, Output),
|
||||
free_ground_network(Network).
|
||||
cpp_free_ground_network(Network).
|
||||
|
||||
|
||||
run_solver(ground(Network,Hash), QueryKeys, Solutions) :-
|
||||
%get_dists_parameters(DistIds, DistsParams),
|
||||
%set_factors_params(Network, DistsParams),
|
||||
%cpp_set_factors_params(Network, DistsParams),
|
||||
list_of_keys_to_ids(QueryKeys, Hash, QueryIds),
|
||||
%writeln(queryKeys:QueryKeys), writeln(''),
|
||||
%writeln(queryIds:QueryIds), writeln(''),
|
||||
list_of_keys_to_ids(QueryKeys, Hash, QueryIds),
|
||||
run_ground_solver(Network, [QueryIds], Solutions).
|
||||
cpp_run_ground_solver(Network, [QueryIds], Solutions).
|
||||
|
||||
|
||||
keys_to_ids([], _, Hash, Hash).
|
||||
@ -134,7 +134,7 @@ terms_to_atoms(K.Ks, Atom.As) :-
|
||||
|
||||
|
||||
finalize_bp_solver(bp(Network, _)) :-
|
||||
free_ground_network(Network).
|
||||
cpp_free_ground_network(Network).
|
||||
|
||||
|
||||
bp([[]],_,_) :- !.
|
||||
@ -149,15 +149,15 @@ init_bp_solver(_, AllVars0, _, bp(BayesNet, DistIds)) :-
|
||||
%check_for_agg_vars(AllVars0, AllVars),
|
||||
get_vars_info(AllVars0, VarsInfo, DistIds0),
|
||||
sort(DistIds0, DistIds),
|
||||
create_ground_network(VarsInfo, BayesNet),
|
||||
cpp_ground_network(VarsInfo, BayesNet),
|
||||
true.
|
||||
|
||||
|
||||
run_bp_solver(QueryVars, Solutions, bp(Network, DistIds)) :-
|
||||
get_dists_parameters(DistIds, DistsParams),
|
||||
set_factors_params(Network, DistsParams),
|
||||
cpp_set_factors_params(Network, DistsParams),
|
||||
vars_to_ids(QueryVars, QueryVarsIds),
|
||||
run_ground_solver(Network, QueryVarsIds, Solutions).
|
||||
cpp_run_ground_solver(Network, QueryVarsIds, Solutions).
|
||||
|
||||
|
||||
get_dists_parameters([],[]).
|
||||
|
@ -14,10 +14,10 @@
|
||||
]).
|
||||
|
||||
:- use_module(horus,
|
||||
[create_lifted_network/3,
|
||||
set_parfactors_params/2,
|
||||
run_lifted_solver/3,
|
||||
free_parfactors/1
|
||||
[cpp_create_lifted_network/3,
|
||||
cpp_set_parfactors_params/2,
|
||||
cpp_run_lifted_solver/3,
|
||||
cpp_free_parfactors/1
|
||||
]).
|
||||
|
||||
:- use_module(library('clpbn/display'),
|
||||
@ -48,7 +48,7 @@ init_fove_solver(_, AllAttVars, _, fove(ParfactorList, DistIds)) :-
|
||||
get_observed_vars(AllAttVars, ObservedVars),
|
||||
%writeln(parfactors:Parfactors:'\n'),
|
||||
%writeln(evidence:ObservedVars:'\n'),
|
||||
create_lifted_network(Parfactors,ObservedVars,ParfactorList).
|
||||
cpp_create_lifted_network(Parfactors,ObservedVars,ParfactorList).
|
||||
|
||||
|
||||
:- table get_parfactors/1.
|
||||
@ -139,10 +139,10 @@ run_fove_solver(QueryVarsAtts, Solutions, fove(ParfactorList, DistIds)) :-
|
||||
%writeln(queryVars:QueryVars), writeln(''),
|
||||
get_dists_parameters(DistIds, DistsParams),
|
||||
%writeln(dists:DistsParams), writeln(''),
|
||||
set_parfactors_params(ParfactorList, DistsParams),
|
||||
run_lifted_solver(ParfactorList, QueryVars, Solutions).
|
||||
cpp_set_parfactors_params(ParfactorList, DistsParams),
|
||||
cpp_run_lifted_solver(ParfactorList, QueryVars, Solutions).
|
||||
|
||||
|
||||
finalize_fove_solver(fove(ParfactorList, _)) :-
|
||||
free_parfactors(ParfactorList).
|
||||
cpp_free_parfactors(ParfactorList).
|
||||
|
||||
|
@ -197,7 +197,6 @@ void readLiftedEvidence (
|
||||
}
|
||||
unsigned evidence = (unsigned) YAP_IntOfTerm (YAP_ArgOfTerm (2, pair));
|
||||
bool found = false;
|
||||
cout << "has evidence()" << endl;
|
||||
for (unsigned i = 0; i < obsFormulas.size(); i++) {
|
||||
if (obsFormulas[i].functor() == functor &&
|
||||
obsFormulas[i].arity() == args.size() &&
|
||||
@ -572,15 +571,15 @@ freeParfactors (void)
|
||||
extern "C" void
|
||||
init_predicates (void)
|
||||
{
|
||||
YAP_UserCPredicate ("create_lifted_network", createLiftedNetwork, 3);
|
||||
YAP_UserCPredicate ("create_ground_network", createGroundNetwork, 4);
|
||||
YAP_UserCPredicate ("run_lifted_solver", runLiftedSolver, 3);
|
||||
YAP_UserCPredicate ("run_ground_solver", runGroundSolver, 3);
|
||||
YAP_UserCPredicate ("set_parfactors_params", setParfactorsParams, 2);
|
||||
YAP_UserCPredicate ("set_factors_params", setFactorsParams, 2);
|
||||
YAP_UserCPredicate ("set_vars_information", setVarsInformation, 2);
|
||||
YAP_UserCPredicate ("set_horus_flag", setHorusFlag, 2);
|
||||
YAP_UserCPredicate ("free_parfactors", freeParfactors, 1);
|
||||
YAP_UserCPredicate ("free_ground_network", freeGroundNetwork, 1);
|
||||
YAP_UserCPredicate ("cpp_create_lifted_network", createLiftedNetwork, 3);
|
||||
YAP_UserCPredicate ("cpp_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);
|
||||
YAP_UserCPredicate ("cpp_cpp_set_factors_params", setFactorsParams, 2);
|
||||
YAP_UserCPredicate ("cpp_set_vars_information", setVarsInformation, 2);
|
||||
YAP_UserCPredicate ("cpp_set_horus_flag", setHorusFlag, 2);
|
||||
YAP_UserCPredicate ("cpp_free_parfactors", freeParfactors, 1);
|
||||
YAP_UserCPredicate ("cpp_free_ground_network", freeGroundNetwork, 1);
|
||||
}
|
||||
|
||||
|
@ -23,10 +23,10 @@ CC=@CC@
|
||||
CXX=@CXX@
|
||||
|
||||
# normal
|
||||
#CXXFLAGS= -std=c++0x @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../../../.. -I$(srcdir)/../../../../include @CPPFLAGS@ -DNDEBUG
|
||||
#CXXFLAGS= -std=c++0x @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../../.. -I$(srcdir)/../../../include @CPPFLAGS@ -DNDEBUG
|
||||
|
||||
# debug
|
||||
CXXFLAGS= -std=c++0x @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../../../.. -I$(srcdir)/../../../../include @CPPFLAGS@ -g -O0 -Wextra
|
||||
CXXFLAGS= -std=c++0x @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -D_YAP_NOT_INSTALLED_=1 -I$(srcdir) -I../../.. -I$(srcdir)/../../../include @CPPFLAGS@ -g -O0 -Wextra
|
||||
|
||||
|
||||
#
|
||||
|
Reference in New Issue
Block a user