This commit is contained in:
Tiago Gomes 2013-03-09 17:14:00 +00:00
parent a300b27764
commit 2da7249247
8 changed files with 38 additions and 23 deletions

View File

@ -23,6 +23,7 @@ BeliefProp::MsgSchedule BeliefProp::schedule_ =
BeliefProp::BeliefProp (const FactorGraph& fg)
: GroundSolver (fg), nIters_(0), runned_(false)
{
}
@ -294,7 +295,8 @@ BeliefProp::runSolver()
std::cout << "Belief propagation converged in " ;
std::cout << nIters_ << " iterations" << std::endl;
} else {
std::cout << "The maximum number of iterations was hit, terminating..." ;
std::cout << "The maximum number of iterations was hit," ;
std::cout << " terminating..." ;
std::cout << std::endl;
}
std::cout << std::endl;

View File

@ -92,10 +92,9 @@ FactorGraph::readFromUaiFormat (const char* fileName)
for (unsigned j = 0; j < nrArgs; j++) {
is >> vid;
if (vid >= ranges.size()) {
std::cerr << "Error: invalid variable identifier `" << vid << "'. " ;
std::cerr << "Identifiers must be between 0 and " ;
std::cerr << ranges.size() - 1 ;
std::cerr << "." << std::endl;
std::cerr << "Error: invalid variable identifier `" << vid << "'" ;
std::cerr << ". Identifiers must be between 0 and " ;
std::cerr << ranges.size() - 1 << "." << std::endl;
exit (EXIT_FAILURE);
}
allVarIds.back().push_back (vid);
@ -108,8 +107,8 @@ FactorGraph::readFromUaiFormat (const char* fileName)
ignoreLines (is);
is >> nrParams;
if (nrParams != Util::sizeExpected (allRanges[i])) {
std::cerr << "Error: invalid number of parameters for factor nº " << i ;
std::cerr << ", " << Util::sizeExpected (allRanges[i]);
std::cerr << "Error: invalid number of parameters for factor nº " ;
std::cerr << i << ", " << Util::sizeExpected (allRanges[i]);
std::cerr << " expected, " << nrParams << " given." << std::endl;
exit (EXIT_FAILURE);
}
@ -165,8 +164,9 @@ FactorGraph::readFromLibDaiFormat (const char* fileName)
is >> ranges[j];
VarNode* var = getVarNode (vids[j]);
if (var && ranges[j] != var->range()) {
std::cerr << "Error: variable `" << vids[j] << "' appears in two or " ;
std::cerr << "more factors with a different range." << std::endl;
std::cerr << "Error: variable `" << vids[j] << "' appears" ;
std::cerr << " in two or more factors with a different range." ;
std::cerr << std::endl;
}
}
// read parameters

View File

@ -35,7 +35,7 @@ typedef unsigned long long ullong;
enum class LiftedSolverType {
lveSolver, // generalized counting first-order variable elimination (GC-FOVE)
lveSolver, // generalized counting first-order variable elimination
lbpSolver, // lifted first-order belief propagation
lkcSolver // lifted first-order knowledge compilation
};

View File

@ -404,7 +404,8 @@ readParfactor (YAP_Term pfTerm)
} else {
LogVars logVars;
YAP_Functor yapFunctor = YAP_FunctorOfTerm (formulaTerm);
std::string name ((char*) YAP_AtomName (YAP_NameOfFunctor (yapFunctor)));
std::string name ((char*) YAP_AtomName (
YAP_NameOfFunctor (yapFunctor)));
Symbol functor = LiftedUtils::getSymbol (name);
unsigned arity = (unsigned) YAP_ArityOfFunctor (yapFunctor);
for (unsigned i = 1; i <= arity; i++) {

View File

@ -62,7 +62,8 @@ class AndNode : public CircuitNode {
AndNode() : CircuitNode(), leftBranch_(0), rightBranch_(0) { }
AndNode (CircuitNode* leftBranch, CircuitNode* rightBranch)
: CircuitNode(), leftBranch_(leftBranch), rightBranch_(rightBranch) { }
: CircuitNode(), leftBranch_(leftBranch),
rightBranch_(rightBranch) { }
~AndNode();
@ -235,7 +236,8 @@ class LiftedCircuit {
bool shatterCountedLogVarsAux (Clauses& clauses);
bool shatterCountedLogVarsAux (Clauses& clauses, size_t idx1, size_t idx2);
bool shatterCountedLogVarsAux (Clauses& clauses,
size_t idx1, size_t idx2);
bool independentClause (Clause& clause, Clauses& otherClauses) const;

View File

@ -556,7 +556,8 @@ LiftedWCNF::addIndicatorClauses (const ParfactorList& pfList)
Clause* clause = new Clause (tempConstr);
std::vector<LiteralId> lids;
for (size_t j = 0; j < formulas[i].range(); j++) {
clause->addLiteral (Literal (freeLiteralId_, formulas[i].logVars()));
clause->addLiteral (Literal (
freeLiteralId_, formulas[i].logVars()));
lids.push_back (freeLiteralId_);
freeLiteralId_ ++;
}

View File

@ -616,7 +616,8 @@ Parfactor::print (bool printParams) const
if (args_[0].group() != Util::maxUnsigned()) {
std::vector<std::string> groups;
for (size_t i = 0; i < args_.size(); i++) {
groups.push_back (std::string ("g") + Util::toString (args_[i].group()));
groups.push_back (std::string ("g")
+ Util::toString (args_[i].group()));
}
cout << "Groups: " << groups << endl;
}

View File

@ -203,16 +203,24 @@ setHorusFlag (std::string option, std::string value)
{
bool returnVal = true;
if (option == "lifted_solver") {
if (value == "lve") Globals::liftedSolver = LiftedSolverType::lveSolver;
else if (value == "lbp") Globals::liftedSolver = LiftedSolverType::lbpSolver;
else if (value == "lkc") Globals::liftedSolver = LiftedSolverType::lkcSolver;
else returnVal = invalidValue (option, value);
if (value == "lve")
Globals::liftedSolver = LiftedSolverType::lveSolver;
else if (value == "lbp")
Globals::liftedSolver = LiftedSolverType::lbpSolver;
else if (value == "lkc")
Globals::liftedSolver = LiftedSolverType::lkcSolver;
else
returnVal = invalidValue (option, value);
} else if (option == "ground_solver" || option == "solver") {
if (value == "hve") Globals::groundSolver = GroundSolverType::veSolver;
else if (value == "bp") Globals::groundSolver = GroundSolverType::bpSolver;
else if (value == "cbp") Globals::groundSolver = GroundSolverType::CbpSolver;
else returnVal = invalidValue (option, value);
if (value == "hve")
Globals::groundSolver = GroundSolverType::veSolver;
else if (value == "bp")
Globals::groundSolver = GroundSolverType::bpSolver;
else if (value == "cbp")
Globals::groundSolver = GroundSolverType::CbpSolver;
else
returnVal = invalidValue (option, value);
} else if (option == "verbosity") {
std::stringstream ss;