16 template<
class V,
class I>
23 if(
visitor(inference)==0) {
return true;}
64 order_iterations = 25;
74 DAOOPT(
const GraphicalModelType& gm,
const Parameter& para = Parameter());
78 std::string
name()
const;
81 template<
class VISITOR>
85 typename GM::ValueType
bound()
const;
86 typename GM::ValueType
value()
const;
89 const GraphicalModelType&
gm_;
96 : gm_(gm), parameter_(para) {
104 throw RuntimeError(
"Error: Specifying a subproblem requires reading a fixed ordering from file.");
108 throw RuntimeError(
"Error: subproblem ordering has to be 0(width-inc), 1(width-dec), 2(heur-inc) or 3(heur-dec)");
118 size_t len, start, pos1, pos2;
120 pos1 = fname.find_last_of(
"\\");
122 pos1 = fname.find_last_of(
"/");
124 pos2 = fname.find_last_of(
".");
125 if (pos1 == string::npos) { len = pos2; start = 0; }
126 else { len = (pos2-pos1-1); start = pos1+1; }
127 parameter_.problemName = fname.substr(start, len);
136 main_.setOptions(
new daoopt::ProgramOptions(static_cast<daoopt::ProgramOptions>(
parameter_)));
138 if(!
main_.outputInfo()) {
143 daoopt::Problem* problem =
new daoopt::Problem();
144 if(!problem->convertOPENGM(
gm_)) {
145 throw RuntimeError(
"Error converting openGM to DAOOPT problem.");
147 main_.setProblem(problem);
149 if(!
main_.loadProblem()) {
172 EmptyVisitorType visitor;
173 return this->infer(visitor);
177 template<
class VISITOR>
180 visitor.begin(*
this);
183 if(!main_.runSLS()) {
187 if(!main_.findOrLoadOrdering()) {
188 throw RuntimeError(
"Error running DAOOPT find/load ordering.");
191 if(!main_.initDataStructs()) {
192 throw RuntimeError(
"Error initializing DAOOPT data structs.");
195 if(!main_.compileHeuristic()) {
196 throw RuntimeError(
"Error compiling DAOOPT heuristic.");
199 if(!main_.runLDS()) {
203 if(!main_.finishPreproc()) {
204 throw RuntimeError(
"Error finishing DAOOPT preprocessing.");
208 if(!main_.runSearch(v)) {
212 if(!main_.outputStats()) {
222 const daoopt::Problem& problem = main_.getProblem();
224 const std::vector<daoopt::val_t>& assignment = problem.getSolutionAssg();
225 if(assignment.size() == gm_.numberOfVariables()){
226 arg.assign(assignment.begin(), assignment.end()-1);
229 std::cout <<
"Warning: DAOOPT return labeling of wrong size!"<<std::endl;
230 arg.resize(gm_.numberOfVariables(),0);
237 return AccumulationType::ineutral<ValueType>();
246 const daoopt::Problem& problem = main_.getProblem();
249 return std::numeric_limits<ValueType>::infinity();
const GraphicalModelType & gm_
OpengmVisitor(V &v, I &i)
GM::ValueType bound() const
return a bound on the solution
DAOOPT(const GraphicalModelType &gm, const Parameter ¶=Parameter())
opengm::Minimizer AccumulationType
visitors::VerboseVisitor< DAOOPT< GM > > VerboseVisitorType
const GraphicalModelType & graphicalModel() const
GM::ValueType value() const
return the solution (value)
GraphicalModelType::ValueType ValueType
Inference algorithm interface.
DAOOPT DAOOPT inference algorithm class.
visitors::EmptyVisitor< DAOOPT< GM > > EmptyVisitorType
Minimization as a unary accumulation.
InferenceTermination arg(std::vector< LabelType > &, const size_t &=1) const
InferenceTermination infer()
visitors::TimingVisitor< DAOOPT< GM > > TimingVisitorType
Parameter inherits from daoopt ProgramOptions.