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