OpenGM  2.3.x
Discrete Graphical Model Library
loc.hxx
Go to the documentation of this file.
1 #pragma once
2 #ifndef OPENGM_LOC_HXX
3 #define OPENGM_LOC_HXX
4 
5 #include <vector>
6 #include <algorithm>
7 #include <string>
8 #include <iostream>
9 #include <iomanip>
10 #include <cstdlib>
11 #include <cmath>
12 #include <queue>
13 #include <deque>
14 #include "opengm/opengm.hxx"
19 
20 #include <cmath>
21 #include <algorithm>
22 
23 #include <sstream>
24 
26 
27 
28 // internal
34 
35 // external (autoinc)
37 // external (inclued by with)
38 #ifdef WITH_CPLEX
40 #endif
41 
42 namespace opengm {
52 template<class GM, class ACC>
53 class LOC : public Inference<GM, ACC> {
54 public:
55  typedef ACC AccumulationType;
56  typedef GM GraphicalModelType;
59 
63 
64 
66  typedef typename SubOptimizer::SubGmType SubGmType;
67 
68  // subsolvers
69 
77 
78  // external (autoincluded)
80  #ifdef WITH_CPLEX
81  typedef opengm::LPCplex<SubGmType,AccumulationType> LpCplexSubInf;
82  #endif
83 
84  template<class _GM>
85  struct RebindGm{
87  };
88 
89  template<class _GM,class _ACC>
92  };
93 
94 
95  class Parameter {
96  public:
103  Parameter
104  (
105  const std::string solver="ad3",
106  const double phi = 0.3,
107  const size_t maxBlockRadius = 50,
108  const size_t maxTreeRadius = 50,
109  const double pFastHeuristic = 0.9,
110  const size_t maxIterations = 100000,
111  const size_t stopAfterNBadIterations=10000,
112  const size_t maxBlockSize = 0,
113  const size_t maxTreeSize =0,
114  const int treeRuns =1
115  )
116  : solver_(solver),
117  phi_(phi),
118  maxBlockRadius_(maxBlockRadius),
119  maxTreeRadius_(maxTreeRadius),
120  pFastHeuristic_(pFastHeuristic),
121  maxIterations_(maxIterations),
122  stopAfterNBadIterations_(stopAfterNBadIterations),
123  maxBlockSize_(maxBlockSize),
124  treeRuns_(treeRuns)
125  {
126 
127  }
128 
129  template<class P>
130  Parameter
131  (
132  const P & p
133  )
134  : solver_(p.solver_),
135  phi_(p.phi_),
136  maxBlockRadius_(p.maxBlockRadius_),
137  maxTreeRadius_(p.maxTreeRadius_),
138  pFastHeuristic_(p.pFastHeuristic_),
139  maxIterations_(p.maxIterations_),
140  stopAfterNBadIterations_(p.stopAfterNBadIterations_),
141  maxBlockSize_(p.maxBlockSize_),
142  treeRuns_(p.treeRuns_)
143  {
144 
145  }
146 
147  // subsolver used for submodel ("ad3" or "astar" so far)
148  std::string solver_;
150  double phi_;
158 
159  // stop after n iterations without improvement
161 
162  // max allowed subgraph size (0 means any is allowed)
164  size_t maxTreeSize_;
166  };
167 
168  LOC(const GraphicalModelType&, const Parameter& param = Parameter());
169  std::string name() const;
170  const GraphicalModelType& graphicalModel() const;
172  void reset();
173  template<class VisitorType>
174  InferenceTermination infer(VisitorType&);
175  void setStartingPoint(typename std::vector<LabelType>::const_iterator);
176  InferenceTermination arg(std::vector<LabelType>&, const size_t = 1) const;
177  ValueType value() const;
178 
179 
180  template<class VI_ITER>
181  void setBorderDirty(VI_ITER begin,VI_ITER end){
182  const IndexType nVis=std::distance(begin,end);
183  OPENGM_CHECK_OP(subOptimizer_.submodelSize(),==,nVis,"");
184  for(IndexType v=0;v<nVis;++v){
185  const IndexType vi=begin[v];
186  const IndexType nNVar = viAdjacency_[vi].size();
187  for(IndexType vo=0;vo<nNVar;++vo){
188  const IndexType vio=viAdjacency_[vi][vo];
189  if( subOptimizer_.inSubmodel(vio)==false){
190  cleanRegion_[vio]=false;
191  }
192  }
193  }
194  }
195 
196  template<class VI_ITER>
197  void setInsideClean(VI_ITER begin,VI_ITER end){
198  const IndexType nVis=std::distance(begin,end);
199  OPENGM_CHECK_OP(subOptimizer_.submodelSize(),==,nVis,"");
200  for(IndexType v=0;v<nVis;++v){
201  const IndexType vi=begin[v];
202  cleanRegion_[vi]=true;
203  }
204  }
205 
206 
207  template<class VI_ITER>
208  bool hasDirtyInsideVariables(VI_ITER begin,VI_ITER end){
209  const IndexType nVis=std::distance(begin,end);
210  OPENGM_CHECK_OP(subOptimizer_.submodelSize(),==,nVis,"");
211 
212  for(IndexType v=0;v<nVis;++v){
213  const IndexType vi=begin[v];
214  if(cleanRegion_[vi]==false){
215  return true;
216  }
217  }
218  return false;
219  }
220 
221 
222 
223 private:
224  void getSubgraphVis(const size_t, const size_t, std::vector<size_t>&);
225  void getSubgraphTreeVis(const size_t, const size_t, std::vector<size_t>&);
226  void inline initializeProbabilities(std::vector<double>&,const size_t maxRadius);
227  const GraphicalModelType& gm_;
228  MovemakerType movemaker_;
229  Parameter param_;
230  std::vector< RandomAccessSet<IndexType> > viAdjacency_;
231  std::vector<bool> usedVi_;
232  std::vector<bool> checkedVi_;
233  std::vector<UInt64Type> distance_;
234 
235 
236  // submodel
237  SubOptimizer subOptimizer_;
238 
239  // clean region
240  std::vector<bool> cleanRegion_;
241 
242 
243 
244  bool optimizeSubmodel(std::vector<size_t> & subgraphVi,const bool);
245 };
246 
247 template<class GM, class ACC>
249 (
250  const GraphicalModelType& gm,
251  const Parameter& parameter
252 )
253 : gm_(gm),
254  movemaker_(gm),
255  param_(parameter),
256  viAdjacency_(gm.numberOfVariables()),
257  usedVi_(gm.numberOfVariables(), false),
258  checkedVi_(gm.numberOfVariables(), false),
259  distance_(gm.numberOfVariables()),
260  subOptimizer_(gm),
261  cleanRegion_(gm.numberOfVariables(),false)
262 {
263 
264  // compute variable adjacency
265  gm.variableAdjacencyList(viAdjacency_);
266  if(this->param_.maxIterations_==0)
267  param_.maxIterations_ = gm_.numberOfVariables() *
268  log(double(gm_.numberOfVariables()))*log(double(gm_.numberOfVariables()));
269 }
270 
271 template<class GM, class ACC>
272 void
274 {
275  movemaker_.reset();
276  std::fill(usedVi_.begin(),usedVi_.end(),false);
277  // compute variable adjacency is not nessesary
278  // since reset assumes that the structure of
279  // the graphical model has not changed
280  if(this->param_.maxIterations_==0)
281  param_.maxIterations_ = gm_.numberOfVariables() *
282  log(double(gm_.numberOfVariables()))*log(double(gm_.numberOfVariables()));
283 }
284 
285 template<class GM, class ACC>
286 inline void
288 (
289  typename std::vector<typename LOC<GM,ACC>::LabelType>::const_iterator begin
290 ) {
291  try{
292  movemaker_.initialize(begin);
293  }
294  catch(...) {
295  throw RuntimeError("unsuitable starting point");
296  }
297 }
298 
299 template<class GM, class ACC>
300 inline typename LOC<GM, ACC>::ValueType
302 {
303  return this->movemaker_.value();
304 }
305 
306 template<class GM, class ACC>
307 void inline
309 (
310  std::vector<double>& prob,const size_t maxRadius
311 )
312 {
313  if(maxRadius!=0){
314  const double phi = param_.phi_;
315  prob.resize(maxRadius);
316  for(size_t i=0;i<maxRadius-1;++i) {
317  prob[i] = phi * pow((1.0-phi), static_cast<double>(i));
318  }
319  prob[maxRadius-1]= pow((1.0-phi), static_cast<double>(maxRadius));
320  }
321 }
322 
323 template<class GM, class ACC>
324 inline std::string
326  return "LOC";
327 }
328 
329 template<class GM, class ACC>
330 inline const typename LOC<GM, ACC>::GraphicalModelType&
332  return gm_;
333 }
334 
335 template<class GM, class ACC>
337 (
338  const size_t startVi,
339  const size_t radius,
340  std::vector<size_t>& vis
341 ) {
342  std::fill(usedVi_.begin(),usedVi_.end(),false);
343  vis.clear();
344  vis.push_back(startVi);
345  usedVi_[startVi]=true;
346  std::queue<size_t> viQueue;
347  viQueue.push(startVi);
348 
349  std::fill(distance_.begin(),distance_.begin()+gm_.numberOfVariables(),0);
350 
351  const size_t maxSgSize = (param_.maxBlockSize_==0? gm_.numberOfVariables() :param_.maxBlockSize_);
352  while(viQueue.size()!=0 && vis.size()<=maxSgSize) {
353  size_t cvi=viQueue.front();
354  viQueue.pop();
355  // for each neigbour of cvi
356  for(size_t vni=0;vni<viAdjacency_[cvi].size();++vni) {
357  // if neighbour has not been visited
358  const size_t vn=viAdjacency_[cvi][vni];
359  if(usedVi_[vn]==false) {
360  // set as visited
361  usedVi_[vn]=true;
362  // insert into the subgraph vis
363  distance_[vn]=distance_[cvi]+1;
364  if(distance_[vn]<=radius){
365  if(vis.size()<maxSgSize){
366  vis.push_back(vn);
367  viQueue.push(vn);
368  }
369  else{
370  break;
371  }
372  }
373  }
374  }
375  }
376 }
377 
378 
379 template<class GM, class ACC>
381 (
382  const size_t startVi,
383  const size_t radius,
384  std::vector<size_t>& vis
385 ) {
386 
387  //std::cout<<"build tree\n";
388  std::fill(usedVi_.begin(),usedVi_.end(),false);
389  std::fill(checkedVi_.begin(),checkedVi_.end(),false);
390  vis.clear();
391  vis.push_back(startVi);
392  usedVi_[startVi]=true;
393  checkedVi_[startVi]=true;
394  std::deque<IndexType> viQueue;
395  viQueue.push_back(startVi);
396 
397  bool first=true;
398  const size_t maxSgSize = (param_.maxTreeSize_==0? gm_.numberOfVariables() :param_.maxTreeSize_);
399 
400  std::fill(distance_.begin(),distance_.begin()+gm_.numberOfVariables(),0);
401  //std::fill(distance_.begin(),distance_.begin()+vis.size(),0);
402 
403  while(viQueue.size()!=0 && /*r<radius &&*/ vis.size()<=maxSgSize) {
404  IndexType cvi=viQueue.front();
405 
406  OPENGM_CHECK(usedVi_[cvi]==false || vis.size()==1,"");
407 
408 
409  //std::cout<<"cvi "<<cvi<<" size "<<viQueue.size()<<" vis size "<<vis.size()<<"\n";
410  viQueue.pop_front();
411 
412  if(checkedVi_[cvi]==true && first ==false){
413  continue;
414  }
415  first=false;
416 
417  size_t includeInTree=0;
418  // for each neigbour of cvi
419  for(size_t vni=0;vni<viAdjacency_[cvi].size();++vni) {
420  const IndexType vn=viAdjacency_[cvi][vni];
421  if(usedVi_[vn]==true) {
422  ++includeInTree;
423  }
424  }
425  //std::cout<<"inlcuded in tree "<<includeInTree<<"\n";
426  OPENGM_CHECK_OP(includeInTree,<=,vis.size(),"");
427  //OPENGM_CHECK_OP(includeInTree,<=,2,"");
428  checkedVi_[cvi]=true;
429  //std::cout<<"icn in tree "<<includeInTree<<"\n";
430  OPENGM_CHECK(includeInTree>0 || (vis.size()==1 && includeInTree==0),"");
431  //if (usedVi_[cvi]==false && includeInTree<=1){
432  if (includeInTree<=1){
433  //std::cout<<"in 1....\n";
434  // insert into the subgraph vis
435  if(usedVi_[cvi]==false){
436  vis.push_back(cvi);
437  // set as visited
438  usedVi_[cvi]=true;
439 
440  if(vis.size()>=maxSgSize){
441  //std::cout<<"max size exit\n";
442  }
443  }
444 
445  std::vector<IndexType> adjVis(viAdjacency_[cvi].size());
446  for(size_t vni=0;vni<viAdjacency_[cvi].size();++vni) {
447  const size_t vn=viAdjacency_[cvi][vni];
448  adjVis[vni]=vn;
449  }
450  std::random_shuffle(adjVis.begin(),adjVis.end());
451 
452  // for each neigbour of cvi
453  for(size_t vni=0;vni<viAdjacency_[cvi].size();++vni) {
454  //std::cout<<"hello\n";
455  // if neighbour has not been visited
456  const size_t vn=adjVis[vni];
457  //std::cout<<"in 2....\n";
458  if(usedVi_[vn]==false && checkedVi_[vn]==false) {
459  //std::cout<<"in 3....\n";
460  // insert into queue
461 
462  distance_[vn]=distance_[cvi]+1;
463  if(distance_[vn]<=radius)
464  viQueue.push_back(vn);
465  }
466  }
467  }
468  else{
469  //usedVi_[cvi]=true;
470  }
471  }
472 }
473 
474 template<class GM, class ACC>
477  EmptyVisitorType v;
478  return infer(v);
479 }
480 
481 template<class GM, class ACC>
482 template<class VisitorType>
485 (
486  VisitorType& visitor
487 ) {
488 
489  //const UInt64Type autoStop = param_.stopAfterNBadIterations_==0 ? gm_.numberOfVariables() : param_.stopAfterNBadIterations_;
490  const bool useTrees = param_.maxTreeRadius_ > 0;
491  const bool useBlocks = param_.maxBlockRadius_ > 0;
492 
493 
494 
495  visitor.begin(*this);
496  // create random generators
497  opengm::RandomUniform<size_t> randomVariable(0, gm_.numberOfVariables());
498  opengm::RandomUniform<double> random01(0.0, 1.0);
499 
500  std::vector<double> probBlock,probTree;
501  opengm::RandomDiscreteWeighted<size_t, double> randomRadiusBlock,randomRadiusTree;
502 
503  if(useBlocks){
504  this->initializeProbabilities(probBlock,param_.maxBlockRadius_);
505  randomRadiusBlock =opengm::RandomDiscreteWeighted<size_t, double> (probBlock.begin(), probBlock.end());
506  }
507  if(useTrees){
508  this->initializeProbabilities(probTree,param_.maxTreeRadius_);
509  randomRadiusTree= opengm::RandomDiscreteWeighted<size_t, double> (probTree.begin(), probTree.end());
510  }
511 
512 
513 
514  std::vector<size_t> subgGraphViBLock;
515  std::vector<size_t> subgGraphViTree;
516 
517  // all iterations, usualy n*log(n)
518 
519  //ValueType e1 = movemaker_.value(),e2;
520  //size_t badIter=0;
521 
522  for(IndexType vi=0;vi<gm_.numberOfVariables();++vi){
523  subOptimizer_.setLabel(vi,movemaker_.state(vi));
524  }
525 
526 
527  for(IndexType run=0;run<2;++run){
528  std::vector<bool> coverdVar(gm_.numberOfVariables(),false);
529 
530  for(IndexType vi=0;vi<gm_.numberOfVariables();++vi){
531  if(coverdVar[vi]==false){
532  size_t viStart = vi;
533  // select random radius block and tree
534  size_t radiusBlock = (useBlocks ? randomRadiusBlock()+1 : 0);
535  size_t radiusTree = (useTrees ? randomRadiusTree()+1 : 0);
536 
537 
538  //std::cout<<"viStart "<<viStart<<" rt "<<radiusTree<<" rb "<<radiusBlock<<"\n";
539 
540 
541 
542 
543  if(useTrees){
544  //std::cout<<"get'n optimize tree model\n";
545  if(param_.treeRuns_>0){
546  for(size_t tr=0;tr<(size_t)(param_.treeRuns_);++tr){
547  this->getSubgraphTreeVis(viStart, radiusTree, subgGraphViTree);
548  std::sort(subgGraphViTree.begin(), subgGraphViTree.end());
549  optimizeSubmodel(subgGraphViTree,true);
550  }
551  }
552  else{
553  size_t nTr=(param_.treeRuns_==0? 1: std::abs(param_.treeRuns_));
554  bool changes=true;
555  while(changes){
556  this->getSubgraphTreeVis(viStart, radiusTree, subgGraphViTree);
557  std::sort(subgGraphViTree.begin(), subgGraphViTree.end());
558  changes=false;
559  for(size_t tr=0;tr<nTr;++tr){
560  this->getSubgraphTreeVis(viStart, radiusTree, subgGraphViTree);
561  std::sort(subgGraphViTree.begin(), subgGraphViTree.end());
562  bool c=optimizeSubmodel(subgGraphViTree,true);
563  if(c){
564  changes=true;
565  }
566  }
567  }
568  }
569  }
570  //std::cout<<"bevore block "<<movemaker_.value()<<"\n";
571  if(useBlocks){
572  this->getSubgraphVis(viStart, radiusBlock, subgGraphViBLock);
573  std::sort(subgGraphViBLock.begin(), subgGraphViBLock.end());
574  optimizeSubmodel(subgGraphViBLock,false);
575 
576  for(IndexType lvi=0;lvi<subgGraphViBLock.size();++lvi){
577  coverdVar[subgGraphViBLock[lvi]]=true;
578  }
579  }
580  //std::cout<<"after block "<<movemaker_.value()<<"\n";
581 
582  //std::cout<<"after tree "<<movemaker_.value()<<"\n";
583  visitor(*this);
584  }
585  }
586  }
587 
588  for(size_t i=0;i<0;++i) {
589  //for(size_t i=0;i<param_.maxIterations_;++i) {
590 
591  //std::cout<<i<<" "<<param_.maxIterations_<<"\n";
592 
593  // select random variable
594  size_t viStart = randomVariable();
595  // select random radius block and tree
596  size_t radiusBlock = (useBlocks ? randomRadiusBlock()+1 : 0);
597  size_t radiusTree = (useTrees ? randomRadiusTree()+1 : 0);
598 
599 
600  //std::cout<<"viStart "<<viStart<<" rt "<<radiusTree<<" rb "<<radiusBlock<<"\n";
601 
602 
603 
604 
605  if(useTrees){
606  //std::cout<<"get'n optimize tree model\n";
607  if(param_.treeRuns_>0){
608  for(size_t tr=0;tr<(size_t)(param_.treeRuns_);++tr){
609  this->getSubgraphTreeVis(viStart, radiusTree, subgGraphViTree);
610  std::sort(subgGraphViTree.begin(), subgGraphViTree.end());
611  optimizeSubmodel(subgGraphViTree,true);
612  }
613  }
614  else{
615  size_t nTr=(param_.treeRuns_==0? 1: std::abs(param_.treeRuns_));
616  bool changes=true;
617  while(changes){
618  this->getSubgraphTreeVis(viStart, radiusTree, subgGraphViTree);
619  std::sort(subgGraphViTree.begin(), subgGraphViTree.end());
620  changes=false;
621  for(size_t tr=0;tr<nTr;++tr){
622  this->getSubgraphTreeVis(viStart, radiusTree, subgGraphViTree);
623  std::sort(subgGraphViTree.begin(), subgGraphViTree.end());
624  bool c=optimizeSubmodel(subgGraphViTree,true);
625  if(c){
626  changes=true;
627  }
628  }
629  }
630  }
631  }
632  //std::cout<<"bevore block "<<movemaker_.value()<<"\n";
633  if(useBlocks){
634  this->getSubgraphVis(viStart, radiusBlock, subgGraphViBLock);
635  std::sort(subgGraphViBLock.begin(), subgGraphViBLock.end());
636  optimizeSubmodel(subgGraphViBLock,false);
637  }
638  //std::cout<<"after block "<<movemaker_.value()<<"\n";
639 
640  //std::cout<<"after tree "<<movemaker_.value()<<"\n";
641  visitor(*this);
642 
643 
644  }
645  std::cout<<"basic inference is done\n";
646  visitor.end(*this);
647  return NORMAL;
648 }
649 
650 template<class GM, class ACC>
651 bool LOC<GM, ACC>::optimizeSubmodel(std::vector<size_t> & subgGraphVi,const bool useTrees){
652 
653  bool changes=false;
654  std::vector<LabelType> states;
655  if(subgGraphVi.size()>2){
656  subOptimizer_.setVariableIndices(subgGraphVi.begin(), subgGraphVi.end());
657 
658 
659  if (useTrees){
660  //std::cout<<"infer with tres\n";
661  changes = subOptimizer_.mergeFactorsAndInferDp(states);
662  //changes = subOptimizer_. template inferSubmodel<BpSubInf>(typename BpSubInf::Parameter() ,states);
663  //changes = subOptimizer_. template inferSubmodel<DpSubInf>(typename DpSubInf::Parameter() ,states);
664  //std::cout<<"infer with tress\n";
665  }
666  // OPTIMAL OR MONOTON MOVERS
667  else if(param_.solver_==std::string("ad3")){
668  changes = subOptimizer_. template inferSubmodelInplace<Ad3SubInf>(typename Ad3SubInf::Parameter(Ad3SubInf::AD3_ILP) ,states);
669  }
670 
671  else if (param_.solver_==std::string("astar")){
672  //changes = subOptimizer_. template inferSubmodel<AStarSubInf>(typename AStarSubInf::Parameter() ,states);
673  }
674  else if (param_.solver_==std::string("cplex")){
675  #ifdef WITH_CPLEX
676  //typedef opengm::LPCplex<SubGmType,AccumulationType> LpCplexSubInf;
677  typename LpCplexSubInf::Parameter subParam;
678  subParam.integerConstraint_=true;
679  changes = subOptimizer_. template inferSubmodel<LpCplexSubInf>(subParam ,states);
680  #else
681  throw RuntimeError("solver cplex needs flag WITH_CPLEX defined bevore the #include of LOC sovler");
682  #endif
683  }
684  // MONOTON MOVERS
685  else if(param_.solver_[0]=='l' && param_.solver_[1]=='f'){
686  std::stringstream ss;
687  for(size_t i=2;i<param_.solver_.size();++i){
688  ss<<param_.solver_[i];
689  }
690  size_t maxSgSize;
691  ss>>maxSgSize;
692  changes = subOptimizer_. template inferSubmodel<LfSubInf>(typename LfSubInf::Parameter(maxSgSize) ,states,true,true);
693  }
694 
695  subOptimizer_.unsetVariableIndices();
696 
697  if(changes){
698  movemaker_.move(subgGraphVi.begin(), subgGraphVi.end(), states.begin());
699  for(IndexType v=0;v<subgGraphVi.size();++v){
700  subOptimizer_.setLabel(subgGraphVi[v],movemaker_.state(subgGraphVi[v]));
701  }
702  }
703  }
704  else{
705  // do nothing
706  }
707 
708  return changes;
709 }
710 
711 
712 template<class GM, class ACC>
715 (
716  std::vector<LabelType>& x,
717  const size_t N
718 ) const {
719  if(N == 1) {
720  x.resize(gm_.numberOfVariables());
721  for(size_t j = 0; j < x.size(); ++j) {
722  x[j] = movemaker_.state(j);
723  }
724  return NORMAL;
725  }
726  else
727  return UNKNOWN;
728 }
729 
730 } // namespace opengm
731 
732 #endif // #ifndef OPENGM_LOC_HXX
733 
InferenceTermination arg(std::vector< LabelType > &, const size_t=1) const
output a solution
Definition: loc.hxx:715
Update rules for the MessagePassing framework.
size_t maxBlockSize_
Definition: loc.hxx:163
Update rules for the MessagePassing framework.
The OpenGM namespace.
Definition: config.hxx:43
double phi_
phi of the truncated geometric distribution is used to select a certain subgraph radius with a certai...
Definition: loc.hxx:150
opengm::LazyFlipper< SubGmType, AccumulationType > LfSubInf
Definition: loc.hxx:72
LOC(const GraphicalModelType &, const Parameter &param=Parameter())
Definition: loc.hxx:249
opengm::BeliefPropagationUpdateRules< SubGmType, AccumulationType > UpdateRulesTypeBp
Definition: loc.hxx:73
opengm::visitors::VerboseVisitor< LOC< GM, ACC > > VerboseVisitorType
Definition: loc.hxx:60
const GraphicalModelType & graphicalModel() const
Definition: loc.hxx:331
A framework for message passing algorithms Cf. F. R. Kschischang, B. J. Frey and H...
std::string solver_
Definition: loc.hxx:148
LOC< _GM, ACC > type
Definition: loc.hxx:86
opengm::TrbpUpdateRules< SubGmType, AccumulationType > UpdateRulesTypeTrbp
Definition: loc.hxx:74
void setStartingPoint(typename std::vector< LabelType >::const_iterator)
set initial labeling
Definition: loc.hxx:288
ValueType value() const
return the solution (value)
Definition: loc.hxx:301
GM GraphicalModelType
Definition: loc.hxx:56
size_t maxTreeRadius_
Definition: loc.hxx:153
void setInsideClean(VI_ITER begin, VI_ITER end)
Definition: loc.hxx:197
LOC< _GM, _ACC > type
Definition: loc.hxx:91
A star search algorithm.
Definition: astar.hxx:64
size_t stopAfterNBadIterations_
Definition: loc.hxx:160
GraphicalModelType::IndexType IndexType
Definition: inference.hxx:49
InferenceTermination infer()
Definition: loc.hxx:476
OPENGM_GM_TYPE_TYPEDEFS
Definition: loc.hxx:57
opengm::MessagePassing< SubGmType, AccumulationType, UpdateRulesTypeTrbp, opengm::MaxDistance > TrBpSubInf
Definition: loc.hxx:76
ACC AccumulationType
Definition: loc.hxx:55
Movemaker< GraphicalModelType > MovemakerType
Definition: loc.hxx:58
Optimization by Linear Programming (LP) or Integer LP using IBM ILOG CPLEX http://www.ilog.com/products/cplex/.
Definition: lpcplex.hxx:38
GraphicalModelType::ValueType ValueType
Definition: inference.hxx:50
opengm::external::AD3Inf< SubGmType, AccumulationType > Ad3SubInf
Definition: loc.hxx:79
Inference algorithm interface.
Definition: inference.hxx:43
void setBorderDirty(VI_ITER begin, VI_ITER end)
Definition: loc.hxx:181
SubOptimizer::SubGmType SubGmType
Definition: loc.hxx:66
SubmodelOptimizer< GM, ACC > SubOptimizer
Definition: loc.hxx:65
LOC Algorithm K. Jung, P. Kohli and D. Shah, "Local Rules for Global MAP: When Do They Work...
Definition: loc.hxx:53
bool hasDirtyInsideVariables(VI_ITER begin, VI_ITER end)
Definition: loc.hxx:208
opengm::MessagePassing< SubGmType, AccumulationType, UpdateRulesTypeBp, opengm::MaxDistance > BpSubInf
Definition: loc.hxx:75
opengm::AStar< SubGmType, AccumulationType > AStarSubInf
Definition: loc.hxx:71
#define OPENGM_CHECK_OP(A, OP, B, TXT)
Definition: submodel2.hxx:24
double pFastHeuristic_
prob. of f
Definition: loc.hxx:155
size_t maxIterations_
maximum number of iterations
Definition: loc.hxx:157
opengm::visitors::EmptyVisitor< LOC< GM, ACC > > EmptyVisitorType
Definition: loc.hxx:61
void reset()
Definition: loc.hxx:273
#define OPENGM_CHECK(B, TXT)
Definition: submodel2.hxx:28
GraphicalModelType::LabelType LabelType
Definition: inference.hxx:48
opengm::visitors::TimingVisitor< LOC< GM, ACC > > TimingVisitorType
Definition: loc.hxx:62
opengm::DynamicProgramming< SubGmType, AccumulationType > DpSubInf
Definition: loc.hxx:70
A generalization of ICM B. Andres, J. H. Kappes, U. Koethe and Hamprecht F. A., The Lazy Flipper: MA...
size_t maxBlockRadius_
maximum subgraph radius
Definition: loc.hxx:152
OpenGM runtime error.
Definition: opengm.hxx:100
T abs(const T &x)
Definition: opengm.hxx:111
InferenceTermination
Definition: inference.hxx:24
std::string name() const
Definition: loc.hxx:325