From 53e458e49c9c5890a21aa16040ee7f45ef2f5fa8 Mon Sep 17 00:00:00 2001 From: Emil Koutanov Date: Sat, 11 Nov 2023 10:54:30 +1100 Subject: [PATCH] Not using the term 'scenarios' --- src/mc.rs | 14 +++++++------- src/model.rs | 4 ++-- src/model/fit.rs | 12 ++++++------ src/selection.rs | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/mc.rs b/src/mc.rs index 343ee42..aa8837f 100644 --- a/src/mc.rs +++ b/src/mc.rs @@ -119,7 +119,7 @@ impl<'a, R: Rand> MonteCarloEngine<'a, R> { pub fn simulate_batch( &mut self, - scenarios: &[Selections], + selections_list: &[Selections], counts: &mut [u64], ) { self.ensure_init(); @@ -127,7 +127,7 @@ impl<'a, R: Rand> MonteCarloEngine<'a, R> { simulate_batch( self.trials, - scenarios, + selections_list, counts, self.probs.as_ref().unwrap(), self.podium.as_mut().unwrap(), @@ -193,7 +193,7 @@ impl From> for Matrix { pub fn simulate_batch( trials: u64, - scenarios: &[Selections], + selections_list: &[Selections], counts: &mut [u64], probs: &Matrix, podium: &mut [usize], @@ -203,17 +203,17 @@ pub fn simulate_batch( ) { assert!(validate_args(probs, podium, bitmap, totals)); assert_eq!( - scenarios.len(), + selections_list.len(), counts.len(), - "a count must exist for each scenario" + "a count must exist for each set of selections" ); counts.fill(0); for _ in 0..trials { run_once(probs, podium, bitmap, totals, rand); - for (scenario_index, selections) in scenarios.iter().enumerate() { + for (selections_index, selections) in selections_list.iter().enumerate() { if selections.iter().all(|selection| selection.matches(podium)) { - counts[scenario_index] += 1; + counts[selections_index] += 1; } } } diff --git a/src/model.rs b/src/model.rs index e899ea7..4383481 100644 --- a/src/model.rs +++ b/src/model.rs @@ -326,8 +326,8 @@ fn derive_prices( let runners = weighted_probs.cols(); let mut counts = Matrix::allocate(PODIUM, runners); - let scenarios = selection::top_n_matrix(PODIUM, runners); - engine.simulate_batch(scenarios.flatten(), counts.flatten_mut()); + let all_selections = selection::top_n_matrix(PODIUM, runners); + engine.simulate_batch(all_selections.flatten(), counts.flatten_mut()); let mut derived_probs = Matrix::allocate(PODIUM, runners); for runner in 0..runners { diff --git a/src/model/fit.rs b/src/model/fit.rs index c46cdc2..e084d31 100644 --- a/src/model/fit.rs +++ b/src/model/fit.rs @@ -87,13 +87,13 @@ pub fn fit_all(options: &FitOptions, markets: &[Market]) -> Result = (1..model::PODIUM) .map(|rank| { let market = &markets[rank]; let outcome = fit_individual( - &scenarios, + &all_selections, &weighted_probs, options.mc_trials, options.individual_target_msre, @@ -166,9 +166,9 @@ pub fn fit_place( ) -> Result { options.validate()?; let num_runners = place_market.probs.len(); - let scenarios = selection::top_n_matrix(model::PODIUM, num_runners); + let all_selections = selection::top_n_matrix(model::PODIUM, num_runners); let outcome = fit_individual( - &scenarios, + &all_selections, weighted_probs, options.mc_trials, options.individual_target_msre, @@ -217,7 +217,7 @@ pub struct IndividualFitOutcome { } fn fit_individual( - scenarios: &Matrix, + all_selections: &Matrix, weighted_probs: &Matrix, mc_trials: u64, target_msre: f64, @@ -245,7 +245,7 @@ fn fit_individual( Rank::index(rank) ); let mut counts = Matrix::allocate(podium_places, runners); - engine.simulate_batch(scenarios.flatten(), counts.flatten_mut()); + engine.simulate_batch(all_selections.flatten(), counts.flatten_mut()); let fitted_probs: Vec<_> = counts .row_slice(rank) .iter() diff --git a/src/selection.rs b/src/selection.rs index 2d7ee36..6f50955 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -214,13 +214,13 @@ impl<'a> FromStr for Selections<'a> { /// Builds a `podium_places` x `num_runners` matrix populated with top-_N_ selections. pub fn top_n_matrix(podium_places: usize, num_runners: usize) -> Matrix> { - let mut scenarios = Matrix::allocate(podium_places, num_runners); + let mut all_selections = Matrix::allocate(podium_places, num_runners); for runner in 0..num_runners { for rank in 0..podium_places { - scenarios[(rank, runner)] = vec![Runner::index(runner).top(Rank::index(rank))].into(); + all_selections[(rank, runner)] = vec![Runner::index(runner).top(Rank::index(rank))].into(); } } - scenarios + all_selections } pub fn validate_plausible_selections(selections: &[Selection]) -> Result<(), anyhow::Error> {