diff --git a/gemla/src/bracket/mod.rs b/gemla/src/bracket/mod.rs index dcba0a4..ce3709b 100644 --- a/gemla/src/bracket/mod.rs +++ b/gemla/src/bracket/mod.rs @@ -8,9 +8,12 @@ use uuid::Uuid; // directory: String // } +/// Constructs a tree with a given height while simultaneously running a simulation on each node. fn build_tree(h: u32) -> Option> { let mut result: Option> = None; + // Recursively building a tree and running the simulation after wards to ensure a bottom-up + // execution order. if h != 0 { result = Some(Box::new(tree::combine_trees(Uuid::new_v4(), build_tree(h - 1), build_tree(h - 1)))); match &result { @@ -22,10 +25,14 @@ fn build_tree(h: u32) -> Option> { result } +/// Generates a bracket tree and runs simulation against each node. +/// +/// TODO: Explain reasoning for bracket system against genetic algorithm. pub fn run_bracket() { let mut height = 1; let mut tree: tree::Tree = *build_tree(height).expect("Error getting result from build_tree."); + // Building tree one node at a time, appending to the top. loop { println!("========================================="); println!("Running bracket..."); diff --git a/gemla/src/constants/args.rs b/gemla/src/constants/args.rs index 431270b..6a59c9a 100644 --- a/gemla/src/constants/args.rs +++ b/gemla/src/constants/args.rs @@ -1 +1,2 @@ +/// Corresponds to the DIRECTORY command line argument used in accordance with the clap crate. pub const DIRECTORY: &str = "DIRECTORY"; \ No newline at end of file diff --git a/gemla/src/main.rs b/gemla/src/main.rs index bba6c70..8dcabf9 100644 --- a/gemla/src/main.rs +++ b/gemla/src/main.rs @@ -6,13 +6,18 @@ extern crate clap; use clap::App; use std::fs::metadata; +/// Runs a simluation of a genetic algorithm against a dataset. +/// +/// Use the -h, --h, or --help flag to see usage syntax. fn main() { + // Command line arguments are parsed with the clap crate. And this program uses + // the yaml method with clap. let yaml = load_yaml!("../cli.yml"); let matches = App::from_yaml(yaml).get_matches(); + // Checking that the first argument is a valid directory let directory = matches.value_of(constants::args::DIRECTORY).unwrap(); let metadata = metadata(directory); - match &metadata { Ok(m) if m.is_dir() == true => { println!("{} is a valid directory!", directory);