MCPcopy Create free account
hub / github.com/davisking/dlib / brute_force_potts_model

Function brute_force_potts_model

dlib/test/graph_cuts.cpp:313–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311
312 template <typename potts_model>
313 void brute_force_potts_model (
314 potts_model& g
315 )
316 {
317 potts_model m(g);
318
319 const unsigned long num = (unsigned long)std::pow(2.0, (double)m.number_of_nodes());
320
321 double best_score = -std::numeric_limits<double>::infinity();
322 for (unsigned long i = 0; i < num; ++i)
323 {
324 for (unsigned long j = 0; j < m.number_of_nodes(); ++j)
325 {
326 unsigned long T = (1)<<j;
327 T = (T&i);
328 if (T != 0)
329 m.set_label(j,SINK_CUT);
330 else
331 m.set_label(j,SOURCE_CUT);
332 }
333
334
335 double score = potts_model_score(m);
336 if (score > best_score)
337 {
338 best_score = score;
339 g = m;
340 }
341 }
342 }
343
344// ----------------------------------------------------------------------------------------
345

Callers 1

impl_test_potts_modelFunction · 0.85

Calls 3

potts_model_scoreFunction · 0.85
number_of_nodesMethod · 0.45
set_labelMethod · 0.45

Tested by

no test coverage detected