pub maxmem: usize,
}
-#[derive(Serialize, Deserialize)]
-#[serde(rename_all = "kebab-case")]
-/// Static usage information of an HA resource.
-pub struct StaticServiceUsage {
- /// Number of assigned CPUs or CPU limit.
- pub maxcpu: f64,
- /// Maximum assigned memory in bytes.
- pub maxmem: usize,
+impl StaticNodeUsage {
+ /// Add usage of `service` to the node's usage.
+ pub fn add_service_usage(&mut self, service: &StaticServiceUsage) {
+ self.cpu = add_cpu_usage(self.cpu, self.maxcpu as f64, service.maxcpu);
+ self.mem += service.maxmem;
+ }
}
/// Calculate new CPU usage in percent.
}
}
-impl StaticNodeUsage {
- /// Add usage of `service` to the node's usage.
- pub fn add_service_usage(&mut self, service: &StaticServiceUsage) {
- self.cpu = add_cpu_usage(self.cpu, self.maxcpu as f64, service.maxcpu);
- self.mem += service.maxmem;
- }
+#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
+/// Static usage information of an HA resource.
+pub struct StaticServiceUsage {
+ /// Number of assigned CPUs or CPU limit.
+ pub maxcpu: f64,
+ /// Maximum assigned memory in bytes.
+ pub maxmem: usize,
}
criteria_struct! {
/// A normalized array of `TopsisCriterion`.
pub struct TopsisCriteria<const N_CRITERIA: usize>([TopsisCriterion; N_CRITERIA]);
-/// A normalized matrix used for scoring with the TOPSIS algorithm.
-pub struct TopsisMatrix<const N_CRITERIA: usize>(Vec<[f64; N_CRITERIA]>);
-
-/// Idealized alternatives from a `TopsisMatrix`. That is, the alternative consisting of the best
-/// (respectively worst) value among the alternatives in the matrix for each single criterion.
-struct TopsisIdealAlternatives<const N_CRITERIA: usize> {
- best: [f64; N_CRITERIA],
- worst: [f64; N_CRITERIA],
-}
-
impl<const N: usize> TopsisCriteria<N> {
/// Create a new instance of normalized TOPSIS criteria.
///
}
}
+/// A normalized matrix used for scoring with the TOPSIS algorithm.
+pub struct TopsisMatrix<const N_CRITERIA: usize>(Vec<[f64; N_CRITERIA]>);
+
impl<const N: usize> TopsisMatrix<N> {
/// Values of the matrix for the fixed critierion with index `index`.
fn fixed_criterion(&self, index: usize) -> Vec<f64> {
}
}
+/// Idealized alternatives from a `TopsisMatrix`. That is, the alternative consisting of the best
+/// (respectively worst) value among the alternatives in the matrix for each single criterion.
+struct TopsisIdealAlternatives<const N_CRITERIA: usize> {
+ best: [f64; N_CRITERIA],
+ worst: [f64; N_CRITERIA],
+}
+
/// 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>(