Move MsgSchedule enum to inside class BeliefProp.
Move also SPNodeInfo to inside BeliefProp. Improve also some using of enums.
This commit is contained in:
parent
ce8152d7a0
commit
6b0e125e3b
@ -61,9 +61,11 @@ BpLink::toString (void) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
double BeliefProp::accuracy_ = 0.0001;
|
double BeliefProp::accuracy_ = 0.0001;
|
||||||
unsigned BeliefProp::maxIter_ = 1000;
|
unsigned BeliefProp::maxIter_ = 1000;
|
||||||
MsgSchedule BeliefProp::schedule_ = MsgSchedule::seqFixedSch;
|
|
||||||
|
BeliefProp::MsgSchedule BeliefProp::schedule_ =
|
||||||
|
MsgSchedule::seqFixedSch;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -112,9 +114,9 @@ BeliefProp::printSolverFlags (void) const
|
|||||||
case MsgSchedule::parallelSch: ss << "parallel"; break;
|
case MsgSchedule::parallelSch: ss << "parallel"; break;
|
||||||
case MsgSchedule::maxResidualSch: ss << "max_residual"; break;
|
case MsgSchedule::maxResidualSch: ss << "max_residual"; break;
|
||||||
}
|
}
|
||||||
ss << ",bp_max_iter=" << Util::toString (maxIter_);
|
ss << ",bp_max_iter=" << Util::toString (maxIter_);
|
||||||
ss << ",bp_accuracy=" << Util::toString (accuracy_);
|
ss << ",bp_accuracy=" << Util::toString (accuracy_);
|
||||||
ss << ",log_domain=" << Util::toString (Globals::logDomain);
|
ss << ",log_domain=" << Util::toString (Globals::logDomain);
|
||||||
ss << "]" ;
|
ss << "]" ;
|
||||||
std::cout << ss.str() << std::endl;
|
std::cout << ss.str() << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,6 @@
|
|||||||
|
|
||||||
namespace Horus {
|
namespace Horus {
|
||||||
|
|
||||||
enum MsgSchedule {
|
|
||||||
seqFixedSch,
|
|
||||||
seqRandomSch,
|
|
||||||
parallelSch,
|
|
||||||
maxResidualSch
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class BpLink {
|
class BpLink {
|
||||||
public:
|
public:
|
||||||
@ -59,23 +52,18 @@ class BpLink {
|
|||||||
typedef std::vector<BpLink*> BpLinks;
|
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 {
|
class BeliefProp : public GroundSolver {
|
||||||
|
private:
|
||||||
|
class SPNodeInfo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum MsgSchedule {
|
||||||
|
seqFixedSch,
|
||||||
|
seqRandomSch,
|
||||||
|
parallelSch,
|
||||||
|
maxResidualSch
|
||||||
|
};
|
||||||
|
|
||||||
BeliefProp (const FactorGraph&);
|
BeliefProp (const FactorGraph&);
|
||||||
|
|
||||||
virtual ~BeliefProp (void);
|
virtual ~BeliefProp (void);
|
||||||
@ -146,6 +134,20 @@ class BeliefProp : public GroundSolver {
|
|||||||
static MsgSchedule schedule_;
|
static MsgSchedule schedule_;
|
||||||
|
|
||||||
private:
|
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);
|
void initializeSolver (void);
|
||||||
|
|
||||||
bool converged (void);
|
bool converged (void);
|
||||||
@ -157,7 +159,7 @@ class BeliefProp : public GroundSolver {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline SPNodeInfo*
|
inline BeliefProp::SPNodeInfo*
|
||||||
BeliefProp::ninf (const VarNode* var) const
|
BeliefProp::ninf (const VarNode* var) const
|
||||||
{
|
{
|
||||||
return varsI_[var->getIndex()];
|
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
|
BeliefProp::ninf (const FacNode* fac) const
|
||||||
{
|
{
|
||||||
return facsI_[fac->getIndex()];
|
return facsI_[fac->getIndex()];
|
||||||
|
@ -92,6 +92,7 @@ CountingBp::printSolverFlags (void) const
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "counting bp [" ;
|
ss << "counting bp [" ;
|
||||||
ss << "bp_msg_schedule=" ;
|
ss << "bp_msg_schedule=" ;
|
||||||
|
typedef WeightedBp::MsgSchedule MsgSchedule;
|
||||||
switch (WeightedBp::msgSchedule()) {
|
switch (WeightedBp::msgSchedule()) {
|
||||||
case MsgSchedule::seqFixedSch: ss << "seq_fixed"; break;
|
case MsgSchedule::seqFixedSch: ss << "seq_fixed"; break;
|
||||||
case MsgSchedule::seqRandomSch: ss << "seq_random"; break;
|
case MsgSchedule::seqRandomSch: ss << "seq_random"; break;
|
||||||
|
@ -69,6 +69,7 @@ LiftedBp::printSolverFlags (void) const
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "lifted bp [" ;
|
ss << "lifted bp [" ;
|
||||||
ss << "bp_msg_schedule=" ;
|
ss << "bp_msg_schedule=" ;
|
||||||
|
typedef WeightedBp::MsgSchedule MsgSchedule;
|
||||||
switch (WeightedBp::msgSchedule()) {
|
switch (WeightedBp::msgSchedule()) {
|
||||||
case MsgSchedule::seqFixedSch: ss << "seq_fixed"; break;
|
case MsgSchedule::seqFixedSch: ss << "seq_fixed"; break;
|
||||||
case MsgSchedule::seqRandomSch: ss << "seq_random"; break;
|
case MsgSchedule::seqRandomSch: ss << "seq_random"; break;
|
||||||
|
@ -225,20 +225,22 @@ setHorusFlag (std::string option, std::string value)
|
|||||||
else returnVal = invalidValue (option, value);
|
else returnVal = invalidValue (option, value);
|
||||||
|
|
||||||
} else if (option == "hve_elim_heuristic") {
|
} else if (option == "hve_elim_heuristic") {
|
||||||
|
typedef ElimGraph::ElimHeuristic ElimHeuristic;
|
||||||
if (value == "sequential")
|
if (value == "sequential")
|
||||||
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::sequentialEh);
|
ElimGraph::setElimHeuristic (ElimHeuristic::sequentialEh);
|
||||||
else if (value == "min_neighbors")
|
else if (value == "min_neighbors")
|
||||||
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::minNeighborsEh);
|
ElimGraph::setElimHeuristic (ElimHeuristic::minNeighborsEh);
|
||||||
else if (value == "min_weight")
|
else if (value == "min_weight")
|
||||||
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::minWeightEh);
|
ElimGraph::setElimHeuristic (ElimHeuristic::minWeightEh);
|
||||||
else if (value == "min_fill")
|
else if (value == "min_fill")
|
||||||
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::minFillEh);
|
ElimGraph::setElimHeuristic (ElimHeuristic::minFillEh);
|
||||||
else if (value == "weighted_min_fill")
|
else if (value == "weighted_min_fill")
|
||||||
ElimGraph::setElimHeuristic (ElimGraph::ElimHeuristic::weightedMinFillEh);
|
ElimGraph::setElimHeuristic (ElimHeuristic::weightedMinFillEh);
|
||||||
else
|
else
|
||||||
returnVal = invalidValue (option, value);
|
returnVal = invalidValue (option, value);
|
||||||
|
|
||||||
} else if (option == "bp_msg_schedule") {
|
} else if (option == "bp_msg_schedule") {
|
||||||
|
typedef BeliefProp::MsgSchedule MsgSchedule;
|
||||||
if (value == "seq_fixed")
|
if (value == "seq_fixed")
|
||||||
BeliefProp::setMsgSchedule (MsgSchedule::seqFixedSch);
|
BeliefProp::setMsgSchedule (MsgSchedule::seqFixedSch);
|
||||||
else if (value == "seq_random")
|
else if (value == "seq_random")
|
||||||
|
@ -42,13 +42,13 @@ VarElim::printSolverFlags (void) const
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "variable elimination [" ;
|
ss << "variable elimination [" ;
|
||||||
ss << "elim_heuristic=" ;
|
ss << "elim_heuristic=" ;
|
||||||
typedef ElimGraph::ElimHeuristic EGEH;
|
typedef ElimGraph::ElimHeuristic ElimHeuristic;
|
||||||
switch (ElimGraph::elimHeuristic()) {
|
switch (ElimGraph::elimHeuristic()) {
|
||||||
case EGEH::sequentialEh: ss << "sequential"; break;
|
case ElimHeuristic::sequentialEh: ss << "sequential"; break;
|
||||||
case EGEH::minNeighborsEh: ss << "min_neighbors"; break;
|
case ElimHeuristic::minNeighborsEh: ss << "min_neighbors"; break;
|
||||||
case EGEH::minWeightEh: ss << "min_weight"; break;
|
case ElimHeuristic::minWeightEh: ss << "min_weight"; break;
|
||||||
case EGEH::minFillEh: ss << "min_fill"; break;
|
case ElimHeuristic::minFillEh: ss << "min_fill"; break;
|
||||||
case EGEH::weightedMinFillEh: ss << "weighted_min_fill"; break;
|
case ElimHeuristic::weightedMinFillEh: ss << "weighted_min_fill"; break;
|
||||||
}
|
}
|
||||||
ss << ",log_domain=" << Util::toString (Globals::logDomain);
|
ss << ",log_domain=" << Util::toString (Globals::logDomain);
|
||||||
ss << "]" ;
|
ss << "]" ;
|
||||||
|
Reference in New Issue
Block a user