Move MsgSchedule enum to inside class BeliefProp.

Move also SPNodeInfo to inside BeliefProp. Improve also some using of enums.
This commit is contained in:
Tiago Gomes 2013-02-20 23:34:03 +00:00
parent ce8152d7a0
commit 6b0e125e3b
6 changed files with 49 additions and 41 deletions

View File

@ -61,9 +61,11 @@ BpLink::toString (void) const
double BeliefProp::accuracy_ = 0.0001;
unsigned BeliefProp::maxIter_ = 1000;
MsgSchedule BeliefProp::schedule_ = MsgSchedule::seqFixedSch;
double BeliefProp::accuracy_ = 0.0001;
unsigned BeliefProp::maxIter_ = 1000;
BeliefProp::MsgSchedule BeliefProp::schedule_ =
MsgSchedule::seqFixedSch;
@ -112,9 +114,9 @@ BeliefProp::printSolverFlags (void) const
case MsgSchedule::parallelSch: ss << "parallel"; break;
case MsgSchedule::maxResidualSch: ss << "max_residual"; break;
}
ss << ",bp_max_iter=" << Util::toString (maxIter_);
ss << ",bp_accuracy=" << Util::toString (accuracy_);
ss << ",log_domain=" << Util::toString (Globals::logDomain);
ss << ",bp_max_iter=" << Util::toString (maxIter_);
ss << ",bp_accuracy=" << Util::toString (accuracy_);
ss << ",log_domain=" << Util::toString (Globals::logDomain);
ss << "]" ;
std::cout << ss.str() << std::endl;
}

View File

@ -11,13 +11,6 @@
namespace Horus {
enum MsgSchedule {
seqFixedSch,
seqRandomSch,
parallelSch,
maxResidualSch
};
class BpLink {
public:
@ -59,23 +52,18 @@ class BpLink {
typedef std::vector<BpLink*> BpLinks;
class SPNodeInfo {
public:
SPNodeInfo (void) { }
void addBpLink (BpLink* link) { links_.push_back (link); }
const BpLinks& getLinks (void) { return links_; }
private:
BpLinks links_;
DISALLOW_COPY_AND_ASSIGN (SPNodeInfo);
};
class BeliefProp : public GroundSolver {
private:
class SPNodeInfo;
public:
enum MsgSchedule {
seqFixedSch,
seqRandomSch,
parallelSch,
maxResidualSch
};
BeliefProp (const FactorGraph&);
virtual ~BeliefProp (void);
@ -146,6 +134,20 @@ class BeliefProp : public GroundSolver {
static MsgSchedule schedule_;
private:
class SPNodeInfo {
public:
SPNodeInfo (void) { }
void addBpLink (BpLink* link) { links_.push_back (link); }
const BpLinks& getLinks (void) { return links_; }
private:
BpLinks links_;
DISALLOW_COPY_AND_ASSIGN (SPNodeInfo);
};
void initializeSolver (void);
bool converged (void);
@ -157,7 +159,7 @@ class BeliefProp : public GroundSolver {
inline SPNodeInfo*
inline BeliefProp::SPNodeInfo*
BeliefProp::ninf (const VarNode* var) const
{
return varsI_[var->getIndex()];
@ -165,7 +167,7 @@ BeliefProp::ninf (const VarNode* var) const
inline SPNodeInfo*
inline BeliefProp::SPNodeInfo*
BeliefProp::ninf (const FacNode* fac) const
{
return facsI_[fac->getIndex()];

View File

@ -92,6 +92,7 @@ CountingBp::printSolverFlags (void) const
std::stringstream ss;
ss << "counting bp [" ;
ss << "bp_msg_schedule=" ;
typedef WeightedBp::MsgSchedule MsgSchedule;
switch (WeightedBp::msgSchedule()) {
case MsgSchedule::seqFixedSch: ss << "seq_fixed"; break;
case MsgSchedule::seqRandomSch: ss << "seq_random"; break;

View File

@ -69,6 +69,7 @@ LiftedBp::printSolverFlags (void) const
std::stringstream ss;
ss << "lifted bp [" ;
ss << "bp_msg_schedule=" ;
typedef WeightedBp::MsgSchedule MsgSchedule;
switch (WeightedBp::msgSchedule()) {
case MsgSchedule::seqFixedSch: ss << "seq_fixed"; break;
case MsgSchedule::seqRandomSch: ss << "seq_random"; break;

View File

@ -225,20 +225,22 @@ setHorusFlag (std::string option, std::string value)
else returnVal = invalidValue (option, value);
} else if (option == "hve_elim_heuristic") {
typedef ElimGraph::ElimHeuristic ElimHeuristic;
if (value == "sequential")
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::sequentialEh);
ElimGraph::setElimHeuristic (ElimHeuristic::sequentialEh);
else if (value == "min_neighbors")
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::minNeighborsEh);
ElimGraph::setElimHeuristic (ElimHeuristic::minNeighborsEh);
else if (value == "min_weight")
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::minWeightEh);
ElimGraph::setElimHeuristic (ElimHeuristic::minWeightEh);
else if (value == "min_fill")
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::minFillEh);
ElimGraph::setElimHeuristic (ElimHeuristic::minFillEh);
else if (value == "weighted_min_fill")
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::weightedMinFillEh);
ElimGraph::setElimHeuristic (ElimHeuristic::weightedMinFillEh);
else
returnVal = invalidValue (option, value);
} else if (option == "bp_msg_schedule") {
typedef BeliefProp::MsgSchedule MsgSchedule;
if (value == "seq_fixed")
BeliefProp::setMsgSchedule (MsgSchedule::seqFixedSch);
else if (value == "seq_random")

View File

@ -42,13 +42,13 @@ VarElim::printSolverFlags (void) const
std::stringstream ss;
ss << "variable elimination [" ;
ss << "elim_heuristic=" ;
typedef ElimGraph::ElimHeuristic EGEH;
typedef ElimGraph::ElimHeuristic ElimHeuristic;
switch (ElimGraph::elimHeuristic()) {
case EGEH::sequentialEh: ss << "sequential"; break;
case EGEH::minNeighborsEh: ss << "min_neighbors"; break;
case EGEH::minWeightEh: ss << "min_weight"; break;
case EGEH::minFillEh: ss << "min_fill"; break;
case EGEH::weightedMinFillEh: ss << "weighted_min_fill"; break;
case ElimHeuristic::sequentialEh: ss << "sequential"; break;
case ElimHeuristic::minNeighborsEh: ss << "min_neighbors"; break;
case ElimHeuristic::minWeightEh: ss << "min_weight"; break;
case ElimHeuristic::minFillEh: ss << "min_fill"; break;
case ElimHeuristic::weightedMinFillEh: ss << "weighted_min_fill"; break;
}
ss << ",log_domain=" << Util::toString (Globals::logDomain);
ss << "]" ;