improve bmap sorting
This commit is contained in:
parent
8262bf29b2
commit
6faa2c0ae0
@ -17,11 +17,14 @@ HelpFlag help {
|
|||||||
parser, "help", "display this menu", {'h', "help"},
|
parser, "help", "display this menu", {'h', "help"},
|
||||||
};
|
};
|
||||||
|
|
||||||
ValueFlag<double> min {
|
ValueFlag<double> mid {
|
||||||
parser, "0.2", "minimum alter-probability to select", {"min"}, 0.4,
|
parser, "probability", "desired value of alter-probability to select", {"mid"}, 0.5,
|
||||||
};
|
};
|
||||||
ValueFlag<double> max {
|
ValueFlag<double> max_dist {
|
||||||
parser, "0.6", "maximum alter-probability to select", {"max"}, 0.6,
|
parser, "max distance", "maximum distance from mid value", {"max-dist"}, 0.2,
|
||||||
|
};
|
||||||
|
ValueFlag<uint32_t> min_bnum {
|
||||||
|
parser, "number of blocks", "minimum number of blocks to select (prior than max-dist)", {"min-bnum"}, 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace param
|
} // namespace param
|
||||||
@ -30,11 +33,25 @@ ValueFlag<double> max {
|
|||||||
static void Exec() {
|
static void Exec() {
|
||||||
const auto aprob = ReadMatrix<double>(std::cin);
|
const auto aprob = ReadMatrix<double>(std::cin);
|
||||||
|
|
||||||
|
const auto mid = args::get(param::mid);
|
||||||
|
const auto max_dist = args::get(param::max_dist);
|
||||||
|
const auto min_bnum = args::get(param::min_bnum);
|
||||||
|
|
||||||
|
std::vector<std::pair<size_t, double>> vec;
|
||||||
for (auto& probs : aprob) {
|
for (auto& probs : aprob) {
|
||||||
for (size_t i = 0; i < probs.size(); ++i) {
|
vec.reserve(probs.size());
|
||||||
if (args::get(param::min) <= probs[i] && probs[i] <= args::get(param::max)) {
|
vec.clear();
|
||||||
std::cout << i << ' ';
|
for (auto prob : probs) {
|
||||||
|
vec.emplace_back(vec.size(), std::abs(prob-mid));
|
||||||
}
|
}
|
||||||
|
std::sort(vec.begin(), vec.end(), [](auto& a, auto& b) { return a.second < b.second; });
|
||||||
|
|
||||||
|
Enforce(vec.size() >= min_bnum, "cannot satisfy min-bnum limitation");
|
||||||
|
for (auto itr = vec.begin(); itr < vec.end(); ++itr) {
|
||||||
|
if (itr >= vec.begin()+min_bnum) { // min-bnum is satisfied
|
||||||
|
if (itr->second > max_dist) break; // max-dist is unsatisfied
|
||||||
|
}
|
||||||
|
std::cout << itr->first << ' ';
|
||||||
}
|
}
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user