2 #ifndef OPENGM_BRUTEFORCE_HXX
3 #define OPENGM_BRUTEFORCE_HXX
15 template<
class GM,
class ACC>
30 std::string
name()
const {
return "Brute-Force"; }
39 const GraphicalModelType& gm_;
41 std::vector<LabelType> states_;
44 template<
class GM,
class AKK>
51 states_(std::vector<typename GM::LabelType>(gm.numberOfVariables() )),
54 AKK::neutral(energy_);
57 template<
class GM,
class AKK>
62 std::fill(states_.begin(), states_.end(), 0);
63 AKK::neutral(energy_);
66 template<
class GM,
class AKK>
69 const GraphicalModelType& gm,
74 states_(
std::vector<typename GM::
LabelType>(gm.numberOfVariables())),
75 energy_(typename
Bruteforce<GM, AKK>::ValueType())
78 template<
class GM,
class AKK>
79 template<
class VISITOR>
86 std::vector<LabelType> states(gm_.numberOfVariables());
87 std::vector<IndexType> vi(gm_.numberOfVariables());
88 for(
size_t j=0; j<gm_.numberOfVariables(); ++j) {
92 AccumulationType::neutral(energy_);
95 while(exitInf ==
false) {
96 ValueType energy = movemaker_.move(vi.begin(), vi.end(), states.begin());
97 if(AccumulationType::bop(energy , energy_)) {
100 AccumulationType::op(energy, energy_);
104 bool overflow =
true;
105 for(
size_t j=0; j<gm_.numberOfVariables(); ++j) {
106 if(
size_t(states[j]+1) <
size_t(gm_.numberOfLabels(j))) {
108 for(
size_t k=0; k<j; ++k) {
123 template<
class GM,
class AKK>
127 std::vector<LabelType>& states,
141 template<
class GM,
class ACC>
142 typename GM::ValueType
150 #endif // #ifndef OPENGM_BRUTEFORCE_HXX
visitors::VerboseVisitor< Bruteforce< GM, ACC > > VerboseVisitorType
const GraphicalModelType & graphicalModel() const
Bruteforce(const GraphicalModelType &)
virtual ValueType value() const
return the solution (value)
InferenceTermination infer()
visitors::TimingVisitor< Bruteforce< GM, ACC > > TimingVisitorType
A fremework for move making algorithms.
visitors::EmptyVisitor< Bruteforce< GM, ACC > > EmptyVisitorType
Brute force inference algorithm.
Inference algorithm interface.
std::vector< LabelType >::const_iterator LabelIterator
#define OPENGM_GM_TYPE_TYPEDEFS
static const size_t ContinueInf
InferenceTermination arg(std::vector< LabelType > &, const size_t=1) const
output a solution
GraphicalModelType::ValueType ValueType