|
17 | 17 | #include<algorithm> |
18 | 18 | #include<boost/functional/hash.hpp>// For boost::hash_range |
19 | 19 | #include<cassert> |
| 20 | +#include<cstdint> |
20 | 21 | #include<functional>// For std::hash (though not strictly necessary here, but good practice) |
21 | 22 | #include<iostream> |
22 | 23 |
|
@@ -85,24 +86,26 @@ bool Node::operator>(const Node& other) const { |
85 | 86 | doubleTesseractDecoder::get_detcost( |
86 | 87 | size_t d,const std::vector<DetectorCostTuple>& detector_cost_tuples)const { |
87 | 88 | double min_cost = INF; |
| 89 | +uint32_t min_det_cost = std::numeric_limits<uint32_t>::infinity(); |
88 | 90 | double error_cost; |
89 | 91 | ErrorCost ec; |
90 | 92 | DetectorCostTuple dct; |
91 | 93 |
|
92 | 94 | for (int ei : d2e[d]) { |
93 | 95 | ec = error_costs[ei]; |
94 | | -if (ec.min_cost>= min_cost)break; |
| 96 | +if (ec.likelihood_cost * min_det_cost>= min_cost * errors[ei].symptom.detectors.size())break; |
95 | 97 |
|
96 | 98 | dct = detector_cost_tuples[ei]; |
97 | 99 | if (!dct.error_blocked) { |
98 | | - error_cost = ec.likelihood_cost / dct.detectors_count; |
99 | | -if (error_cost < min_cost) { |
| 100 | + error_cost = ec.likelihood_cost; |
| 101 | +if (ec.likelihood_cost < min_cost * dct.detectors_count) { |
100 | 102 | min_cost = error_cost; |
| 103 | + min_det_cost = dct.detectors_count; |
101 | 104 | } |
102 | 105 | } |
103 | 106 | } |
104 | 107 |
|
105 | | -return min_cost + config.det_penalty; |
| 108 | +return(min_cost / min_det_cost) + config.det_penalty; |
106 | 109 | } |
107 | 110 |
|
108 | 111 | TesseractDecoder::TesseractDecoder(TesseractConfig config_) : config(config_) { |
|