OpenGM  2.3.x
Discrete Graphical Model Library
combilp.hxx
Go to the documentation of this file.
1 /*
2  * combiLP.hxx
3  *
4  * Created on: Sep 16, 2013
5  * Author: bsavchyn
6  */
7 
8 #ifndef COMBILP_HXX_
9 #define COMBILP_HXX_
15 
16 namespace opengm{
17 
18  namespace combilp_base{
19 
20  template<class FACTOR>
21  void MakeFactorVariablesTrue(const FACTOR& f,std::vector<bool>* pmask)
22  {
23  for (typename FACTOR::VariablesIteratorType it=f.variableIndicesBegin();
24  it!=f.variableIndicesEnd();++it)
25  (*pmask)[*it]=true;
26  }
27 
28  template<class GM>
29  void DilateMask(const GM& gm,typename GM::IndexType varId,std::vector<bool>* pmask)
30  {
31  typename GM::IndexType numberOfFactors=gm.numberOfFactors(varId);
32  for (typename GM::IndexType localFactorId=0;localFactorId<numberOfFactors;++localFactorId)
33  {
34  const typename GM::FactorType& f=gm[gm.factorOfVariable(varId,localFactorId)];
35  if (f.numberOfVariables()>1)
36  MakeFactorVariablesTrue(f,pmask);
37  }
38  }
39 
40 /*
41  * inmask and poutmask should be different objects!
42  */
43  template<class GM>
44  void DilateMask(const GM& gm,const std::vector<bool>& inmask, std::vector<bool>* poutmask)
45  {
46  *poutmask=inmask;
47  for (typename GM::IndexType varId=0;varId<inmask.size();++varId)
48  if (inmask[varId]) DilateMask(gm,varId,poutmask);
49 
50  }
51 
52  template<class GM>
53  bool LabelingMatching(const std::vector<typename GM::LabelType>& labeling1,const std::vector<typename GM::LabelType>& labeling2,
54  const std::vector<bool>& mask,std::list<typename GM::IndexType>* presult)
55  {
56  OPENGM_ASSERT(labeling1.size()==mask.size());
57  OPENGM_ASSERT(labeling2.size()==mask.size());
58  presult->clear();
59  for (typename GM::IndexType varId=0;varId<mask.size();++varId)
60  if ((mask[varId]) && (labeling1[varId]!=labeling2[varId]))
61  presult->push_back(varId);
62 
63  return presult->empty();
64  }
65 
66  template<class GM>
67  void GetMaskBoundary(const GM& gm,const std::vector<bool>& mask,std::vector<bool>* boundmask)
68  {
69  boundmask->assign(mask.size(),false);
70  for (typename GM::IndexType varId=0;varId<mask.size();++varId)
71  {
72  if (!mask[varId]) continue;
73 
74  typename GM::IndexType numberOfFactors=gm.numberOfFactors(varId);
75  for (typename GM::IndexType localFactorId=0;localFactorId<numberOfFactors;++localFactorId)
76  {
77  if ((*boundmask)[varId]) break;
78 
79  const typename GM::FactorType& f=gm[gm.factorOfVariable(varId,localFactorId)];
80  if (f.numberOfVariables()>1)
81  {
82  for (typename GM::FactorType::VariablesIteratorType it=f.variableIndicesBegin();
83  it!=f.variableIndicesEnd();++it)
84  if (!mask[*it])
85  {
86  (*boundmask)[varId]=true;
87  break;
88  }
89  }
90  }
91  }
92  }
93 
94 //template<class LPREPARAMETRIZERPARAMETERS>
96 
97  CombiLP_base_Parameter(size_t maxNumberOfILPCycles=100,
98  bool verbose=false,
99  const std::string& reparametrizedModelFileName="",//will not be saved if empty
100  bool singleReparametrization=true,
101  bool saveProblemMasks=false,
102  std::string maskFileNamePre=""):
103  maxNumberOfILPCycles_(maxNumberOfILPCycles),
104  verbose_(verbose),
105  reparametrizedModelFileName_(reparametrizedModelFileName),
106  singleReparametrization_(singleReparametrization),
107  saveProblemMasks_(saveProblemMasks),
108  maskFileNamePre_(maskFileNamePre),
109  threads_(1)
110  {};
112  size_t maxNumberOfILPCycles_;
113  bool verbose_;
117  std::string maskFileNamePre_;
118  size_t threads_;
119 
120 #ifdef TRWS_DEBUG_OUTPUT
121  virtual void print(std::ostream& fout)const
122  {
123  fout <<"maxNumberOfILPCycles="<<maxNumberOfILPCycles_<<std::endl;
124  fout <<"verbose"<<verbose_<<std::endl;
125  fout <<"reparametrizedModelFileName="<<reparametrizedModelFileName_<<std::endl;
126  fout <<"singleReparametrization="<<singleReparametrization_<<std::endl;
127  fout <<"saveProblemMasks="<<saveProblemMasks_<<std::endl;
128  fout <<"maskFileNamePre="<<maskFileNamePre_<<std::endl;
129  }
130 #endif
131  };
132 
133 
134 
135  template<class GM, class ACC, class LPREPARAMETRIZER>//TODO: remove default ILP solver
137  {
138  public:
139  typedef ACC AccumulationType;
140  typedef GM GraphicalModelType;
141 
143 
145  typedef LPREPARAMETRIZER ReparametrizerType;
146  typedef typename ReparametrizerType::MaskType MaskType;
147 
149 
150  typedef LPCplex<typename GMManipulatorType::MGM, Minimizer> LPCPLEX;//TODO: move to template parameters
151 
152  CombiLP_base(LPREPARAMETRIZER& reparametrizer, const Parameter& param
153 #ifdef TRWS_DEBUG_OUTPUT
154  , std::ostream& fout=std::cout
155 #endif
156  );
157  virtual ~CombiLP_base(){};
158 
159  const GraphicalModelType& graphicalModel() const { return _lpparametrizer->graphicalModel(); }
160 
161  template <class VISITORWRAPPER> InferenceTermination infer(MaskType& mask,const std::vector<LabelType>& lp_labeling,VISITORWRAPPER& vis);
162 
163  InferenceTermination arg(std::vector<LabelType>& out, const size_t = 1) const
164  {
165  out = _labeling;
166  return opengm::NORMAL;
167  }
168 
169  ValueType value() const{return _value;};
170  ValueType bound() const{return _bound;}
171 
172  void ReparametrizeAndSave();
173  private:
174  void _Reparametrize(typename ReparametrizerType::ReparametrizedGMType* pgm,const MaskType& mask);
175  InferenceTermination _PerformILPInference(GMManipulatorType& modelManipulator,std::vector<LabelType>* plabeling);
176  Parameter _parameter;
177  ReparametrizerType& _lpparametrizer;
178  std::vector<LabelType> _labeling;
179  ValueType _value;
180  ValueType _bound;
181 #ifdef TRWS_DEBUG_OUTPUT
182  std::ostream& _fout;
183 #endif
184  };
185 
186  template<class GM, class ACC, class LPREPARAMETRIZER>
187  CombiLP_base<GM,ACC,LPREPARAMETRIZER>::CombiLP_base(LPREPARAMETRIZER& reparametrizer, const Parameter& param
188 #ifdef TRWS_DEBUG_OUTPUT
189  , std::ostream& fout
190 #endif
191  )
192  : _parameter(param)
193  ,_lpparametrizer(reparametrizer)
194  ,_labeling(_lpparametrizer.graphicalModel().numberOfVariables(),std::numeric_limits<LabelType>::max())
195  ,_value(ACC::template neutral<ValueType>())
196  ,_bound(ACC::template ineutral<ValueType>())
197 #ifdef TRWS_DEBUG_OUTPUT
198  ,_fout(param.verbose_ ? fout : *OUT::nullstream::Instance())//(fout)
199 #endif
200  {
201  };
202 
203  template<class GM, class ACC, class LPREPARAMETRIZER>
204  InferenceTermination CombiLP_base<GM,ACC,LPREPARAMETRIZER>::_PerformILPInference(GMManipulatorType& modelManipulator,std::vector<LabelType>* plabeling)
205  {
206  InferenceTermination terminationILP=NORMAL;
207  modelManipulator.buildModifiedSubModels();
208 
209  std::vector<std::vector<LabelType> > submodelLabelings(modelManipulator.numberOfSubmodels());
210  for (size_t modelIndex=0;modelIndex<modelManipulator.numberOfSubmodels();++modelIndex)
211  {
212  const typename GMManipulatorType::MGM& model=modelManipulator.getModifiedSubModel(modelIndex);
213  submodelLabelings[modelIndex].resize(model.numberOfVariables());
214  typename LPCPLEX::Parameter param;
215  param.integerConstraint_=true;
216  param.numberOfThreads_= _parameter.threads_;
217  param.timeLimit_ = 3600; // TODO: Make this a parameter (1h)
218  param.workMem_= 1024*6; // TODO: Make this a parameter (6GB)
219  LPCPLEX ilpSolver(model,param);
220  terminationILP=ilpSolver.infer();
221 
222  if ((terminationILP!=NORMAL) && (terminationILP!=CONVERGENCE)){
223  return terminationILP;
224  //std::cout << "WARNING: solving ILP failed!"<<std::endl;
225  //return NORMAL;
226  }
227  else
228  ilpSolver.arg(submodelLabelings[modelIndex]);
229  }
230 
231  modelManipulator.modifiedSubStates2OriginalState(submodelLabelings,*plabeling);
232  return terminationILP;
233  }
234 
235  template<class GM, class ACC, class LPREPARAMETRIZER>
236  template <class VISITORWRAPPER>
237  InferenceTermination CombiLP_base<GM,ACC,LPREPARAMETRIZER>::infer(MaskType& mask,const std::vector<LabelType>& lp_labeling,VISITORWRAPPER& vis)
238  {
239 #ifdef TRWS_DEBUG_OUTPUT
240  if (!_parameter.singleReparametrization_)
241  _fout << "Applying reparametrization for each ILP run ..."<<std::endl;
242  else
243  _fout << "Applying a single uniform reparametrization..."<<std::endl;
244 
245  _fout <<"Switching to ILP."<<std::endl;
246 #endif
247 
248  bool startILP=true;
249  typename ReparametrizerType::ReparametrizedGMType gm;
250  bool reparametrizedFlag=false;
251  InferenceTermination terminationId=TIMEOUT;
252 
253  for (size_t i=0;(startILP && (i<_parameter.maxNumberOfILPCycles_));++i)
254  {
255 
257  return TIMEOUT;
258  }
259 
260 #ifdef TRWS_DEBUG_OUTPUT
261  _fout << "Subproblem "<<i<<" size="<<std::count(mask.begin(),mask.end(),true)<<std::endl;
262 #endif
263 
264  MaskType boundmask(mask.size());
265  GetMaskBoundary(_lpparametrizer.graphicalModel(),mask,&boundmask);
266 
267 #ifdef TRWS_DEBUG_OUTPUT
268  if (_parameter.saveProblemMasks_)
269  {
270  OUT::saveContainer(std::string(_parameter.maskFileNamePre_+"-mask-"+trws_base::any2string(i)+".txt"),mask.begin(),mask.end());
271  OUT::saveContainer(std::string(_parameter.maskFileNamePre_+"-boundmask-"+trws_base::any2string(i)+".txt"),boundmask.begin(),boundmask.end());
272  }
273 #endif
274 
275  if (_parameter.singleReparametrization_ && (!reparametrizedFlag) )
276  {
277 #ifdef TRWS_DEBUG_OUTPUT
278  _fout << "Reparametrizing..."<<std::endl;
279 #endif
280  _Reparametrize(&gm,MaskType(mask.size(),true));
281  reparametrizedFlag=true;
282  }
283  else if (!_parameter.singleReparametrization_)
284  {
285 #ifdef TRWS_DEBUG_OUTPUT
286  _fout << "Reparametrizing..."<<std::endl;
287 #endif
288  _Reparametrize(&gm,mask);
289  }
290 
291  OPENGM_ASSERT(mask.size()==gm.numberOfVariables());
292 
293  GMManipulatorType modelManipulator(gm,GMManipulatorType::DROP);
294  modelManipulator.unlock();
295  modelManipulator.freeAllVariables();
296  for (IndexType varId=0;varId<mask.size();++varId)
297  if (mask[varId]==0) modelManipulator.fixVariable(varId,lp_labeling[varId]);
298  modelManipulator.lock();
299 
300  InferenceTermination terminationILP;
301  std::vector<LabelType> labeling;
302  terminationILP=_PerformILPInference(modelManipulator,&labeling);
303  if ((terminationILP!=NORMAL) && (terminationILP!=CONVERGENCE))
304  {
305  _labeling=lp_labeling;
306 #ifdef TRWS_DEBUG_OUTPUT
307  _fout << "ILP solver failed to solve the problem. LP solver results will be saved." <<std::endl;
308 #endif
309 
310  //return NORMAL;
311  return terminationILP;
312  }
313 
314 #ifdef TRWS_DEBUG_OUTPUT
315  _fout <<"Boundary size="<<std::count(boundmask.begin(),boundmask.end(),true)<<std::endl;
316 #endif
317 
318  std::list<IndexType> result;
319  if (LabelingMatching<GM>(lp_labeling,labeling,boundmask,&result))
320  {
321  startILP=false;
322  _labeling=labeling;
323  _value=_bound=_lpparametrizer.graphicalModel().evaluate(_labeling);
324  terminationId=NORMAL;
325 #ifdef TRWS_DEBUG_OUTPUT
326  _fout <<"Solved! Optimal energy="<<value()<<std::endl;
327 #endif
328  }
329  else
330  {
331 #ifdef TRWS_DEBUG_OUTPUT
332  _fout <<"Adding "<<result.size()<<" nodes."<<std::endl;
333  if (_parameter.saveProblemMasks_)
334  OUT::saveContainer(std::string(_parameter.maskFileNamePre_+"-added-"+trws_base::any2string(i)+".txt"),result.begin(),result.end());
335 #endif
336  for (typename std::list<IndexType>::const_iterator it=result.begin();it!=result.end();++it)
337  DilateMask(gm,*it,&mask);
338  }
339  }
340 
341  return terminationId;
342  }
343 
344 
345  template<class GM, class ACC, class LPREPARAMETRIZER>
347  _Reparametrize(typename ReparametrizerType::ReparametrizedGMType* pgm,const MaskType& mask)
348  {
349  _lpparametrizer.reparametrize(&mask);
350  _lpparametrizer.getReparametrizedModel(*pgm);
351  }
352 
353  template<class GM, class ACC, class LPREPARAMETRIZER>
356  {
357  typename ReparametrizerType::ReparametrizedGMType gm;
358  _Reparametrize(&gm,MaskType(_lpparametrizer.graphicalModel().numberOfVariables(),true));
359  store_into_explicit(gm, _parameter.reparametrizedModelFileName_);
360  }
361 
362  }//namespace combilp_base =========================================================================
363 
364  template<class LPSOLVERPARAMETERS,class REPARAMETRIZERPARAMETERS>
366  {
368  CombiLP_Parameter(const LPSOLVERPARAMETERS& lpsolverParameter=LPSOLVERPARAMETERS(),
369  const REPARAMETRIZERPARAMETERS& repaParameter=REPARAMETRIZERPARAMETERS(),
370  size_t maxNumberOfILPCycles=100,
371  bool verbose=false,
372  bool saveReparametrizedModel=false,
373  const std::string& reparametrizedModelFileName="",
374  bool singleReparametrization=true,
375  bool saveProblemMasks=false,
376  std::string maskFileNamePre=""):
377  parent(maxNumberOfILPCycles,
378  verbose,
379  reparametrizedModelFileName,
380  singleReparametrization,
381  saveProblemMasks,
382  maskFileNamePre),
383  lpsolverParameter_(lpsolverParameter),
384  repaParameter_(repaParameter)
385  {
386  };
387  LPSOLVERPARAMETERS lpsolverParameter_;
388  REPARAMETRIZERPARAMETERS repaParameter_;
389 
390 #ifdef TRWS_DEBUG_OUTPUT
391  void print(std::ostream& fout)const
392  {
393  parent::print(fout);
394  fout << "== lpsolverParameters: =="<<std::endl;
395  lpsolverParameter_.print(fout);
396  }
397 #endif
398  };
399 
405 
406  template<class GM, class ACC, class LPSOLVER>//TODO: remove default ILP solver
407  class CombiLP : public Inference<GM, ACC>
408  {
409  public:
410  typedef typename LPSOLVER::ReparametrizerType ReparametrizerType;
412 
413  typedef ACC AccumulationType;
414  typedef GM GraphicalModelType;
415 
420 
422  typedef typename ReparametrizerType::MaskType MaskType;
424 
425  typedef LPCplex<typename GMManipulatorType::MGM, ACC> LPCPLEX;//TODO: move to template parameters
426 
427  CombiLP(const GraphicalModelType& gm, const Parameter& param
428 #ifdef TRWS_DEBUG_OUTPUT
429  , std::ostream& fout=std::cout
430 #endif
431  );
432  virtual ~CombiLP(){if (_plpparametrizer!=0) delete _plpparametrizer;};
433  std::string name() const{ return "CombiLP"; }
434  const GraphicalModelType& graphicalModel() const { return _lpsolver.graphicalModel(); }
436  {
437  EmptyVisitorType vis;
438  return infer(vis);
439  };
440 
441  template<class VISITOR> InferenceTermination infer(VISITOR & visitor);
442 
443  InferenceTermination arg(std::vector<LabelType>& out, const size_t = 1) const
444  {
445  out = _labeling;
446  return opengm::NORMAL;
447  }
448  virtual ValueType bound() const{return _bound;};
449  virtual ValueType value() const{return _value;};
450  private:
451  Parameter _parameter;
452  LPSOLVER _lpsolver;
453  ReparametrizerType* _plpparametrizer;
454  BaseType _base;
455  std::vector<LabelType> _labeling;
456  ValueType _value;
457  ValueType _bound;
458 #ifdef TRWS_DEBUG_OUTPUT
459  std::ostream& _fout;
460 #endif
461  };
462 
463  template<class GM, class ACC, class LPSOLVER>
465 #ifdef TRWS_DEBUG_OUTPUT
466  , std::ostream& fout
467 #endif
468  )
469  : _parameter(param)
470  ,_lpsolver(gm,param.lpsolverParameter_
471 #ifdef TRWS_DEBUG_OUTPUT
472  ,(param.lpsolverParameter_.verbose_ ? fout : *OUT::nullstream::Instance())//fout
473 #endif
474  )
475  ,_plpparametrizer(_lpsolver.getReparametrizer(_parameter.repaParameter_))//TODO: parameters of the reparametrizer come here
476  ,_base(*_plpparametrizer, param
477 #ifdef TRWS_DEBUG_OUTPUT
478  ,fout
479 #endif
480  )
481  ,_labeling(gm.numberOfVariables(),std::numeric_limits<LabelType>::max())
482  ,_value(_lpsolver.value())
483  ,_bound(_lpsolver.bound())
484 #ifdef TRWS_DEBUG_OUTPUT
485  ,_fout(param.verbose_ ? fout : *OUT::nullstream::Instance())//(fout)
486 #endif
487  {
488 #ifdef TRWS_DEBUG_OUTPUT
489  _fout << "Parameters of the "<< name() <<" algorithm:"<<std::endl;
490  param.print(_fout);
491 #endif
492  };
493 
494  template<class GM, class ACC, class LPSOLVER>
495  template<class VISITOR>
497  {
498 #ifdef TRWS_DEBUG_OUTPUT
499  _fout <<"Running LP solver "<<_lpsolver.name()<<std::endl;
500 #endif
501  visitor.begin(*this);
502 
503  _lpsolver.infer();
504  _value=_lpsolver.value();
505  _bound=_lpsolver.bound();
506  _lpsolver.arg(_labeling);
507 
508  if( visitor(*this) != visitors::VisitorReturnFlag::ContinueInf ){
509  visitor.end(*this);
510  return NORMAL;
511  }
512 
513  std::vector<LabelType> labeling_lp;
514  MaskType initialmask;
515  _plpparametrizer->reparametrize();
516  //_plpparametrizer->getArcConsistency(&initialmask,&labeling_lp);
517  _lpsolver.getTreeAgreement(initialmask,&labeling_lp);
518 
519 #ifdef TRWS_DEBUG_OUTPUT
520  _fout <<"Energy of the labeling consistent with the arc consistency ="<<_lpsolver.graphicalModel().evaluate(labeling_lp)<<std::endl;
521  _fout <<"Arc inconsistent set size ="<<std::count(initialmask.begin(),initialmask.end(),false)<<std::endl;
522 #endif
523 
524 #ifdef TRWS_DEBUG_OUTPUT
525  _fout << "Trivializing."<<std::endl;
526 #endif
527 
528 #ifdef WITH_HDF5
529  if (_parameter.reparametrizedModelFileName_.compare("")!=0)
530  {
531 #ifdef TRWS_DEBUG_OUTPUT
532  _fout << "Saving reparametrized model..."<<std::endl;
533 #endif
534  if( visitor(*this) != visitors::VisitorReturnFlag::ContinueInf ){
535  visitor.end(*this);
536  return NORMAL;
537  }
538  _base.ReparametrizeAndSave();
539  if( visitor(*this) != visitors::VisitorReturnFlag::ContinueInf ){
540  visitor.end(*this);
541  return NORMAL;
542  }
543  }
544 #endif
545 
546  if (std::count(initialmask.begin(),initialmask.end(),false)==0)
547  return NORMAL;
548 
549  trws_base::transform_inplace(initialmask.begin(),initialmask.end(),std::logical_not<bool>());
550 
551  MaskType mask;
552  combilp_base::DilateMask(_lpsolver.graphicalModel(),initialmask,&mask);
553 
555  InferenceTermination terminationVal=_base.infer(mask,labeling_lp,vis);
556  //InferenceTermination terminationVal=_base.infer(mask,labeling_lp,trws_base::VisitorWrapper<VISITOR,CombiLP<GM,ACC,LPSOLVER> >(&visitor,this));
557  if ( (terminationVal==NORMAL) || (terminationVal==CONVERGENCE) )
558  {
559  _value=_base.value();
560  _bound=_base.bound();
561  _base.arg(_labeling);
562  }
563  /*else{
564  visitor.end(*this);
565  return ;
566  }*/
567 
568  visitor.end(*this);
569  //return terminationVal;
570  return NORMAL;
571  }
572 
573 
574 }
575 
576 
577 #endif /* COMBILP_HXX_ */
std::string name() const
Definition: combilp.hxx:433
LPCplex< typename GMManipulatorType::MGM, Minimizer > LPCPLEX
Definition: combilp.hxx:150
void DilateMask(const GM &gm, typename GM::IndexType varId, std::vector< bool > *pmask)
Definition: combilp.hxx:29
LPSOLVERPARAMETERS lpsolverParameter_
Definition: combilp.hxx:386
CombiLP Savchynskyy, B. and Kappes, J. H. and Swoboda, P. and Schnoerr, C.: "Global MAP-Optimality b...
Definition: combilp.hxx:407
The OpenGM namespace.
Definition: config.hxx:43
LPSOLVER::ReparametrizerType ReparametrizerType
Definition: combilp.hxx:410
void GetMaskBoundary(const GM &gm, const std::vector< bool > &mask, std::vector< bool > *boundmask)
Definition: combilp.hxx:67
combilp_base::CombiLP_base< GM, ACC, ReparametrizerType > BaseType
Definition: combilp.hxx:411
CombiLP_Parameter< typename LPSOLVER::Parameter, typename ReparametrizerType::Parameter > Parameter
Definition: combilp.hxx:421
opengm::GraphicalModelManipulator< typename ReparametrizerType::ReparametrizedGMType > GMManipulatorType
Definition: combilp.hxx:148
InferenceTermination arg(std::vector< LabelType > &out, const size_t=1) const
Definition: combilp.hxx:163
STL namespace.
combilp_base::CombiLP_base_Parameter parent
Definition: combilp.hxx:367
#define OPENGM_ASSERT(expression)
Definition: opengm.hxx:77
virtual ValueType bound() const
return a bound on the solution
Definition: combilp.hxx:448
LPCplex< typename GMManipulatorType::MGM, ACC > LPCPLEX
Definition: combilp.hxx:425
virtual ~CombiLP()
Definition: combilp.hxx:432
virtual ValueType value() const
return the solution (value)
Definition: combilp.hxx:449
BaseType::GMManipulatorType GMManipulatorType
Definition: combilp.hxx:423
InputIterator transform_inplace(InputIterator first, InputIterator last, UnaryOperator op)
Definition: utilities2.hxx:79
bool LabelingMatching(const std::vector< typename GM::LabelType > &labeling1, const std::vector< typename GM::LabelType > &labeling2, const std::vector< bool > &mask, std::list< typename GM::IndexType > *presult)
Definition: combilp.hxx:53
InferenceTermination infer()
Definition: combilp.hxx:435
const GraphicalModelType & graphicalModel() const
Definition: combilp.hxx:159
CombiLP_base_Parameter Parameter
Definition: combilp.hxx:144
visitors::TimingVisitor< CombiLP< GM, ACC, LPSOLVER > > TimingVisitorType
Definition: combilp.hxx:419
LPREPARAMETRIZER ReparametrizerType
Definition: combilp.hxx:145
const GraphicalModelType & graphicalModel() const
Definition: combilp.hxx:434
InferenceTermination infer(MaskType &mask, const std::vector< LabelType > &lp_labeling, VISITORWRAPPER &vis)
Definition: combilp.hxx:237
ACC AccumulationType
Definition: combilp.hxx:413
CombiLP_base_Parameter(size_t maxNumberOfILPCycles=100, bool verbose=false, const std::string &reparametrizedModelFileName="", bool singleReparametrization=true, bool saveProblemMasks=false, std::string maskFileNamePre="")
Definition: combilp.hxx:97
CombiLP_base(LPREPARAMETRIZER &reparametrizer, const Parameter &param)
Definition: combilp.hxx:187
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
Inference algorithm interface.
Definition: inference.hxx:34
std::string any2string(const AnyType &any)
Definition: utilities2.hxx:25
ReparametrizerType::MaskType MaskType
Definition: combilp.hxx:146
REPARAMETRIZERPARAMETERS repaParameter_
Definition: combilp.hxx:388
void MakeFactorVariablesTrue(const FACTOR &f, std::vector< bool > *pmask)
Definition: combilp.hxx:21
CombiLP_Parameter(const LPSOLVERPARAMETERS &lpsolverParameter=LPSOLVERPARAMETERS(), const REPARAMETRIZERPARAMETERS &repaParameter=REPARAMETRIZERPARAMETERS(), size_t maxNumberOfILPCycles=100, bool verbose=false, bool saveReparametrizedModel=false, const std::string &reparametrizedModelFileName="", bool singleReparametrization=true, bool saveProblemMasks=false, std::string maskFileNamePre="")
Definition: combilp.hxx:368
GraphicalModelType::LabelType LabelType
Definition: inference.hxx:39
ReparametrizerType::MaskType MaskType
Definition: combilp.hxx:422
visitors::EmptyVisitor< CombiLP< GM, ACC, LPSOLVER > > EmptyVisitorType
Definition: combilp.hxx:418
CombiLP(const GraphicalModelType &gm, const Parameter &param)
Definition: combilp.hxx:464
InferenceTermination
Definition: inference.hxx:24
visitors::VerboseVisitor< CombiLP< GM, ACC, LPSOLVER > > VerboseVisitorType
Definition: combilp.hxx:417
InferenceTermination arg(std::vector< LabelType > &out, const size_t=1) const
output a solution
Definition: combilp.hxx:443