aggregation

Function aggregation 

Source
pub fn aggregation<KI, KV>(
    rules: &[Rule],
    input: &HashMap<KI, Float>,
    vars: &HashMap<KV, Variable>,
    sampler: &UniformSampler,
) -> Result<HashMap<String, Vec<Float>>>
where KI: Eq + Hash + Borrow<str>, KV: Eq + Hash + Borrow<str>,
Expand description

Aggregate the contributions of all rules into output membership functions.

For each Rule, this function computes its activation (Rule::activation) from input and vars, applies implication (Rule::implicate) to obtain output membership sample vectors, then merges those vectors into a single map keyed by output variable name using pointwise maxima.

Type parameters and bounds:

  • KI: key type for the input map (must borrow as str) — e.g., &str, String, or Arc<str>.
  • KV: key type for the variables map (must borrow as str).

Returns a map from output variable name to its aggregated membership samples (length sampler.n).

Errors

  • Propagates FuzzyError::NotFound if an input or variable is missing.
  • Propagates FuzzyError::TypeMismatch if a term name is unknown.
  • Propagates FuzzyError::OutOfBounds if inputs are outside variable domains.

Performance

  • Time: O(R * C * N) where R = rules, C = average number of consequents per rule, and N = sampler resolution per variable.
  • Memory: O(V * N) for the aggregated output across V output variables.