use std::process;
use structopt::StructOpt;
use wsp::{adaptive_wsp, wsp, PointSet};
#[derive(StructOpt)]
struct Cli {
#[structopt(short = "o", long = "output", default_value = "wsp.csv")]
output_file: String,
#[structopt(short = "i", long = "initial")]
output_file_before: Option<String>,
#[structopt(short = "a", long = "algo", default_value = "random")]
_initial_algo: String,
#[structopt(short = "n", long = "nb-initial", default_value = "2000")]
nb_initial: usize,
#[structopt(short = "d", long = "distance", default_value = "1.0")]
d_min: f64,
#[structopt(short = "m", long = "dimension", default_value = "20")]
dim: usize,
#[structopt(short = "s", long = "seed", default_value = "51")]
seed: u64,
#[structopt(long = "adaptive")]
nb_target: Option<usize>,
#[structopt(short = "v", long = "verbose")]
verbose: bool,
#[structopt(short = "t", long = "transpose")]
transpose: bool,
}
fn main() {
let args = Cli::from_args();
let mut points: PointSet = PointSet::init_from_random(args.nb_initial, args.dim, args.seed);
if let Some(filename) = args.output_file_before {
if let Err(err) = points.save_in_csv(&filename, args.transpose) {
eprintln!("Error writing in CSV: {}", err);
process::exit(1);
}
}
match args.nb_target {
Some(obj_nb) => adaptive_wsp(&mut points, obj_nb, args.verbose),
None => wsp(&mut points, args.d_min),
}
if let Err(err) = points.save_in_csv(&args.output_file, args.transpose) {
eprintln!("Error writing in CSV: {}", err);
process::exit(1);
}
if args.verbose {
println!("Nb active: {}", points.nb_active);
}
}