diff -r ea3ca78873e8 -r 21b0e537ac0e src/main.rs --- a/src/main.rs Fri Dec 02 18:14:03 2022 +0200 +++ b/src/main.rs Fri Dec 02 21:20:04 2022 +0200 @@ -14,11 +14,11 @@ #![feature(drain_filter)] use clap::Parser; +use serde::{Serialize, Deserialize}; +use serde_json; use itertools::Itertools; -use serde_json; use std::num::NonZeroUsize; -use alg_tools::iterate::Verbose; use alg_tools::parallelism::{ set_num_threads, set_max_threads, @@ -43,7 +43,6 @@ use types::{float, ClapFloat}; use run::{ DefaultAlgorithm, - Configuration, PlotLevel, Named, AlgorithmConfig, @@ -54,7 +53,7 @@ use DefaultAlgorithm::*; /// Command line parameters -#[derive(Parser, Debug)] +#[derive(Parser, Debug, Serialize)] #[clap( about = env!("CARGO_PKG_DESCRIPTION"), author = env!("CARGO_PKG_AUTHORS"), @@ -63,12 +62,14 @@ after_long_help = "", )] pub struct CommandLineArgs { - #[arg(long, short = 'm', value_name = "M")] + #[arg(long, short = 'm', value_name = "M", default_value_t = 2000)] /// Maximum iteration count - max_iter : Option, + max_iter : usize, #[arg(long, short = 'n', value_name = "N")] /// Output status every N iterations. Set to 0 to disable. + /// + /// The default is to output status based on logarithmic increments. verbose_iter : Option, #[arg(long, short = 'q')] @@ -94,12 +95,12 @@ #[arg(value_name = "JSON_FILE", long)] saved_algorithm : Vec, - /// Write plots for every verbose iteration + /// Plot saving scheme #[arg(value_enum, long, short = 'p', default_value_t = PlotLevel::Data)] plot : PlotLevel, /// Directory for saving results - #[arg(long, short = 'o', default_value = "out")] + #[arg(long, short = 'o', required = true, default_value = "out")] outdir : String, #[arg(long, help_heading = "Multi-threading", default_value = "4")] @@ -120,7 +121,7 @@ } /// Command line experiment setup overrides -#[derive(Parser, Debug)] +#[derive(Parser, Debug, Serialize, Deserialize)] pub struct ExperimentOverrides { #[arg(long)] /// Regularisation parameter override. @@ -143,7 +144,7 @@ } /// Command line algorithm parametrisation overrides -#[derive(Parser, Debug)] +#[derive(Parser, Debug, Serialize, Deserialize)] pub struct AlgorithmOverrides { #[arg(long, value_names = &["COUNT", "EACH"])] /// Override bootstrap insertion iterations for --algorithm. @@ -222,7 +223,6 @@ for experiment_shorthand in cli.experiments.iter().unique() { let experiment = experiment_shorthand.get_experiment(&cli.experiment_overrides).unwrap(); - let mut config : Configuration = experiment.default_config(); let mut algs : Vec>> = cli.algorithm.iter() .map(|alg| experiment.algorithm_defaults(*alg, &cli.algoritm_overrides)) @@ -232,16 +232,7 @@ let alg = serde_json::from_reader(f).unwrap(); algs.push(alg); } - cli.max_iter.map(|m| config.iterator_options.max_iter = m); - cli.verbose_iter.map(|n| config.iterator_options.verbose_iter = Verbose::Every(n)); - config.plot = cli.plot; - config.iterator_options.quiet = cli.quiet; - config.outdir = cli.outdir.clone(); - if !algs.is_empty() { - config.algorithms = algs.clone(); - } - - experiment.runall(config) + experiment.runall(&cli, (!algs.is_empty()).then_some(algs)) .unwrap() } }