-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vn first multi #57
base: master
Are you sure you want to change the base?
Vn first multi #57
Conversation
if imbalance < new_imbalance { | ||
if new_imbalance <= imbalance { | ||
// The move decreases the partition imbalance. | ||
imbalance = new_imbalance; | ||
max_load = new_max_load; | ||
partition[i] = q; | ||
i_last = i; | ||
} else { | ||
// The move does not decrease the partition imbalance. | ||
part_loads[p] += weights[i].clone(); | ||
part_loads[q] = part_loads[p].clone() - weights[i].clone(); | ||
continue; | ||
} | ||
imbalance = new_imbalance; | ||
max_load = new_max_load; | ||
partition[i] = q; | ||
i_last = i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff is so that vnfirst does not make the move when T::partial_cmp(imbalance, new_imbalance)
returns None
(imbalance < new_imbalance
would return false
, thus making the move)
However, this means vnfirst only makes a move when there are gains on all criterion at once, which is overly restrictive.
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
==========================================
+ Coverage 50.25% 50.62% +0.36%
==========================================
Files 42 42
Lines 7223 7143 -80
==========================================
- Hits 3630 3616 -14
+ Misses 3593 3527 -66
Continue to review full report at Codecov.
|
Related to #54
It's just a proof of concept and not to be merged.
The current "mono" implementation of vnfirst can actually be used for multi-criteria partitioning, thanks to generic types.
This PR makes use of nalgebra's
SVector<T, const D: usize>
, a wrapper around[T; D]
that implements arithmetic operations andPartialOrd
to effectively feed vector of numbers to the mono-criterion implementation of vnfirst.It also turns out there were some mistakes made during the port from the aire-de-jeu. Those are fixed I think but I didn't have the motivation to split these changes into separate commits.
Limitations
Notably the
SVector
implementation ofPartialOrd
returns:Some(Greater)
/Some(Lesser)
/Some(Equal)
when all elements of the first vector are greater/lesser/equal to those of the other,None
otherwise,This is the reason why this if/else has been rewriten:
coupe/src/algorithms/vn/first.rs
Line 61 in 8d6e2c2
and also messes with
Itertools::minmax
calls, I think, where we want the min and the max loads across all criteria.