Skip to content

Commit

Permalink
Use ABSOLUTE_RATING_FLOOR and DEFAULT_VOLAILITY as bounds for mu/sigma
Browse files Browse the repository at this point in the history
  • Loading branch information
hburn7 committed Dec 19, 2024
1 parent 3fa5680 commit 493f986
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/model/otr_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use openskill::{
rating::{Rating, TeamRating}
};
use std::collections::HashMap;
use crate::model::constants::{ABSOLUTE_RATING_FLOOR, DEFAULT_VOLATILITY};

pub struct OtrModel {
pub model: PlackettLuce,
Expand Down Expand Up @@ -251,8 +252,8 @@ impl OtrModel {
final_map.insert(
*k,
Rating {
mu: rating_final,
sigma: volatility_final
mu: rating_final.max(ABSOLUTE_RATING_FLOOR),
sigma: volatility_final.min(DEFAULT_VOLATILITY)
}
);
}
Expand Down Expand Up @@ -364,7 +365,7 @@ mod tests {
};
use approx::assert_abs_diff_eq;
use chrono::Utc;
use crate::model::constants::{ABSOLUTE_RATING_FLOOR};
use crate::model::constants::{ABSOLUTE_RATING_FLOOR, DEFAULT_VOLATILITY};

#[test]
fn test_rate() {
Expand Down Expand Up @@ -494,12 +495,12 @@ mod tests {
}

#[test]
fn test_minimum_rating() {
fn test_minimum_rating_maximum_volatility() {
let player_ratings = vec![
generate_player_rating(1, Osu, 100.1, 100.0, 1),
generate_player_rating(2, Osu, 100.0, 100.0, 1),
generate_player_rating(3, Osu, 100.0, 100.0, 1),
generate_player_rating(4, Osu, 100.0, 100.0, 1),
generate_player_rating(1, Osu, 100.1, 500.0, 1),
generate_player_rating(2, Osu, 100.0, 500.0, 1),
generate_player_rating(3, Osu, 100.0, 500.0, 1),
generate_player_rating(4, Osu, 100.0, 500.0, 1),
];

let countries = generate_country_mapping_player_ratings(player_ratings.as_slice(), "US");
Expand All @@ -525,6 +526,7 @@ mod tests {
let rating = model.rating_tracker.get_rating(i, Osu).unwrap();

assert!(rating.rating >= ABSOLUTE_RATING_FLOOR);
assert!(rating.volatility <= DEFAULT_VOLATILITY);
}
}
}

0 comments on commit 493f986

Please sign in to comment.