mirror of
https://git.proxmox.com/git/proxmox-resource-scheduling
synced 2025-10-04 22:43:14 +00:00
make ideal_alternatives a method of IdealAlternatives
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
c83c8887c8
commit
4ac19a0016
@ -136,12 +136,10 @@ struct TopsisIdealAlternatives<const N_CRITERIA: usize> {
|
||||
worst: [f64; N_CRITERIA],
|
||||
}
|
||||
|
||||
impl<const N: usize> TopsisIdealAlternatives<N> {
|
||||
/// Compute the idealized alternatives from the given `matrix`. The `criteria` are required to know
|
||||
/// if a critierion should be maximized or minimized.
|
||||
fn ideal_alternatives<const N: usize>(
|
||||
matrix: &TopsisMatrix<N>,
|
||||
criteria: &TopsisCriteria<N>,
|
||||
) -> TopsisIdealAlternatives<N> {
|
||||
fn compute(matrix: &TopsisMatrix<N>, criteria: &TopsisCriteria<N>) -> Self {
|
||||
let criteria = &criteria.0;
|
||||
|
||||
let mut best = [0.0; N];
|
||||
@ -164,7 +162,8 @@ fn ideal_alternatives<const N: usize>(
|
||||
}
|
||||
}
|
||||
|
||||
TopsisIdealAlternatives { best, worst }
|
||||
Self { best, worst }
|
||||
}
|
||||
}
|
||||
|
||||
/// Scores the alternatives in `matrix` according to their similarity to the ideal worst
|
||||
@ -174,7 +173,7 @@ pub fn score_alternatives<const N: usize>(
|
||||
matrix: &TopsisMatrix<N>,
|
||||
criteria: &TopsisCriteria<N>,
|
||||
) -> Result<Vec<f64>, Error> {
|
||||
let ideal_alternatives = ideal_alternatives(matrix, criteria);
|
||||
let ideal_alternatives = TopsisIdealAlternatives::compute(matrix, criteria);
|
||||
let ideal_best = &ideal_alternatives.best;
|
||||
let ideal_worst = &ideal_alternatives.worst;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user