| 62 | |
| 63 | template <typename T> |
| 64 | std::vector<long> brute_force_max_cost_assignment ( |
| 65 | matrix<T> cost |
| 66 | ) |
| 67 | { |
| 68 | if (cost.size() == 0) |
| 69 | return std::vector<long>(); |
| 70 | |
| 71 | const std::vector<std::vector<long> >& perms = permutations(range(0,cost.nc()-1)); |
| 72 | |
| 73 | T best_cost = std::numeric_limits<T>::min(); |
| 74 | unsigned long best_idx = 0; |
| 75 | for (unsigned long i = 0; i < perms.size(); ++i) |
| 76 | { |
| 77 | const T temp = assignment_cost(cost, perms[i]); |
| 78 | if (temp > best_cost) |
| 79 | { |
| 80 | best_idx = i; |
| 81 | best_cost = temp; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return perms[best_idx]; |
| 86 | } |
| 87 | |
| 88 | // ---------------------------------------------------------------------------------------- |
| 89 | // ---------------------------------------------------------------------------------------- |
no test coverage detected