Accept new Phragmén solutions if they are epsilon better + Better pre-inclusion checks. (#6173)

* part1: Accept inly epsilon better solutions

* Fix pre-dispatch check

* Fix build

* review grumbles

* Epsilon -> Threshold
This commit is contained in:
Kian Paimani
2020-06-02 17:22:56 +02:00
committed by GitHub
parent 6547d7a09a
commit 0eec4bb795
14 changed files with 310 additions and 46 deletions
@@ -19,8 +19,8 @@
/// converts x into the range [a, b] in a pseudo-fair way.
pub fn to_range(x: usize, a: usize, b: usize) -> usize {
// does not work correctly if b < 2*a
assert!(b > 2 * a);
// does not work correctly if b < 2 * a
assert!(b >= 2 * a);
let collapsed = x % b;
if collapsed >= a {
collapsed
@@ -131,7 +131,7 @@ fn main() {
return;
}
let enhance = is_score_better(initial_score, final_score);
let enhance = is_score_better(final_score, initial_score, Perbill::zero());
println!(
"iter = {} // {:?} -> {:?} [{}]",
@@ -140,6 +140,7 @@ fn main() {
final_score,
enhance,
);
// if more than one iteration has been done, or they must be equal.
assert!(enhance || initial_score == final_score || i == 0)
});