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