1 #ifndef TRWS_INTERFACE_HXX_ 2 #define TRWS_INTERFACE_HXX_ 20 bool absolutePrecision=
true,
22 :parent(maxIternum,
precision,absolutePrecision),
58 #ifdef TRWS_DEBUG_OUTPUT 59 void print(std::ostream& fout)
const 62 fout <<
"precision="<<
precision()<<std::endl;
69 fout <<
"verbose="<<
verbose()<<std::endl;
92 template<
class GM,
class ACC>
110 TRWSi(
const GraphicalModelType& gm,
const Parameter& param
111 #ifdef TRWS_DEBUG_OUTPUT
112 ,std::ostream& fout=std::cout
116 _solver(_storage,param
117 #ifdef TRWS_DEBUG_OUTPUT
118 ,(param.
verbose_ ? fout : *OUT::nullstream::Instance())
121 #ifdef TRWS_DEBUG_OUTPUT 122 std::ostream& out=(param.verbose_ ? fout : *OUT::nullstream::Instance());
123 out <<
"Parameters of the "<< name() <<
" algorithm:"<<std::endl;
127 if (param.maxNumberOfIterations_==0)
throw 128 std::runtime_error(
"TRWSi: Maximal number of iterations (> 0) has to be specified!");
130 std::string
name()
const{
return "TRWSi"; }
131 const GraphicalModelType&
graphicalModel()
const {
return _storage.masterModel(); }
139 _solver.infer(visiwrap);
149 void getTreeAgreement(std::vector<bool>& out,std::vector<LabelType>* plabeling=0,std::vector<std::vector<LabelType> >* ptreeLabelings=0){_solver.getTreeAgreement(out,plabeling,ptreeLabelings);}
159 {
return new ReparametrizerType(_storage,_solver.getFactorProperties(),params);}
161 void getDDVector(DDVectorType* pddvector)
const{_storage.getDDVector(pddvector);}
trws_base::DecompositionStorage< GM > Storage
TRWSi(const GraphicalModelType &gm, const Parameter ¶m)
bool & isAbsolutePrecision()
Storage::StructureType & decompositionType()
const GraphicalModelType & graphicalModel() const
const Storage::StructureType & decompositionType() const
const bool & fastComputations() const
Storage & getDecompositionStorage()
ValueType minRelativeDualImprovement_
bool & fastComputations()
virtual ValueType bound() const
return a bound on the solution
Storage::StructureType decompositionType_
const ValueType & precision() const
size_t maxNumberOfIterations_
InferenceTermination infer()
visitors::EmptyVisitor< TRWSi< GM, ACC > > EmptyVisitorType
TRWSi_Parameter(size_t maxIternum=0, typename Storage::StructureType decompositionType=Storage::GENERALSTRUCTURE, ValueType precision=1.0, bool absolutePrecision=true, bool verbose=false)
InferenceTermination infer(VISITOR &visitor)
const Solver::FactorProperties & getFactorProperties() const
void getDDVector(DDVectorType *pddvector) const
const ValueType & minRelativeDualImprovement() const
std::vector< typename GM::ValueType > DDVectorType
ReparametrizerType * getReparametrizer(const typename ReparametrizerType::Parameter ¶ms=typename ReparametrizerType::Parameter())
TRWS_Reparametrizer< Storage, ACC > ReparametrizerType
ValueType & minRelativeDualImprovement()
size_t treeAgreeMaxStableIter() const
const size_t & maxNumberOfIterations() const
const bool & verbose() const
void getTreeAgreement(std::vector< bool > &out, std::vector< LabelType > *plabeling=0, std::vector< std::vector< LabelType > > *ptreeLabelings=0)
GraphicalModelType::ValueType ValueType
Storage::DDVectorType DDVectorType
Inference algorithm interface.
size_t & maxNumberOfIterations()
visitors::VerboseVisitor< TRWSi< GM, ACC > > VerboseVisitorType
std::vector< typename GM::ValueType > DDVectorType
virtual ValueType value() const
return the solution (value)
const bool & canonicalNormalization() const
trws_base::DecompositionStorage< GM > Storage
[class trwsi] TRWSi - tree-reweighted sequential message passing Based on the paper: V...
trws_base::MaxSumTRWS_Parameters< ValueType > parent
InferenceTermination arg(std::vector< LabelType > &out, const size_t=1) const
output a solution
TRWSi_Parameter< GM > Parameter
const bool & isAbsolutePrecision() const
bool canonicalNormalization_
static std::string getString(StructureType structure)
visitors::TimingVisitor< TRWSi< GM, ACC > > TimingVisitorType
FunctionParameters< GM > FactorProperties
bool & canonicalNormalization()
trws_base::MaxSumTRWS< GM, ACC > Solver