diff --git a/research/Cargo.lock b/research/Cargo.lock index 3f09d41..ee5f41c 100644 --- a/research/Cargo.lock +++ b/research/Cargo.lock @@ -17,6 +17,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -65,6 +114,52 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "clap" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + [[package]] name = "compensated-summation" version = "0.3.0" @@ -211,6 +306,12 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hex" version = "0.4.3" @@ -268,6 +369,12 @@ dependencies = [ "serde", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itoa" version = "1.0.11" @@ -298,6 +405,7 @@ name = "liglicko2-research" version = "0.0.0" dependencies = [ "chrono", + "clap", "compensated-summation", "csv", "liglicko2", @@ -571,6 +679,12 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.11.0" @@ -650,6 +764,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" version = "0.52.6" diff --git a/research/Cargo.toml b/research/Cargo.toml index 9f84e80..9ad123b 100644 --- a/research/Cargo.toml +++ b/research/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" [dependencies] chrono = "0.4.38" +clap = { version = "4.5.20", features = ["derive"] } compensated-summation = { git = "https://github.com/niklasf/compensated-summation", branch = "feat/default" } csv = "1.3.0" liglicko2 = { path = ".." } diff --git a/research/src/bin/replay_encounters.rs b/research/src/bin/replay_encounters.rs index 3f2bfd5..e371fba 100644 --- a/research/src/bin/replay_encounters.rs +++ b/research/src/bin/replay_encounters.rs @@ -1,3 +1,4 @@ +use clap::Parser as _; use std::{error::Error as StdError, fmt, fs::File, io, io::Write, str::FromStr}; use chrono::{DateTime, NaiveDateTime}; @@ -385,18 +386,38 @@ fn write_report( Ok(()) } +#[derive(clap::Parser)] +struct Opt { + #[clap(long, value_delimiter = ',', num_args = 1.., default_value = "45")] + min_deviation: Vec, + #[clap(long, value_delimiter = ',', num_args = 1.., default_value = "500")] + max_deviation: Vec, + #[clap(long, value_delimiter = ',', num_args = 1.., default_value = "0.09")] + default_volatility: Vec, + #[clap(long, value_delimiter = ',', num_args = 1.., default_value = "0.75")] + tau: Vec, + #[clap(long, value_delimiter = ',', num_args = 1.., default_value = "0")] + first_advantage: Vec, + #[clap(long, value_delimiter = ',', num_args = 1.., default_value = "0,1")] + preview_opponent_deviation: Vec, + #[clap(long, value_delimiter = ',', num_args = 1.., default_value = "0.21436")] + rating_periods_per_day: Vec, +} + fn main() -> Result<(), Box> { + let opt = Opt::parse(); + let process_uuid = Uuid::now_v7(); let mut experiments = Vec::new(); - for min_deviation in [40.0, 45.0, 50.0] { - for max_deviation in [450.0, 500.0, 550.0] { - for default_volatility in [0.08, 0.09, 0.1] { - for tau in [0.6, 0.75, 0.9] { - for first_advantage in [0.0, 8.0, 11.0] { - for preview_opponent_deviation in [true, false] { - for rating_periods_per_day in [0.2, 0.21436, 0.23] { + for &min_deviation in &opt.min_deviation { + for &max_deviation in &opt.max_deviation { + for &default_volatility in &opt.default_volatility { + for &tau in &opt.tau { + for &first_advantage in &opt.first_advantage { + for &preview_opponent_deviation in &opt.preview_opponent_deviation { + for &rating_periods_per_day in &opt.rating_periods_per_day { experiments.push(Experiment { rating_system: RatingSystem::builder() .min_deviation(RatingDifference(min_deviation)) @@ -404,7 +425,7 @@ fn main() -> Result<(), Box> { .default_volatility(Volatility(default_volatility)) .tau(tau) .first_advantage(RatingDifference(first_advantage)) - .preview_opponent_deviation(preview_opponent_deviation) + .preview_opponent_deviation(preview_opponent_deviation != 0) .build(), rating_periods_per_day, ..Default::default()