~mht/cra

bae1de7fcfbd2d5878884b2271f21df3fee32fea — Martin Hafskjold Thoresen 6 months ago 50ab160
Remove _by_dim suffix.

This was used for almost all keys, making it very annoying
1 files changed, 32 insertions(+), 32 deletions(-)

M src/log.rs
M src/log.rs => src/log.rs +32 -32
@@ 48,21 48,21 @@ pub struct Aggregate {
    adds: Vec<(usize, usize)>,

    /// The number of adds required to reduce a simplex, by dimension.
    adds_required_by_dim: HashMap<isize, f64>,
    adds_required: HashMap<isize, f64>,
    /// The average number of additions required to reduce a simplex, by dimension.
    avg_adds_required: HashMap<isize, f64>,

    /// The size of a simplex when we add them to reduce the first.
    add_size_by_dim: HashMap<isize, Vec<(usize, usize)>>,
    add_size: HashMap<isize, Vec<(usize, usize)>>,
    /// Average of the sizes.
    avg_add_size_by_dim: HashMap<isize, (f64, f64)>,
    avg_add_size: HashMap<isize, (f64, f64)>,
    /// Histogram of the sizes
    histogram_add_size_by_dim: HashMap<isize, HashMap<usize, (usize, usize)>>,
    histogram_add_size: HashMap<isize, HashMap<usize, (usize, usize)>>,

    /// The sum of sizes of simplices when we reduce
    add_cost_by_dim: HashMap<isize, Vec<usize>>,
    avg_add_cost_by_dim: HashMap<isize, f64>,
    histogram_add_cost_by_dim: HashMap<isize, HashMap<usize, usize>>,
    add_cost: HashMap<isize, Vec<usize>>,
    avg_add_cost: HashMap<isize, f64>,
    histogram_add_cost: HashMap<isize, HashMap<usize, usize>>,

    num_simplices: HashMap<isize, usize>,
}


@@ 86,7 86,7 @@ impl<'a> Reduction<'a> {
        }

        let mut num_simplices = HashMap::new();
        for (&j, &dim) in simplices2dim.iter() {
        for &dim in simplices2dim.values() {
            *num_simplices.entry(dim).or_insert(0) += 1;
        }



@@ 97,45 97,45 @@ impl<'a> Reduction<'a> {
            }
        }

        let mut adds_required_by_dim = HashMap::new();
        let mut adds_required = HashMap::new();
        let mut count = HashMap::new();
        for r in self.reductions.iter() {
            *adds_required_by_dim.entry(r.dim).or_insert(0.0) += r.adds.len() as f64;
            *adds_required.entry(r.dim).or_insert(0.0) += r.adds.len() as f64;
            *count.entry(r.dim).or_insert(0) += 1;
        }

        let mut avg_adds_required = HashMap::new();
        for (&k, &c) in count.iter() {
            avg_adds_required.insert(k, adds_required_by_dim.get(&k).unwrap() / c as f64);
            avg_adds_required.insert(k, adds_required.get(&k).unwrap() / c as f64);
        }

        let mut add_size_by_dim = HashMap::<isize, Vec<(usize, usize)>>::new();
        let mut add_size = HashMap::<isize, Vec<(usize, usize)>>::new();
        for r in self.reductions.iter() {
            if r.adds.len() == 0 {
                continue;
            }
            let v = add_size_by_dim.entry(r.dim).or_insert(Vec::new());
            let v = add_size.entry(r.dim).or_insert(Vec::new());
            for a in r.adds.iter() {
                v.push((a.this_size, a.other_size));
            }
        }

        let mut avg_add_size_by_dim = HashMap::new();
        for (&dim, adds) in add_size_by_dim.iter() {
        let mut avg_add_size = HashMap::new();
        for (&dim, adds) in add_size.iter() {
            if adds.len() == 0 {
                continue;
            }
            let avg_f = adds.iter().map(|(f, _s)| *f).sum::<usize>() as f64 / adds.len() as f64;
            let avg_s = adds.iter().map(|(_f, s)| *s).sum::<usize>() as f64 / adds.len() as f64;
            avg_add_size_by_dim.insert(dim, (avg_f, avg_s));
            avg_add_size.insert(dim, (avg_f, avg_s));
        }

        let mut histogram_add_size_by_dim = HashMap::new();
        let mut histogram_add_size = HashMap::new();
        for r in self.reductions.iter() {
            if r.adds.len() == 0 {
                continue;
            }
            let histogram: &mut HashMap<usize, (usize, usize)> = histogram_add_size_by_dim
            let histogram: &mut HashMap<usize, (usize, usize)> = histogram_add_size
                .entry(r.dim)
                .or_insert(HashMap::new());
            for add in r.adds.iter() {


@@ 144,32 144,32 @@ impl<'a> Reduction<'a> {
            }
        }

        let mut add_cost_by_dim = HashMap::<isize, Vec<usize>>::new();
        let mut add_cost = HashMap::<isize, Vec<usize>>::new();
        for r in self.reductions.iter() {
            if r.adds.len() == 0 {
                continue;
            }
            let v = add_cost_by_dim.entry(r.dim).or_insert(Vec::new());
            let v = add_cost.entry(r.dim).or_insert(Vec::new());
            for a in r.adds.iter() {
                v.push(a.this_size + a.other_size);
            }
        }

        let mut avg_add_cost_by_dim = HashMap::new();
        for (&dim, adds) in add_cost_by_dim.iter() {
        let mut avg_add_cost = HashMap::new();
        for (&dim, adds) in add_cost.iter() {
            if adds.len() == 0 {
                continue;
            }
            let avg = adds.iter().map(|f| *f).sum::<usize>() as f64 / adds.len() as f64;
            avg_add_cost_by_dim.insert(dim, avg);
            avg_add_cost.insert(dim, avg);
        }

        let mut histogram_add_cost_by_dim = HashMap::new();
        let mut histogram_add_cost = HashMap::new();
        for r in self.reductions.iter() {
            if r.adds.len() == 0 {
                continue;
            }
            let histogram: &mut HashMap<usize, usize> = histogram_add_cost_by_dim
            let histogram: &mut HashMap<usize, usize> = histogram_add_cost
                .entry(r.dim)
                .or_insert(HashMap::new());
            for add in r.adds.iter() {


@@ 179,14 179,14 @@ impl<'a> Reduction<'a> {

        Aggregate {
            adds,
            adds_required_by_dim,
            adds_required,
            avg_adds_required,
            add_size_by_dim,
            avg_add_size_by_dim,
            histogram_add_size_by_dim,
            add_cost_by_dim,
            avg_add_cost_by_dim,
            histogram_add_cost_by_dim,
            add_size,
            avg_add_size,
            histogram_add_size,
            add_cost,
            avg_add_cost,
            histogram_add_cost,
            num_simplices,
        }
    }