16 template<
class V,
class I>
23 if(
visitor(inference)==0) {
return true;}
60 template<
class _GM,
class _ACC>
75 order_iterations = 25;
85 subprobOrder = p.subprobOrder;
88 cbound_worker = p.cbound_worker;
89 rotateLimit = p.rotateLimit;
90 order_iterations = p.order_iterations;
91 order_timelimit = p.order_timelimit;
93 sampleDepth = p.sampleDepth;
94 sampleRepeat = p.sampleRepeat;
95 aobbLookahead = p.aobbLookahead;
104 std::string name()
const;
105 const GraphicalModelType& graphicalModel()
const;
107 template<
class VISITOR>
111 typename GM::ValueType bound()
const;
112 typename GM::ValueType value()
const;
115 const GraphicalModelType&
gm_;
122 : gm_(gm), parameter_(para) {
130 throw RuntimeError(
"Error: Specifying a subproblem requires reading a fixed ordering from file.");
134 throw RuntimeError(
"Error: subproblem ordering has to be 0(width-inc), 1(width-dec), 2(heur-inc) or 3(heur-dec)");
144 size_t len, start, pos1, pos2;
146 pos1 = fname.find_last_of(
"\\");
148 pos1 = fname.find_last_of(
"/");
150 pos2 = fname.find_last_of(
".");
151 if (pos1 == string::npos) { len = pos2; start = 0; }
152 else { len = (pos2-pos1-1); start = pos1+1; }
153 parameter_.problemName = fname.substr(start, len);
162 main_.setOptions(
new daoopt::ProgramOptions(static_cast<daoopt::ProgramOptions>(
parameter_)));
164 if(!
main_.outputInfo()) {
169 daoopt::Problem* problem =
new daoopt::Problem();
170 if(!problem->convertOPENGM(
gm_)) {
171 throw RuntimeError(
"Error converting openGM to DAOOPT problem.");
173 main_.setProblem(problem);
175 if(!
main_.loadProblem()) {
199 return this->
infer(visitor);
203 template<
class VISITOR>
206 visitor.begin(*
this);
209 if(!
main_.runSLS()) {
213 if(!
main_.findOrLoadOrdering()) {
214 throw RuntimeError(
"Error running DAOOPT find/load ordering.");
217 if(!
main_.initDataStructs()) {
218 throw RuntimeError(
"Error initializing DAOOPT data structs.");
221 if(!
main_.compileHeuristic()) {
222 throw RuntimeError(
"Error compiling DAOOPT heuristic.");
225 if(!
main_.runLDS()) {
229 if(!
main_.finishPreproc()) {
230 throw RuntimeError(
"Error finishing DAOOPT preprocessing.");
234 if(!
main_.runSearch(v)) {
238 if(!
main_.outputStats()) {
248 const daoopt::Problem& problem =
main_.getProblem();
250 const std::vector<daoopt::val_t>& assignment = problem.getSolutionAssg();
251 if(assignment.size() ==
gm_.numberOfVariables()){
252 arg.assign(assignment.begin(), assignment.end()-1);
255 std::cout <<
"Warning: DAOOPT return labeling of wrong size!"<<std::endl;
256 arg.resize(
gm_.numberOfVariables(),0);
263 return AccumulationType::ineutral<ValueType>();
272 const daoopt::Problem& problem =
main_.getProblem();
275 return std::numeric_limits<ValueType>::infinity();
const GraphicalModelType & gm_
void infer(const typename INF::GraphicalModelType &gm, const typename INF::Parameter ¶m, std::vector< typename INF::LabelType > &conf)
OpengmVisitor(V &v, I &i)
opengm::Minimizer AccumulationType
GM::ValueType bound() const
return a bound on the solution
InferenceTermination arg(std::vector< LabelType > &, const size_t &=1) const
visitors::VerboseVisitor< DAOOPT< GM > > VerboseVisitorType
GM::ValueType value() const
return the solution (value)
GraphicalModelType::ValueType ValueType
Inference algorithm interface.
const GraphicalModelType & graphicalModel() const
DAOOPT DAOOPT inference algorithm class.
visitors::EmptyVisitor< DAOOPT< GM > > EmptyVisitorType
Minimization as a unary accumulation.
InferenceTermination infer()
visitors::TimingVisitor< DAOOPT< GM > > TimingVisitorType
Parameter inherits from daoopt ProgramOptions.