add a sequential elimination heuristic
This commit is contained in:
parent
0315cd51a3
commit
02395daed3
@ -139,12 +139,23 @@ ElimGraph::exportToGraphViz (
|
||||
|
||||
VarIds
|
||||
ElimGraph::getEliminationOrder (
|
||||
const vector<Factor*> factors,
|
||||
const Factors& factors,
|
||||
VarIds excludedVids)
|
||||
{
|
||||
if (elimHeuristic == ElimHeuristic::SEQUENTIAL) {
|
||||
VarIds allVids;
|
||||
Factors::const_iterator first = factors.begin();
|
||||
Factors::const_iterator end = factors.end();
|
||||
for (; first != end; ++first) {
|
||||
Util::addToVector (allVids, (*first)->arguments());
|
||||
}
|
||||
TinySet<VarId> elimOrder (allVids);
|
||||
for (size_t i = 0; i < excludedVids.size(); i++) {
|
||||
elimOrder.remove (excludedVids[i]);
|
||||
}
|
||||
return elimOrder.elements();
|
||||
}
|
||||
ElimGraph graph (factors);
|
||||
// graph.print();
|
||||
// graph.exportToGraphViz ("_egg.dot");
|
||||
return graph.getEliminatingOrder (excludedVids);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ using namespace std;
|
||||
|
||||
enum ElimHeuristic
|
||||
{
|
||||
SEQUENTIAL,
|
||||
MIN_NEIGHBORS,
|
||||
MIN_WEIGHT,
|
||||
MIN_FILL,
|
||||
@ -45,7 +46,7 @@ class EgNode : public Var
|
||||
class ElimGraph
|
||||
{
|
||||
public:
|
||||
ElimGraph (const vector<Factor*>&); // TODO
|
||||
ElimGraph (const Factors&);
|
||||
|
||||
~ElimGraph (void);
|
||||
|
||||
@ -56,7 +57,7 @@ class ElimGraph
|
||||
void exportToGraphViz (const char*, bool = true,
|
||||
const VarIds& = VarIds()) const;
|
||||
|
||||
static VarIds getEliminationOrder (const vector<Factor*>, VarIds);
|
||||
static VarIds getEliminationOrder (const Factors&, VarIds);
|
||||
|
||||
static ElimHeuristic elimHeuristic;
|
||||
|
||||
|
@ -219,7 +219,9 @@ setHorusFlag (string key, string value)
|
||||
returnVal = false;
|
||||
}
|
||||
} else if (key == "elim_heuristic") {
|
||||
if ( value == "min_neighbors") {
|
||||
if ( value == "sequential") {
|
||||
ElimGraph::elimHeuristic = ElimHeuristic::SEQUENTIAL;
|
||||
} else if (value == "min_neighbors") {
|
||||
ElimGraph::elimHeuristic = ElimHeuristic::MIN_NEIGHBORS;
|
||||
} else if (value == "min_weight") {
|
||||
ElimGraph::elimHeuristic = ElimHeuristic::MIN_WEIGHT;
|
||||
|
@ -48,6 +48,7 @@ VarElimSolver::printSolverFlags (void) const
|
||||
ss << "elim_heuristic=" ;
|
||||
ElimHeuristic eh = ElimGraph::elimHeuristic;
|
||||
switch (eh) {
|
||||
case SEQUENTIAL: ss << "sequential"; break;
|
||||
case MIN_NEIGHBORS: ss << "min_neighbors"; break;
|
||||
case MIN_WEIGHT: ss << "min_weight"; break;
|
||||
case MIN_FILL: ss << "min_fill"; break;
|
||||
|
Reference in New Issue
Block a user