Tweak rating algorithm code

This commit is contained in:
Kiana Sheibani 2023-11-02 14:04:03 -04:00
parent 6f969cd231
commit 3d2a02c1b4
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -67,12 +67,17 @@ fn glicko_adjust(
} else { } else {
(1..) (1..)
.map(|k| vol_fn(a - k as f64 * tau)) .map(|k| vol_fn(a - k as f64 * tau))
.inspect(|x| {
if x.is_nan() {
panic!();
}
})
.find(|x| x >= &0.0) .find(|x| x >= &0.0)
.unwrap() .unwrap()
}; };
let vol_new = f64::exp(illinois_optimize(vol_fn, a, initial_b) / 2.0); let vol_new = f64::exp(illinois_optimize(vol_fn, a, initial_b) / 2.0);
let dev_time = time_adjust(time as f64 / period as f64, dev_sq, vol_new); let dev_time = time_adjust(time as f64 / period, dev_sq, vol_new);
let dev_new = 1.0 / (1.0 / dev_time / dev_time + 1.0 / variance).sqrt(); let dev_new = 1.0 / (1.0 / dev_time / dev_time + 1.0 / variance).sqrt();
let adjust = dev_new * dev_new * g_val * (score - exp_val); let adjust = dev_new * dev_new * g_val * (score - exp_val);
@ -227,6 +232,10 @@ fn update_from_set(
metadata, metadata,
); );
// Set minimum deviation level
let dev_new1 = f64::max(dev_new1, 0.2);
let dev_new2 = f64::max(dev_new2, 0.2);
set_player_data( set_player_data(
connection, connection,
dataset, dataset,
@ -271,7 +280,9 @@ pub fn sync_dataset(
for (i, event) in events.into_iter().enumerate() { for (i, event) in events.into_iter().enumerate() {
println!( println!(
"Accessing sets from event ID {}... ({}/{})", "Accessing sets from event ID {}... ({}/{})",
event.0, i, num_events event.0,
i + 1,
num_events
); );
let mut sets = let mut sets =
@ -284,6 +295,8 @@ pub fn sync_dataset(
sets.sort_by_key(|set| set.time); sets.sort_by_key(|set| set.time);
sets.into_iter() sets.into_iter()
.try_for_each(|set| update_from_set(connection, dataset, &metadata, set))?;
}
} }
connection.execute("COMMIT;") connection.execute("COMMIT;")
} }