use crate::cards::observation::Observation;
use crate::cards::street::Street;
use crate::clustering::abstraction::Abstraction;
use crate::clustering::histogram::Histogram;
use std::collections::BTreeMap;
#[derive(Default)]
pub struct Abstractor(pub BTreeMap<Observation, Abstraction>);
impl Abstractor {
pub fn projection(&self, inner: &Observation) -> Histogram {
match inner.street() {
Street::Turn => inner.clone().into(),
_ => inner
.outnodes()
.into_iter()
.map(|ref outer| self.abstraction(outer))
.collect::<Vec<Abstraction>>()
.into(),
}
}
pub fn abstraction(&self, outer: &Observation) -> Abstraction {
self.0
.get(outer)
.cloned()
.expect("precomputed abstraction mapping")
}
pub fn assign(&mut self, a: &Abstraction, o: &Observation) {
self.0.insert(o.to_owned(), a.to_owned());
}
}