8 #ifndef SMOOTHING_STRATEGY_HXX_ 9 #define SMOOTHING_STRATEGY_HXX_ 17 template<
class VALUETYPE>
29 else if (name.compare(
"FIXED")==0)
return FIXED;
33 static std::string
getString(SmoothingStrategyType strategytype)
41 case FIXED:
return std::string(
"FIXED");
42 default:
return std::string(
"UNKNOWN");
47 ValueType smoothingValue=0.0,
48 ValueType smoothingDecayMultiplier=-1.0,
49 ValueType precision=0,
81 bool lazyLPPrimalBoundComputation,
82 const SmoothingParametersType& smoothingParameters,
83 const SumProdSolverParametersType& sumProdSolverParameters,
84 const MaxSumSolverParametersType& maxSumSolverParameters,
85 const PrimalLPEstimatorParametersType& primalLPEstimatorParameters):
86 decompositionType_(decompositionType),
87 lazyLPPrimalBoundComputation_(lazyLPPrimalBoundComputation),
88 smoothingParameters_(smoothingParameters),
89 sumProdSolverParameters_(sumProdSolverParameters),
90 maxSumSolverParameters_(maxSumSolverParameters),
91 primalLPEstimatorParameters_(primalLPEstimatorParameters)
123 ValueType precision=1.0,
124 bool absolutePrecision=
true,
125 size_t numOfInternalIterations=3,
126 typename Storage::StructureType decompositionType=Storage::GENERALSTRUCTURE,
127 ValueType smoothingGapRatio=4,
128 ValueType startSmoothingValue=0.0,
129 ValueType primalBoundPrecision=std::numeric_limits<ValueType>::epsilon(),
130 size_t maxPrimalBoundIterationNumber=100,
131 size_t presolveMaxIterNumber=100,
132 bool canonicalNormalization=
true,
133 ValueType presolveMinRelativeDualImprovement=0.01,
134 bool lazyLPPrimalBoundComputation=
true,
135 ValueType smoothingDecayMultiplier=-1.0,
136 SmoothingStrategyType smoothingStrategy=SmoothingParametersType::ADAPTIVE_DIMINISHING,
138 bool fastComputations=
true,
141 :parent(decompositionType,
142 lazyLPPrimalBoundComputation,
143 SmoothingParametersType(smoothingGapRatio,startSmoothingValue,smoothingDecayMultiplier,precision,smoothingStrategy),
145 SumProdSolverParametersType(numOfInternalIterations,startSmoothingValue,precision,absolutePrecision,0.0,fastComputations,canonicalNormalization),
146 MaxSumSolverParametersType(presolveMaxIterNumber,precision,absolutePrecision,presolveMinRelativeDualImprovement,fastComputations,canonicalNormalization),
147 PrimalLPEstimatorParametersType(primalBoundPrecision,maxPrimalBoundIterationNumber)
149 numOfExternalIterations_(numOfExternalIterations),
166 const ValueType&
precision()
const{
return parent::sumProdSolverParameters_.precision_;}
167 void setPrecision(ValueType precision){parent::maxSumSolverParameters_.precision_=parent::sumProdSolverParameters_.precision_=parent::smoothingParameters_.precision_=precision;}
173 const ValueType&
smoothingGapRatio()
const{
return parent::smoothingParameters_.smoothingGapRatio_;}
186 SmoothingStrategyType&
smoothingStrategy(){
return parent::smoothingParameters_.smoothingStrategy_;}
187 const SmoothingStrategyType&
smoothingStrategy()
const{
return parent::smoothingParameters_.smoothingStrategy_;}
190 const typename Storage::StructureType&
decompositionType()
const{
return parent::decompositionType_;}
193 void setStartSmoothingValue(ValueType val){ parent::smoothingParameters_.smoothingValue_=parent::sumProdSolverParameters_.smoothingValue_=val;}
195 const bool&
fastComputations()
const{
return parent::sumProdSolverParameters_.fastComputations_;}
196 void setFastComputations(
bool fast){parent::sumProdSolverParameters_.fastComputations_=parent::maxSumSolverParameters_.fastComputations_=fast;}
199 void setCanonicalNormalization(
bool canonical){parent::sumProdSolverParameters_.canonicalNormalization_=parent::maxSumSolverParameters_.canonicalNormalization_=canonical;}
222 #ifdef TRWS_DEBUG_OUTPUT 223 void print(std::ostream& fout)
const 225 fout <<
"maxNumberOfIterations="<< maxNumberOfIterations()<<std::endl;
226 fout <<
"numberOfInternalIterations="<< numberOfInternalIterations()<<std::endl;
227 fout <<
"precision=" <<precision()<<std::endl;
228 fout <<
"isAbsolutePrecision=" << isAbsolutePrecision()<< std::endl;
229 fout <<
"smoothingGapRatio=" << smoothingGapRatio()<< std::endl;
230 fout <<
"lazyLPPrimalBoundComputation="<<lazyLPPrimalBoundComputation()<< std::endl;
231 fout <<
"smoothingDecayMultiplier=" << smoothingDecayMultiplier()<< std::endl;
233 fout <<
"smoothing strategy="<<SmoothingParametersType::getString(smoothingStrategy())<<std::endl;
234 fout <<
"decompositionType=" << Storage::getString(decompositionType()) << std::endl;
236 fout <<
"startSmoothingValue=" << startSmoothingValue()<<std::endl;
237 fout <<
"fastComputations="<<fastComputations()<<std::endl;
238 fout <<
"canonicalNormalization="<<canonicalNormalization()<<std::endl;
243 fout <<
"maxNumberOfPresolveIterations="<<maxNumberOfPresolveIterations()<<std::endl;
244 fout <<
"presolveMinRelativeDualImprovement=" <<presolveMinRelativeDualImprovement()<<std::endl;
249 fout <<
"maxPrimalBoundIterationNumber="<<maxPrimalBoundIterationNumber()<<std::endl;
250 fout <<
"primalBoundRelativePrecision=" <<primalBoundRelativePrecision()<<std::endl;
251 fout <<
"verbose="<<verbose()<<std::endl;
259 template<
class GM,
class ACC>
262 template<
class GM,
class ACC>
271 SmoothingStrategy(ValueType smoothingMultiplier,
const Parameter& param=Parameter(), std::ostream& fout=std::cout):
273 _initializationStage(true),
274 _smoothingMultiplier(smoothingMultiplier),
276 _oracleCallsCounter(0){};
279 ValueType primalBound,
280 ValueType dualBound){
282 return _InitAdaptiveSmoothing(smoothInference,primalBound,dualBound,getStartingSmoothing(primalBound,dualBound));
285 ValueType primalBound,
287 ValueType smoothDualBound,
288 ValueType smoothingDerivative,
289 size_t iterationCounter)
291 if (SmoothingMustBeDecreased(smoothingValue,primalBound,dualBound,smoothDualBound,smoothingDerivative,iterationCounter))
293 smoothingValue= std::max((ValueType)(smoothingValue/2.0),SmoothingEstimateValue(primalBound,smoothDualBound,smoothingDerivative));
295 #ifdef TRWS_DEBUG_OUTPUT 296 _fout <<
"Smoothing decreased to = "<<smoothingValue<<std::endl;
299 return smoothingValue;
303 ValueType primalBound,
305 ValueType smoothDualBound,
306 ValueType smoothingDerivative,
307 size_t iterationCounter)
309 ValueType rhs=fabs(primalBound-smoothDualBound);
311 return (smoothingValue > SmoothingEstimateValue(primalBound,smoothDualBound,smoothingDerivative));
317 template<
class DualDecompositionStorage >
321 typename DualDecompositionStorage::LabelType numOfLabels=0;
322 for (
size_t i=0;i<storage.numberOfSharedVariables();++i)
323 numOfLabels=std::max(numOfLabels,storage.numberOfLabels(i));
326 ValueType multiplier=0;
327 ValueType logLabels=log((ValueType)numOfLabels);
328 for (
size_t i=0;i<storage.numberOfModels();++i)
329 multiplier+=storage.size(i)*logLabels;
336 virtual ValueType SmoothingEstimateValue(
337 ValueType primalBound,
338 ValueType smoothDualBound,
339 ValueType smoothingDerivative)
const=0;
343 if (_parameters.smoothingValue_ > 0 )
344 return _parameters.smoothingValue_;
346 return SmoothingEstimateValue(primalBound,dualBound,_smoothingMultiplier);
354 ValueType primalBound,
356 ValueType initialSmoothing);
365 template<
class GM,
class ACC>
368 ValueType primalBound,
372 #ifdef TRWS_DEBUG_OUTPUT 373 _fout <<
"_maxsumsolver.value()="<<primalBound<<
", _maxsumsolver.bound()="<<dualBound<<std::endl;
374 _fout <<
"Initial smoothing="<<smoothing<<std::endl;
377 ValueType derivativeValue;
380 _oracleCallsCounter=1;
382 ++_oracleCallsCounter;
384 #ifdef TRWS_DEBUG_OUTPUT 385 _fout <<
"test smoothing = "<<smoothing<<std::endl;
388 #ifdef TRWS_DEBUG_OUTPUT 389 _fout <<
"smoothDualBound="<<smoothDualBound<<std::endl;
391 }
while (!SmoothingMustBeDecreased(smoothing,primalBound,dualBound,smoothDualBound,derivativeValue,0));
395 #ifdef TRWS_DEBUG_OUTPUT 396 _fout <<
"Smoothing := "<<smoothing<<std::endl;
398 _initializationStage=
false;
404 template<
class GM,
class ACC>
415 :parent(smoothingMultiplier,param,fout)
417 if (param.smoothingValue_ > 0 )
418 throw std::runtime_error(
"WorstCasePrecisionOrientedSmoothing()::WorstCasePrecisionOrientedSmoothing(): Error! Starting smoothing value can not be selected manually! parameter.smoothingValue_ must be<0.");
421 ValueType primalBound,
422 ValueType smoothDualBound,
423 ValueType smoothingDerivative)
const 424 {
return parent::getWorstCaseSmoothing();}
429 template<
class GM,
class ACC>
442 ValueType smoothDualBound,
443 ValueType smoothingDerivative)
const 444 {
return parent::_parameters.precision_/2.0/fabs(smoothingDerivative);}
450 template<
class GM,
class ACC>
460 WorstCaseDiminishingSmoothing(ValueType smoothingMultiplier,
const Parameter& param=Parameter(), std::ostream& fout=std::cout):parent(smoothingMultiplier,param,fout){};
463 ValueType primalBound,
464 ValueType smoothDualBound,
465 ValueType smoothingDerivative)
const 466 {
return fabs(primalBound-smoothDualBound)/parent::_parameters.smoothingGapRatio_/fabs(parent::_smoothingMultiplier);}
472 template<
class GM,
class ACC>
483 :parent(smoothingMultiplier,param,fout){};
486 ValueType primalBound,
487 ValueType smoothDualBound,
488 ValueType smoothingDerivative)
const 489 {
return fabs(primalBound-smoothDualBound)/parent::_parameters.smoothingGapRatio_/fabs(smoothingDerivative);}
494 template<
class GM,
class ACC>
504 FixedSmoothing(ValueType smoothingMultiplier,
const Parameter& param=Parameter(), std::ostream& fout=std::cout)
505 :parent(smoothingMultiplier,param,fout)
507 if (param.smoothingValue_ <= 0 )
508 throw std::runtime_error(
"FixedSmoothing()::FixedSmoothing(): Smoothing value must be positive!");
512 ValueType smoothDualBound,
513 ValueType smoothingDerivative)
const 514 {
return parent::_parameters.smoothingValue_;}
518 template<
class GM,
class ACC>
539 #ifdef TRWS_DEBUG_OUTPUT
540 ,std::ostream& fout=std::cout
544 _storage(gm,param.decompositionType_),
545 _sumprodsolver(_storage,param.getSumProdSolverParameters()
546 #ifdef TRWS_DEBUG_OUTPUT
550 _maxsumsolver(_storage,param.getMaxSumSolverParameters()
551 #ifdef TRWS_DEBUG_OUTPUT
555 _estimator(gm,param.getPrimalLPEstimatorParameters()),
556 #ifdef TRWS_DEBUG_OUTPUT
559 _bestPrimalLPbound(ACC::template neutral<ValueType>()),
560 _bestPrimalBound(ACC::template neutral<ValueType>()),
561 _bestDualBound(ACC::template ineutral<ValueType>()),
562 _bestIntegerBound(ACC::template neutral<ValueType>()),
563 _bestIntegerLabeling(_storage.masterModel().numberOfVariables(),0.0)
565 ValueType smoothingMultiplier=SmoothingStrategyType::ComputeSmoothingMultiplier(_storage);
567 if ( (param.smoothingStrategy()==Parameter::SmoothingParametersType::WC_PRECISIONORIENTED) ||
568 (param.smoothingStrategy()==Parameter::SmoothingParametersType::ADAPTIVE_PRECISIONORIENTED))
569 if (!param.isAbsolutePrecision())
570 throw std::runtime_error(
"SmoothingBasedInference: Error: relative precision can be used only with diminishing smoothing.");
572 switch (param.smoothingStrategy())
574 case Parameter::SmoothingParametersType::ADAPTIVE_DIMINISHING:
576 #ifdef TRWS_DEBUG_OUTPUT 581 case Parameter::SmoothingParametersType::WC_DIMINISHING:
583 #ifdef TRWS_DEBUG_OUTPUT 588 case Parameter::SmoothingParametersType::ADAPTIVE_PRECISIONORIENTED:
590 #ifdef TRWS_DEBUG_OUTPUT 595 case Parameter::SmoothingParametersType::WC_PRECISIONORIENTED:
597 #ifdef TRWS_DEBUG_OUTPUT 602 case Parameter::SmoothingParametersType::FIXED:
604 #ifdef TRWS_DEBUG_OUTPUT 609 default:
throw std::runtime_error(
"SmoothingBasedInference: Error: Unknown smoothing strategy type");
616 {out = _bestIntegerLabeling;
618 const GraphicalModelType&
graphicalModel()
const {
return _storage.masterModel(); }
620 ValueType
bound()
const{
return _bestDualBound;}
621 ValueType
value()
const{
return _bestIntegerBound;}
623 ValueType UpdateSmoothDualEstimates(ValueType smoothingValue,ValueType* pderivativeValue);
625 void getTreeAgreement(std::vector<bool>& out,std::vector<LabelType>* plabeling=0,std::vector<std::vector<LabelType> >* ptreeLabelings=0){_maxsumsolver.getTreeAgreement(out,plabeling,ptreeLabelings);}
630 {
return new ReparametrizerType(_storage,_maxsumsolver.getFactorProperties(),params);}
634 _marginalsTemp.resize(_storage.numberOfLabels(varID));
635 _sumprodsolver.GetMarginals(varID, _marginalsTemp.begin());
637 out.assign(graphicalModel(), &varID, &varID+1, ACC::template neutral<ValueType>());
639 out(i)=_marginalsTemp[i];
643 template<
class VISITOR>
645 template<
class VISITOR>
646 size_t _EstimateStartingSmoothing(VISITOR& visitor);
647 bool _UpdateSmoothing(ValueType primalBound,ValueType dualBound, ValueType smoothDualBound, ValueType derivativeValue,
size_t iterationCounterPlus1=0);
648 ValueType _EstimateRhoDerivative()
const;
650 void _UpdatePrimalEstimator();
651 void _SelectOptimalBoundsAndLabeling();
652 bool _isLPBoundComputed()
const;
660 #ifdef TRWS_DEBUG_OUTPUT 678 template<
class GM,
class ACC>
682 _sumprodsolver.SetSmoothing(smoothingValue);
683 _sumprodsolver.ForwardMove();
684 _sumprodsolver.GetMarginalsAndDerivativeMove();
685 *pderivativeValue=_EstimateRhoDerivative();
686 return _sumprodsolver.bound();
689 template<
class GM,
class ACC>
690 template<
class VISITOR>
693 ValueType smoothingValue= psmoothingStrategy->InitSmoothing(*
this,_maxsumsolver.value(),_maxsumsolver.bound());
694 _sumprodsolver.SetSmoothing(smoothingValue);
695 return psmoothingStrategy->getOracleCallsCounter();
698 template<
class GM,
class ACC>
701 ValueType newSmoothing=psmoothingStrategy->UpdateSmoothing(_sumprodsolver.GetSmoothing(),primalBound,dualBound,smoothDualBound,derivativeValue,iterationCounterPlus1-1);
702 if (newSmoothing != _sumprodsolver.GetSmoothing())
704 _sumprodsolver.SetSmoothing(newSmoothing);
711 template<
class GM,
class ACC>
715 ValueType derivative=0.0;
717 for (
size_t i=0;i<_storage.numberOfModels();++i)
721 ACC::op(_sumprodsolver.getDerivative(i),(_sumprodsolver.getBound(i)-_maxsumsolver.getBound(i))/_sumprodsolver.GetSmoothing(),delta);
729 template<
class GM,
class ACC>
732 std::pair<ValueType,ValueType> bestNorms=std::make_pair((ValueType)0.0,(ValueType)0.0);
733 ValueType numberOfVariables=_storage.masterModel().numberOfVariables();
734 for (
IndexType var=0;var<numberOfVariables;++var)
736 _marginalsTemp.resize(_storage.numberOfLabels(var));
737 std::pair<ValueType,ValueType> norms=_sumprodsolver.GetMarginals(var, _marginalsTemp.begin());
739 bestNorms.second=std::max(bestNorms.second,norms.second);
740 bestNorms.first+=norms.first*norms.first;
745 _estimator.setVariable(var,_marginalsTemp.begin());
747 #ifdef TRWS_DEBUG_OUTPUT 748 _fout <<
"l2 gradient norm="<<sqrt(bestNorms.first)<<
", "<<
"l_inf gradient norm="<<bestNorms.second<<std::endl;
752 template<
class GM,
class ACC>
756 if (ACC::bop(_sumprodsolver.value(),_maxsumsolver.value()))
758 _bestIntegerLabeling=_sumprodsolver.arg();
759 _bestIntegerBound=_sumprodsolver.value();
762 _bestIntegerLabeling=_maxsumsolver.arg();
763 _bestIntegerBound=_maxsumsolver.value();
767 ACC::op(_bestPrimalLPbound,_bestIntegerBound,_bestPrimalBound);
768 #ifdef TRWS_DEBUG_OUTPUT 769 _fout <<
"_bestPrimalBound=" <<_bestPrimalBound<<std::endl;
773 if (ACC::ibop(_sumprodsolver.bound(),_maxsumsolver.bound()))
774 _bestDualBound=_sumprodsolver.bound();
776 _bestDualBound=_maxsumsolver.bound();
780 template<
class GM,
class ACC>
781 template<
class VISITOR>
784 #ifdef TRWS_DEBUG_OUTPUT 785 _fout <<
"Running TRWS presolve..."<<std::endl;
787 return _maxsumsolver.infer_visitor_updates(visitor,piterCounter);
790 template<
class GM,
class ACC>
793 return (!_parameters.lazyLPPrimalBoundComputation_ || !ACC::bop(_sumprodsolver.value(),_bestPrimalBound) );
796 template<
class GM,
class ACC>
799 if( _isLPBoundComputed())
801 _UpdatePrimalEstimator();
803 ACC::op(_estimator.getTotalValue(),_bestPrimalLPbound);
804 #ifdef TRWS_DEBUG_OUTPUT 805 _fout <<
"_primalLPbound=" <<_estimator.getTotalValue()<<std::endl;
808 _SelectOptimalBoundsAndLabeling();
810 if (_maxsumsolver.CheckTreeAgreement(preturncode))
return true;
812 if (_sumprodsolver.CheckDualityGap(_bestPrimalBound,_maxsumsolver.bound()))
814 #ifdef TRWS_DEBUG_OUTPUT 815 _fout <<
"SmoothingBasedInference::_CheckStoppingCondition(): Precision attained! Problem solved!"<<std::endl;
void setStartSmoothingValue(ValueType val)
ValueType smoothingGapRatio_
const size_t & numberOfInternalIterations() const
SmoothingStrategy(ValueType smoothingMultiplier, const Parameter ¶m=Parameter(), std::ostream &fout=std::cout)
std::vector< LabelType > _bestIntegerLabeling
virtual ~SmoothingStrategy()
const ValueType & smoothingGapRatio() const
SmoothingBasedInference_Parameter< GM > Parameter
size_t & maxNumberOfIterations()
const size_t & maxNumberOfPresolveIterations() const
parent::MaxSumSolverParametersType MaxSumSolverParametersType
ReparametrizerType * getReparametrizer(const typename ReparametrizerType::Parameter ¶ms=typename ReparametrizerType::Parameter())
ValueType smoothingDecayMultiplier_
virtual ValueType SmoothingEstimateValue(ValueType primalBound, ValueType smoothDualBound, ValueType smoothingDerivative) const
void _SelectOptimalBoundsAndLabeling()
const ValueType & smoothingDecayMultiplier() const
void setPrecision(ValueType precision)
ValueType InitSmoothing(SmoothingBasedInference< GM, ACC > &smoothInference, ValueType primalBound, ValueType dualBound)
void _UpdatePrimalEstimator()
AdaptivePrecisionOrientedSmoothing(ValueType smoothingMultiplier, const Parameter ¶m=Parameter(), std::ostream &fout=std::cout)
trws_base::DecompositionStorage< GM > Storage
SumProdSolver::OutputContainerType _marginalsTemp
SmoothingParameters< ValueType > Parameter
ValueType & smoothingDecayMultiplier()
MaxSumSolver _maxsumsolver
Inference< GM, ACC > parent
SmoothingStrategy< GM, ACC > parent
Storage::StructureType & decompositionType()
ValueType smoothingValue_
bool _CheckStoppingCondition(InferenceTermination *)
SmoothingStrategyType & smoothingStrategy()
bool & lazyLPPrimalBoundComputation()
ValueType _smoothingMultiplier
ValueType bound() const
return a bound on the solution
ValueType _InitAdaptiveSmoothing(SmoothingBasedInference< GM, ACC > &smoothInference, ValueType primalBound, ValueType dualBound, ValueType initialSmoothing)
size_t getOracleCallsCounter() const
bool _isLPBoundComputed() const
const SmoothingStrategyType & smoothingStrategy() const
virtual ~SmoothingBasedInference()
SmoothingParametersType smoothingParameters_
size_t & maxPrimalBoundIterationNumber()
parent::SumProdSolverParametersType SumProdSolverParametersType
SmoothingParameters< ValueType > Parameter
trws_base::SmoothingBasedInference_Parameter_Base< GM > parent
SmoothingParameters< ValueType > SmoothingParametersType
const ValueType & primalBoundRelativePrecision() const
const bool & canonicalNormalization() const
SumProdSolver _sumprodsolver
SmoothingParametersType::SmoothingStrategyType SmoothingStrategyType
SmoothingParameters< ValueType > Parameter
const SumProdSolverParametersType & getSumProdSolverParameters() const
Storage & getDecompositionStorage()
parent::PrimalLPEstimatorParametersType PrimalLPEstimatorParametersType
ValueType & smoothingGapRatio()
SmoothingStrategyType * psmoothingStrategy
ValueType _EstimateRhoDerivative() const
ValueType SmoothingEstimateValue(ValueType primalBound, ValueType smoothDualBound, ValueType smoothingDerivative) const
size_t numOfExternalIterations_
InputIterator transform_inplace(InputIterator first, InputIterator last, UnaryOperator op)
PrimalBoundEstimator _estimator
WorstCaseDiminishingSmoothing(ValueType smoothingMultiplier, const Parameter ¶m=Parameter(), std::ostream &fout=std::cout)
bool lazyLPPrimalBoundComputation_
const Storage::StructureType & decompositionType() const
virtual ~SmoothingBasedInference_Parameter_Base()
ValueType & primalBoundRelativePrecision()
DecompositionStorage< GM > Storage
ValueType _bestPrimalLPbound
MaxSumSolverParametersType maxSumSolverParameters_
MaxSumTRWS_Parameters< ValueType > MaxSumSolverParametersType
SumProdTRWS_Parameters< ValueType > SumProdSolverParametersType
ValueType getStartingSmoothing(ValueType primalBound, ValueType dualBound) const
ValueType UpdateSmoothDualEstimates(ValueType smoothingValue, ValueType *pderivativeValue)
GraphicalModelType::IndexType IndexType
const GraphicalModelType & graphicalModel() const
const SmoothingParametersType & getSmoothingParameters() const
trws_base::DecompositionStorage< GM > Storage
size_t _EstimateStartingSmoothing(VISITOR &visitor)
const ValueType & precision() const
ValueType _bestPrimalBound
ValueType SmoothingEstimateValue(ValueType primalBound, ValueType smoothDualBound, ValueType smoothingDerivative) const
ValueType & presolveMinRelativeDualImprovement()
size_t & numberOfInternalIterations()
SmoothingStrategy< GM, ACC > parent
SmoothingBasedInference_Parameter_Base(typename Storage::StructureType decompositionType, bool lazyLPPrimalBoundComputation, const SmoothingParametersType &smoothingParameters, const SumProdSolverParametersType &sumProdSolverParameters, const MaxSumSolverParametersType &maxSumSolverParameters, const PrimalLPEstimatorParametersType &primalLPEstimatorParameters)
const bool & fastComputations() const
GraphicalModelType::ValueType ValueType
FixedSmoothing(ValueType smoothingMultiplier, const Parameter ¶m=Parameter(), std::ostream &fout=std::cout)
InferenceTermination arg(std::vector< LabelType > &out, const size_t=1) const
output a solution
ValueType SmoothingEstimateValue(ValueType primalBound, ValueType smoothDualBound, ValueType smoothingDerivative) const
Inference algorithm interface.
InferenceTermination marginal(const IndexType varID, IndependentFactorType &out)
size_t & maxNumberOfPresolveIterations()
PrimalLPEstimatorParametersType primalLPEstimatorParameters_
PrimalLPBound< GM, ACC > PrimalBoundEstimator
ValueType value() const
return the solution (value)
SmoothingStrategy< GM, ACC > parent
T _Normalize(Iterator begin, Iterator end, T initialValue)
bool SmoothingMustBeDecreased(ValueType smoothingValue, ValueType primalBound, ValueType dualBound, ValueType smoothDualBound, ValueType smoothingDerivative, size_t iterationCounter)
ValueType getWorstCaseSmoothing() const
SumProdSolverParametersType sumProdSolverParameters_
trws_base::SumProdTRWS< GM, ACC > SumProdSolver
SmoothingParameters< ValueType > Parameter
ValueType _bestIntegerBound
bool _UpdateSmoothing(ValueType primalBound, ValueType dualBound, ValueType smoothDualBound, ValueType derivativeValue, size_t iterationCounterPlus1=0)
returns number of oracle calls;
SmoothingStrategy< GM, ACC > SmoothingStrategyType
bool _initializationStage
SmoothingStrategy< GM, ACC > parent
SmoothingStrategy< GM, ACC > parent
parent::OutputContainerType OutputContainerType
InferenceTermination _Presolve(VISITOR &visitor, size_t *piterCounter=0)
const bool & isAbsolutePrecision() const
PrimalLPBound_Parameter< ValueType > PrimalLPEstimatorParametersType
ValueType SmoothingEstimateValue(ValueType primalBound, ValueType smoothDualBound, ValueType smoothingDerivative) const
SmoothingParameters< ValueType > Parameter
const bool & verbose() const
void setCanonicalNormalization(bool canonical)
SmoothingParameters(ValueType smoothingGapRatio=4, ValueType smoothingValue=0.0, ValueType smoothingDecayMultiplier=-1.0, ValueType precision=0, SmoothingStrategyType smoothingStrategy=ADAPTIVE_DIMINISHING)
static std::string getString(SmoothingStrategyType strategytype)
WorstCasePrecisionOrientedSmoothing(ValueType smoothingMultiplier, const Parameter ¶m=Parameter(), std::ostream &fout=std::cout)
SmoothingBasedInference(const GraphicalModelType &gm, const Parameter ¶m)
const size_t & maxPrimalBoundIterationNumber() const
const ValueType & startSmoothingValue() const
ValueType _FastEstimateRhoDerivative() const
bool & isAbsolutePrecision()
const MaxSumSolverParametersType & getMaxSumSolverParameters() const
size_t _oracleCallsCounter
TRWS_Reparametrizer< Storage, ACC > ReparametrizerType
GraphicalModelType::LabelType LabelType
static ValueType ComputeSmoothingMultiplier(const DualDecompositionStorage &storage)
const MaxSumSolver::FactorProperties & getFactorProperties() const
static SmoothingStrategyType getSmoothingStrategyType(const std::string &name)
const ValueType & presolveMinRelativeDualImprovement() const
ValueType UpdateSmoothing(ValueType smoothingValue, ValueType primalBound, ValueType dualBound, ValueType smoothDualBound, ValueType smoothingDerivative, size_t iterationCounter)
const size_t & maxNumberOfIterations() const
void setFastComputations(bool fast)
const PrimalLPEstimatorParametersType & getPrimalLPEstimatorParameters() const
trws_base::MaxSumTRWS< GM, ACC > MaxSumSolver
SmoothingStrategyType smoothingStrategy_
AdaptiveDiminishingSmoothing(ValueType smoothingMultiplier, const Parameter ¶m=Parameter(), std::ostream &fout=std::cout)
FunctionParameters< GM > FactorProperties
SmoothingBasedInference_Parameter(size_t numOfExternalIterations=0, ValueType precision=1.0, bool absolutePrecision=true, size_t numOfInternalIterations=3, typename Storage::StructureType decompositionType=Storage::GENERALSTRUCTURE, ValueType smoothingGapRatio=4, ValueType startSmoothingValue=0.0, ValueType primalBoundPrecision=std::numeric_limits< ValueType >::epsilon(), size_t maxPrimalBoundIterationNumber=100, size_t presolveMaxIterNumber=100, bool canonicalNormalization=true, ValueType presolveMinRelativeDualImprovement=0.01, bool lazyLPPrimalBoundComputation=true, ValueType smoothingDecayMultiplier=-1.0, SmoothingStrategyType smoothingStrategy=SmoothingParametersType::ADAPTIVE_DIMINISHING, bool fastComputations=true, bool verbose=false)
[class primallpbound] PrimalLPBound - estimating primal local polytope bound and feasible primal solu...
SmoothingParameters< ValueType > Parameter
void getTreeAgreement(std::vector< bool > &out, std::vector< LabelType > *plabeling=0, std::vector< std::vector< LabelType > > *ptreeLabelings=0)
parent::SmoothingParametersType SmoothingParametersType
GraphicalModelType::IndependentFactorType IndependentFactorType
const bool & lazyLPPrimalBoundComputation() const