| 856 | |
| 857 | template <typename prob_type> |
| 858 | void brute_force_potts_grid_problem( |
| 859 | const prob_type& prob, |
| 860 | array2d<unsigned char>& labels |
| 861 | ) |
| 862 | { |
| 863 | const unsigned long num = (unsigned long)std::pow(2.0, (double)prob.nr()*prob.nc()); |
| 864 | |
| 865 | array2d<unsigned char> temp(prob.nr(), prob.nc()); |
| 866 | unsigned char* data = &temp[0][0]; |
| 867 | |
| 868 | double best_score = -std::numeric_limits<double>::infinity(); |
| 869 | for (unsigned long i = 0; i < num; ++i) |
| 870 | { |
| 871 | for (unsigned long j = 0; j < temp.size(); ++j) |
| 872 | { |
| 873 | unsigned long T = (1)<<j; |
| 874 | T = (T&i); |
| 875 | if (T != 0) |
| 876 | *(data + j) = SINK_CUT; |
| 877 | else |
| 878 | *(data + j) = SOURCE_CUT; |
| 879 | } |
| 880 | |
| 881 | |
| 882 | double score = potts_model_score(prob, temp); |
| 883 | if (score > best_score) |
| 884 | { |
| 885 | best_score = score; |
| 886 | assign_image(labels, temp); |
| 887 | } |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | void test_inf() |
| 892 | { |
no test coverage detected