Skip to content

Commit

Permalink
Naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ekoutanov committed Nov 11, 2023
1 parent 53e458e commit 4cd6794
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ fn derive_prices(

let runners = weighted_probs.cols();
let mut counts = Matrix::allocate(PODIUM, runners);
let all_selections = selection::top_n_matrix(PODIUM, runners);
engine.simulate_batch(all_selections.flatten(), counts.flatten_mut());
let top_n_selections = selection::top_n_matrix(PODIUM, runners);
engine.simulate_batch(top_n_selections.flatten(), counts.flatten_mut());

let mut derived_probs = Matrix::allocate(PODIUM, runners);
for runner in 0..runners {
Expand Down
12 changes: 6 additions & 6 deletions src/model/fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ pub fn fit_all(options: &FitOptions, markets: &[Market]) -> Result<AllFitOutcome
.with_podium_places(model::PODIUM)
.into();

let all_selections = selection::top_n_matrix(model::PODIUM, num_runners);
let top_n_selections = selection::top_n_matrix(model::PODIUM, num_runners);

let outcomes: Vec<_> = (1..model::PODIUM)
.map(|rank| {
let market = &markets[rank];
let outcome = fit_individual(
&all_selections,
&top_n_selections,
&weighted_probs,
options.mc_trials,
options.individual_target_msre,
Expand Down Expand Up @@ -166,9 +166,9 @@ pub fn fit_place(
) -> Result<PlaceFitOutcome, anyhow::Error> {
options.validate()?;
let num_runners = place_market.probs.len();
let all_selections = selection::top_n_matrix(model::PODIUM, num_runners);
let top_n_selections = selection::top_n_matrix(model::PODIUM, num_runners);
let outcome = fit_individual(
&all_selections,
&top_n_selections,
weighted_probs,
options.mc_trials,
options.individual_target_msre,
Expand Down Expand Up @@ -217,7 +217,7 @@ pub struct IndividualFitOutcome {
}

fn fit_individual(
all_selections: &Matrix<Selections>,
top_n_selections: &Matrix<Selections>,
weighted_probs: &Matrix<f64>,
mc_trials: u64,
target_msre: f64,
Expand Down Expand Up @@ -245,7 +245,7 @@ fn fit_individual(
Rank::index(rank)
);
let mut counts = Matrix::allocate(podium_places, runners);
engine.simulate_batch(all_selections.flatten(), counts.flatten_mut());
engine.simulate_batch(top_n_selections.flatten(), counts.flatten_mut());
let fitted_probs: Vec<_> = counts
.row_slice(rank)
.iter()
Expand Down
6 changes: 3 additions & 3 deletions src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Selections<'static>> {
let mut all_selections = Matrix::allocate(podium_places, num_runners);
let mut top_n_selections = Matrix::allocate(podium_places, num_runners);
for runner in 0..num_runners {
for rank in 0..podium_places {
all_selections[(rank, runner)] = vec![Runner::index(runner).top(Rank::index(rank))].into();
top_n_selections[(rank, runner)] = vec![Runner::index(runner).top(Rank::index(rank))].into();
}
}
all_selections
top_n_selections
}

pub fn validate_plausible_selections(selections: &[Selection]) -> Result<(), anyhow::Error> {
Expand Down

0 comments on commit 4cd6794

Please sign in to comment.