Trivial
This commit is contained in:
parent
a300b27764
commit
2da7249247
@ -23,6 +23,7 @@ BeliefProp::MsgSchedule BeliefProp::schedule_ =
|
|||||||
BeliefProp::BeliefProp (const FactorGraph& fg)
|
BeliefProp::BeliefProp (const FactorGraph& fg)
|
||||||
: GroundSolver (fg), nIters_(0), runned_(false)
|
: GroundSolver (fg), nIters_(0), runned_(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -294,7 +295,8 @@ BeliefProp::runSolver()
|
|||||||
std::cout << "Belief propagation converged in " ;
|
std::cout << "Belief propagation converged in " ;
|
||||||
std::cout << nIters_ << " iterations" << std::endl;
|
std::cout << nIters_ << " iterations" << std::endl;
|
||||||
} else {
|
} 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;
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
@ -92,10 +92,9 @@ FactorGraph::readFromUaiFormat (const char* fileName)
|
|||||||
for (unsigned j = 0; j < nrArgs; j++) {
|
for (unsigned j = 0; j < nrArgs; j++) {
|
||||||
is >> vid;
|
is >> vid;
|
||||||
if (vid >= ranges.size()) {
|
if (vid >= ranges.size()) {
|
||||||
std::cerr << "Error: invalid variable identifier `" << vid << "'. " ;
|
std::cerr << "Error: invalid variable identifier `" << vid << "'" ;
|
||||||
std::cerr << "Identifiers must be between 0 and " ;
|
std::cerr << ". Identifiers must be between 0 and " ;
|
||||||
std::cerr << ranges.size() - 1 ;
|
std::cerr << ranges.size() - 1 << "." << std::endl;
|
||||||
std::cerr << "." << std::endl;
|
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
allVarIds.back().push_back (vid);
|
allVarIds.back().push_back (vid);
|
||||||
@ -108,8 +107,8 @@ FactorGraph::readFromUaiFormat (const char* fileName)
|
|||||||
ignoreLines (is);
|
ignoreLines (is);
|
||||||
is >> nrParams;
|
is >> nrParams;
|
||||||
if (nrParams != Util::sizeExpected (allRanges[i])) {
|
if (nrParams != Util::sizeExpected (allRanges[i])) {
|
||||||
std::cerr << "Error: invalid number of parameters for factor nº " << i ;
|
std::cerr << "Error: invalid number of parameters for factor nº " ;
|
||||||
std::cerr << ", " << Util::sizeExpected (allRanges[i]);
|
std::cerr << i << ", " << Util::sizeExpected (allRanges[i]);
|
||||||
std::cerr << " expected, " << nrParams << " given." << std::endl;
|
std::cerr << " expected, " << nrParams << " given." << std::endl;
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -165,8 +164,9 @@ FactorGraph::readFromLibDaiFormat (const char* fileName)
|
|||||||
is >> ranges[j];
|
is >> ranges[j];
|
||||||
VarNode* var = getVarNode (vids[j]);
|
VarNode* var = getVarNode (vids[j]);
|
||||||
if (var && ranges[j] != var->range()) {
|
if (var && ranges[j] != var->range()) {
|
||||||
std::cerr << "Error: variable `" << vids[j] << "' appears in two or " ;
|
std::cerr << "Error: variable `" << vids[j] << "' appears" ;
|
||||||
std::cerr << "more factors with a different range." << std::endl;
|
std::cerr << " in two or more factors with a different range." ;
|
||||||
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// read parameters
|
// read parameters
|
||||||
|
@ -35,7 +35,7 @@ typedef unsigned long long ullong;
|
|||||||
|
|
||||||
|
|
||||||
enum class LiftedSolverType {
|
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
|
lbpSolver, // lifted first-order belief propagation
|
||||||
lkcSolver // lifted first-order knowledge compilation
|
lkcSolver // lifted first-order knowledge compilation
|
||||||
};
|
};
|
||||||
|
@ -404,7 +404,8 @@ readParfactor (YAP_Term pfTerm)
|
|||||||
} else {
|
} else {
|
||||||
LogVars logVars;
|
LogVars logVars;
|
||||||
YAP_Functor yapFunctor = YAP_FunctorOfTerm (formulaTerm);
|
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);
|
Symbol functor = LiftedUtils::getSymbol (name);
|
||||||
unsigned arity = (unsigned) YAP_ArityOfFunctor (yapFunctor);
|
unsigned arity = (unsigned) YAP_ArityOfFunctor (yapFunctor);
|
||||||
for (unsigned i = 1; i <= arity; i++) {
|
for (unsigned i = 1; i <= arity; i++) {
|
||||||
|
@ -62,7 +62,8 @@ class AndNode : public CircuitNode {
|
|||||||
AndNode() : CircuitNode(), leftBranch_(0), rightBranch_(0) { }
|
AndNode() : CircuitNode(), leftBranch_(0), rightBranch_(0) { }
|
||||||
|
|
||||||
AndNode (CircuitNode* leftBranch, CircuitNode* rightBranch)
|
AndNode (CircuitNode* leftBranch, CircuitNode* rightBranch)
|
||||||
: CircuitNode(), leftBranch_(leftBranch), rightBranch_(rightBranch) { }
|
: CircuitNode(), leftBranch_(leftBranch),
|
||||||
|
rightBranch_(rightBranch) { }
|
||||||
|
|
||||||
~AndNode();
|
~AndNode();
|
||||||
|
|
||||||
@ -235,7 +236,8 @@ class LiftedCircuit {
|
|||||||
|
|
||||||
bool shatterCountedLogVarsAux (Clauses& clauses);
|
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;
|
bool independentClause (Clause& clause, Clauses& otherClauses) const;
|
||||||
|
|
||||||
|
@ -556,7 +556,8 @@ LiftedWCNF::addIndicatorClauses (const ParfactorList& pfList)
|
|||||||
Clause* clause = new Clause (tempConstr);
|
Clause* clause = new Clause (tempConstr);
|
||||||
std::vector<LiteralId> lids;
|
std::vector<LiteralId> lids;
|
||||||
for (size_t j = 0; j < formulas[i].range(); j++) {
|
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_);
|
lids.push_back (freeLiteralId_);
|
||||||
freeLiteralId_ ++;
|
freeLiteralId_ ++;
|
||||||
}
|
}
|
||||||
|
@ -616,7 +616,8 @@ Parfactor::print (bool printParams) const
|
|||||||
if (args_[0].group() != Util::maxUnsigned()) {
|
if (args_[0].group() != Util::maxUnsigned()) {
|
||||||
std::vector<std::string> groups;
|
std::vector<std::string> groups;
|
||||||
for (size_t i = 0; i < args_.size(); i++) {
|
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;
|
cout << "Groups: " << groups << endl;
|
||||||
}
|
}
|
||||||
|
@ -203,16 +203,24 @@ setHorusFlag (std::string option, std::string value)
|
|||||||
{
|
{
|
||||||
bool returnVal = true;
|
bool returnVal = true;
|
||||||
if (option == "lifted_solver") {
|
if (option == "lifted_solver") {
|
||||||
if (value == "lve") Globals::liftedSolver = LiftedSolverType::lveSolver;
|
if (value == "lve")
|
||||||
else if (value == "lbp") Globals::liftedSolver = LiftedSolverType::lbpSolver;
|
Globals::liftedSolver = LiftedSolverType::lveSolver;
|
||||||
else if (value == "lkc") Globals::liftedSolver = LiftedSolverType::lkcSolver;
|
else if (value == "lbp")
|
||||||
else returnVal = invalidValue (option, value);
|
Globals::liftedSolver = LiftedSolverType::lbpSolver;
|
||||||
|
else if (value == "lkc")
|
||||||
|
Globals::liftedSolver = LiftedSolverType::lkcSolver;
|
||||||
|
else
|
||||||
|
returnVal = invalidValue (option, value);
|
||||||
|
|
||||||
} else if (option == "ground_solver" || option == "solver") {
|
} else if (option == "ground_solver" || option == "solver") {
|
||||||
if (value == "hve") Globals::groundSolver = GroundSolverType::veSolver;
|
if (value == "hve")
|
||||||
else if (value == "bp") Globals::groundSolver = GroundSolverType::bpSolver;
|
Globals::groundSolver = GroundSolverType::veSolver;
|
||||||
else if (value == "cbp") Globals::groundSolver = GroundSolverType::CbpSolver;
|
else if (value == "bp")
|
||||||
else returnVal = invalidValue (option, value);
|
Globals::groundSolver = GroundSolverType::bpSolver;
|
||||||
|
else if (value == "cbp")
|
||||||
|
Globals::groundSolver = GroundSolverType::CbpSolver;
|
||||||
|
else
|
||||||
|
returnVal = invalidValue (option, value);
|
||||||
|
|
||||||
} else if (option == "verbosity") {
|
} else if (option == "verbosity") {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
Reference in New Issue
Block a user