2 #ifndef OPENGM_BRUTEFORCE_HXX 3 #define OPENGM_BRUTEFORCE_HXX 15 template<
class GM,
class ACC>
32 template<
class _GM,
class _ACC>
49 std::string
name()
const {
return "Brute-Force"; }
58 const GraphicalModelType& gm_;
60 std::vector<LabelType> states_;
63 template<
class GM,
class AKK>
70 states_(std::vector<typename GM::LabelType>(gm.numberOfVariables() )),
73 AKK::neutral(energy_);
76 template<
class GM,
class AKK>
81 std::fill(states_.begin(), states_.end(), 0);
82 AKK::neutral(energy_);
85 template<
class GM,
class AKK>
93 states_(std::vector<typename GM::LabelType>(gm.numberOfVariables())),
97 template<
class GM,
class AKK>
98 template<
class VISITOR>
105 std::vector<LabelType> states(gm_.numberOfVariables());
106 std::vector<IndexType> vi(gm_.numberOfVariables());
107 for(
size_t j=0; j<gm_.numberOfVariables(); ++j) {
111 AccumulationType::neutral(energy_);
112 bool exitInf =
false;
113 visitor.begin(*
this);
114 while(exitInf ==
false) {
115 ValueType energy = movemaker_.move(vi.begin(), vi.end(), states.begin());
116 if(AccumulationType::bop(energy , energy_)) {
119 AccumulationType::op(energy, energy_);
123 bool overflow =
true;
124 for(
size_t j=0; j<gm_.numberOfVariables(); ++j) {
125 if(
size_t(states[j]+1) <
size_t(gm_.numberOfLabels(j))) {
127 for(
size_t k=0; k<j; ++k) {
142 template<
class GM,
class AKK>
146 std::vector<LabelType>& states,
160 template<
class GM,
class ACC>
161 typename GM::ValueType
169 #endif // #ifndef OPENGM_BRUTEFORCE_HXX
virtual ValueType value() const
return the solution (value)
visitors::VerboseVisitor< Bruteforce< GM, ACC > > VerboseVisitorType
Bruteforce(const GraphicalModelType &)
InferenceTermination infer()
visitors::TimingVisitor< Bruteforce< GM, ACC > > TimingVisitorType
A fremework for move making algorithms.
visitors::EmptyVisitor< Bruteforce< GM, ACC > > EmptyVisitorType
Bruteforce< _GM, _ACC > type
Brute force inference algorithm.
Inference algorithm interface.
InferenceTermination arg(std::vector< LabelType > &, const size_t=1) const
output a solution
std::vector< LabelType >::const_iterator LabelIterator
Bruteforce< _GM, ACC > type
const GraphicalModelType & graphicalModel() const
#define OPENGM_GM_TYPE_TYPEDEFS
static const size_t ContinueInf
GraphicalModelType::ValueType ValueType