add flag to lifted knowledge compilation and s/fove/lve
This commit is contained in:
parent
a8c4f4fc52
commit
0ed89d3eeb
@ -49,11 +49,12 @@ Inference Options
|
||||
PFL supports both ground and lifted inference. The inference algorithm
|
||||
can be chosen using the set_solver/1 predicate. The following algorithms
|
||||
are supported:
|
||||
- fove: lifted variable elimination with arbitrary constraints (GC-FOVE)
|
||||
- lve: generalized counting first-order variable elimination (GC-FOVE)
|
||||
- hve: (ground) variable elimination
|
||||
- lbp: lifted first-order belief propagation
|
||||
- cbp: counting belief propagation
|
||||
- bp: (ground) belief propagation
|
||||
- lkc: lifted first-order knowledge compilation
|
||||
|
||||
For example, if we want to use ground variable elimination to solve some
|
||||
query, we need to call first the following goal:
|
||||
|
@ -3,7 +3,7 @@
|
||||
source city.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="fove"
|
||||
SOLVER="lve"
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
@ -32,5 +32,5 @@ function run_all_graphs
|
||||
}
|
||||
|
||||
prepare_new_run
|
||||
run_all_graphs "fove "
|
||||
run_all_graphs "lve "
|
||||
|
@ -3,7 +3,7 @@
|
||||
source cw.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="fove"
|
||||
SOLVER="lve"
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
@ -26,6 +26,6 @@ function run_all_graphs
|
||||
}
|
||||
|
||||
prepare_new_run
|
||||
run_all_graphs "fove "
|
||||
run_all_graphs "lve "
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
cd workshop_attrs
|
||||
source hve_tests.sh
|
||||
source bp_tests.sh
|
||||
source fove_tests.sh
|
||||
source lve_tests.sh
|
||||
source lbp_tests.sh
|
||||
source cbp_tests.sh
|
||||
cd ..
|
||||
@ -11,7 +11,7 @@ cd ..
|
||||
cd comp_workshops
|
||||
source hve_tests.sh
|
||||
source bp_tests.sh
|
||||
source fove_tests.sh
|
||||
source lve_tests.sh
|
||||
source lbp_tests.sh
|
||||
source cbp_tests.sh
|
||||
cd ..
|
||||
@ -19,7 +19,7 @@ cd ..
|
||||
cd city
|
||||
source hve_tests.sh
|
||||
source bp_tests.sh
|
||||
source fove_tests.sh
|
||||
source lve_tests.sh
|
||||
source lbp_tests.sh
|
||||
source cbp_tests.sh
|
||||
cd ..
|
||||
@ -27,7 +27,7 @@ cd ..
|
||||
cd smokers
|
||||
source hve_tests.sh
|
||||
source bp_tests.sh
|
||||
source fove_tests.sh
|
||||
source lve_tests.sh
|
||||
source lbp_tests.sh
|
||||
source cbp_tests.sh
|
||||
cd ..
|
||||
|
@ -3,7 +3,7 @@
|
||||
source sm.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="fove"
|
||||
SOLVER="lve"
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
@ -26,6 +26,6 @@ function run_all_graphs
|
||||
}
|
||||
|
||||
prepare_new_run
|
||||
run_all_graphs "fove "
|
||||
run_all_graphs "lve "
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
source sm.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="fove"
|
||||
SOLVER="lve"
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
@ -30,6 +30,6 @@ function run_all_graphs
|
||||
}
|
||||
|
||||
prepare_new_run
|
||||
run_all_graphs "fove "
|
||||
run_all_graphs "lve "
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
source wa.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="fove"
|
||||
SOLVER="lve"
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
@ -32,6 +32,6 @@ function run_all_graphs
|
||||
}
|
||||
|
||||
prepare_new_run
|
||||
run_all_graphs "fove "
|
||||
run_all_graphs "lve "
|
||||
|
||||
|
@ -39,8 +39,9 @@ set_solver(ve) :- !, set_clpbn_flag(solver,ve).
|
||||
set_solver(bdd) :- !, set_clpbn_flag(solver,bdd).
|
||||
set_solver(jt) :- !, set_clpbn_flag(solver,jt).
|
||||
set_solver(gibbs) :- !, set_clpbn_flag(solver,gibbs).
|
||||
set_solver(fove) :- !, set_clpbn_flag(solver,fove), set_horus_flag(lifted_solver, fove).
|
||||
set_solver(lve) :- !, set_clpbn_flag(solver,fove), set_horus_flag(lifted_solver, lve).
|
||||
set_solver(lbp) :- !, set_clpbn_flag(solver,fove), set_horus_flag(lifted_solver, lbp).
|
||||
set_solver(lkc) :- !, set_clpbn_flag(solver,fove), set_horus_flag(lifted_solver, lkc).
|
||||
set_solver(hve) :- !, set_clpbn_flag(solver,bp), set_horus_flag(ground_solver, ve).
|
||||
set_solver(bp) :- !, set_clpbn_flag(solver,bp), set_horus_flag(ground_solver, bp).
|
||||
set_solver(cbp) :- !, set_clpbn_flag(solver,bp), set_horus_flag(ground_solver, cbp).
|
||||
|
@ -18,7 +18,7 @@ total_students(256).
|
||||
:- ensure_loaded(parschema).
|
||||
|
||||
:- yap_flag(unknown,error).
|
||||
%:- clpbn_horus:set_solver(fove).
|
||||
%:- clpbn_horus:set_solver(lve).
|
||||
%:- clpbn_horus:set_solver(hve).
|
||||
:- clpbn_horus:set_solver(bp).
|
||||
%:- clpbn_horus:set_solver(bdd).
|
||||
|
@ -1,6 +1,6 @@
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
%:- set_solver(fove).
|
||||
%:- set_solver(lve).
|
||||
%:- set_solver(hve).
|
||||
%:- set_solver(bp).
|
||||
%:- set_solver(cbp).
|
||||
|
@ -1,6 +1,6 @@
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
%:- set_solver(fove).
|
||||
%:- set_solver(lve).
|
||||
%:- set_solver(hve).
|
||||
%:- set_solver(bp).
|
||||
%:- set_solver(cbp).
|
||||
|
@ -1,6 +1,6 @@
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
%:- set_solver(fove).
|
||||
%:- set_solver(lve).
|
||||
%:- set_solver(hve).
|
||||
%:- set_solver(bp).
|
||||
%:- set_solver(cbp).
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
:- set_pfl_flag(solver,fove).
|
||||
:- set_pfl_flag(solver,lve).
|
||||
%:- set_pfl_flag(solver,bp), clpbn_horus:set_horus_flag(inf_alg,ve).
|
||||
%:- set_pfl_flag(solver,bp), clpbn_horus:set_horus_flag(inf_alg,bp).
|
||||
%:- set_pfl_flag(solver,bp), clpbn_horus:set_horus_flag(inf_alg,cbp).
|
||||
|
@ -1,6 +1,6 @@
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
:- set_solver(fove).
|
||||
:- set_solver(lve).
|
||||
%:- set_solver(hve).
|
||||
%:- set_solver(bp).
|
||||
%:- set_solver(cbp).
|
||||
|
@ -1,6 +1,6 @@
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
%:- set_solver(fove).
|
||||
%:- set_solver(lve).
|
||||
%:- set_solver(hve).
|
||||
%:- set_solver(bp).
|
||||
%:- set_solver(cbp).
|
||||
|
@ -1,6 +1,6 @@
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
%:- set_solver(fove).
|
||||
%:- set_solver(lve).
|
||||
%:- set_solver(hve).
|
||||
%:- set_solver(bp).
|
||||
%:- set_solver(cbp).
|
||||
|
@ -1,6 +1,6 @@
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
%:- set_solver(fove).
|
||||
%:- set_solver(lve).
|
||||
%:- set_solver(hve).
|
||||
%:- set_solver(bp).
|
||||
%:- set_solver(cbp).
|
||||
|
@ -30,8 +30,9 @@ typedef unsigned long long ullong;
|
||||
|
||||
enum LiftedSolver
|
||||
{
|
||||
FOVE, // first order variable elimination
|
||||
LBP, // lifted belief propagation
|
||||
LVE, // generalized counting first-order variable elimination (GC-FOVE)
|
||||
LBP, // lifted first-order belief propagation
|
||||
LKC // lifted first-order knowledge compilation
|
||||
};
|
||||
|
||||
|
||||
|
@ -647,7 +647,7 @@ void
|
||||
LiftedVe::printSolverFlags (void) const
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "fove [" ;
|
||||
ss << "lve [" ;
|
||||
ss << "log_domain=" << Util::toString (Globals::logDomain);
|
||||
ss << "]" ;
|
||||
cout << ss.str() << endl;
|
||||
|
@ -215,7 +215,7 @@ bool
|
||||
Clause::isIpgLogVar (LogVar X) const
|
||||
{
|
||||
assert (constr_.logVarSet().contains (X));
|
||||
return ipgLogVars_.contains (X);
|
||||
return ipgLvs_.contains (X);
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +237,7 @@ Clause::ipgCandidates (void) const
|
||||
{
|
||||
LogVarSet candidates;
|
||||
LogVarSet allLvs = constr_.logVarSet();
|
||||
allLvs -= ipgLogVars_;
|
||||
allLvs -= ipgLvs_;
|
||||
allLvs -= posCountedLvs_;
|
||||
allLvs -= negCountedLvs_;
|
||||
for (size_t i = 0; i < allLvs.size(); i++) {
|
||||
@ -281,7 +281,7 @@ Clause::removeLiteral (size_t litIdx)
|
||||
{
|
||||
LogVarSet lvsToRemove = literals_[litIdx].logVarSet()
|
||||
- getLogVarSetExcluding (litIdx);
|
||||
ipgLogVars_ -= lvsToRemove;
|
||||
ipgLvs_ -= lvsToRemove;
|
||||
posCountedLvs_ -= lvsToRemove;
|
||||
negCountedLvs_ -= lvsToRemove;
|
||||
constr_.remove (lvsToRemove);
|
||||
@ -322,7 +322,7 @@ std::ostream& operator<< (ostream &os, const Clause& clause)
|
||||
{
|
||||
for (unsigned i = 0; i < clause.literals_.size(); i++) {
|
||||
if (i != 0) os << " v " ;
|
||||
os << clause.literals_[i].toString (clause.ipgLogVars_,
|
||||
os << clause.literals_[i].toString (clause.ipgLvs_,
|
||||
clause.posCountedLvs_, clause.negCountedLvs_);
|
||||
}
|
||||
if (clause.constr_.empty() == false) {
|
||||
|
@ -81,9 +81,9 @@ class Clause
|
||||
|
||||
bool isUnit (void) const { return literals_.size() == 1; }
|
||||
|
||||
LogVarSet ipgLogVars (void) const { return ipgLogVars_; }
|
||||
LogVarSet ipgLogVars (void) const { return ipgLvs_; }
|
||||
|
||||
void addIpgLogVar (LogVar X) { ipgLogVars_.insert (X); }
|
||||
void addIpgLogVar (LogVar X) { ipgLvs_.insert (X); }
|
||||
|
||||
void addPosCountedLogVar (LogVar X) { posCountedLvs_.insert (X); }
|
||||
|
||||
@ -137,7 +137,7 @@ class Clause
|
||||
LogVarSet getLogVarSetExcluding (size_t idx) const;
|
||||
|
||||
Literals literals_;
|
||||
LogVarSet ipgLogVars_;
|
||||
LogVarSet ipgLvs_;
|
||||
LogVarSet posCountedLvs_;
|
||||
LogVarSet negCountedLvs_;
|
||||
ConstraintTree constr_;
|
||||
|
@ -13,7 +13,7 @@ bool logDomain = false;
|
||||
|
||||
unsigned verbosity = 0;
|
||||
|
||||
LiftedSolver liftedSolver = LiftedSolver::FOVE;
|
||||
LiftedSolver liftedSolver = LiftedSolver::LVE;
|
||||
|
||||
GroundSolver groundSolver = GroundSolver::VE;
|
||||
|
||||
@ -210,10 +210,12 @@ setHorusFlag (string key, string value)
|
||||
ss << value;
|
||||
ss >> Globals::verbosity;
|
||||
} else if (key == "lifted_solver") {
|
||||
if ( value == "fove") {
|
||||
Globals::liftedSolver = LiftedSolver::FOVE;
|
||||
if ( value == "lve") {
|
||||
Globals::liftedSolver = LiftedSolver::LVE;
|
||||
} else if (value == "lbp") {
|
||||
Globals::liftedSolver = LiftedSolver::LBP;
|
||||
} else if (value == "lkc") {
|
||||
Globals::liftedSolver = LiftedSolver::LKC;
|
||||
} else {
|
||||
cerr << "warning: invalid value `" << value << "' " ;
|
||||
cerr << "for `" << key << "'" << endl;
|
||||
|
Reference in New Issue
Block a user