dootcamp #1
7 changed files with 31 additions and 45 deletions
|
@ -15,18 +15,18 @@ categories = ["simulation"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
uuid = { version = "0.8", features = ["serde", "v4"] }
|
uuid = { version = "1.7", features = ["serde", "v4"] }
|
||||||
clap = { version = "~2.27.0", features = ["yaml"] }
|
clap = { version = "4.5.2", features = ["derive"] }
|
||||||
toml = "0.5.8"
|
toml = "0.8.10"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
file_linked = { version = "0.1.0", path = "../file_linked" }
|
file_linked = { version = "0.1.0", path = "../file_linked" }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
rand = "0.8.4"
|
rand = "0.8.5"
|
||||||
log = "0.4.14"
|
log = "0.4.21"
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.11.3"
|
||||||
futures = "0.3.17"
|
futures = "0.3.30"
|
||||||
smol = "1.2.5"
|
smol = "2.0.0"
|
||||||
smol-potat = "1.1.2"
|
smol-potat = "1.1.2"
|
||||||
num_cpus = "1.13.0"
|
num_cpus = "1.16.0"
|
||||||
easy-parallel = "3.1.0"
|
easy-parallel = "3.3.1"
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
name: GEMLA
|
|
||||||
version: "0.1"
|
|
||||||
autor: Jacob VanDomelen <jacob.vandome15@gmail.com>
|
|
||||||
about: Uses a genetic algorithm to generate a machine learning algorithm.
|
|
||||||
args:
|
|
||||||
- FILE:
|
|
||||||
help: Sets the input/output file for the program.
|
|
||||||
required: true
|
|
||||||
index: 1
|
|
|
@ -1,4 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate gemla;
|
extern crate gemla;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -6,17 +5,23 @@ extern crate log;
|
||||||
|
|
||||||
mod test_state;
|
mod test_state;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
|
||||||
use clap::App;
|
|
||||||
use easy_parallel::Parallel;
|
use easy_parallel::Parallel;
|
||||||
use gemla::{
|
use gemla::{
|
||||||
constants::args::FILE,
|
|
||||||
core::{Gemla, GemlaConfig},
|
core::{Gemla, GemlaConfig},
|
||||||
error::{log_error, Error},
|
error::{log_error, Error},
|
||||||
};
|
};
|
||||||
use smol::{channel, channel::RecvError, future, Executor};
|
use smol::{channel, channel::RecvError, future, Executor};
|
||||||
use std::{path::PathBuf, time::Instant};
|
use std::{path::PathBuf, time::Instant};
|
||||||
use test_state::TestState;
|
use test_state::TestState;
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
#[command(version, about, long_about = None)]
|
||||||
|
struct Args {
|
||||||
|
/// The file to read/write the dataset from/to.
|
||||||
|
#[arg(short, long)]
|
||||||
|
file: String,
|
||||||
|
}
|
||||||
|
|
||||||
/// Runs a simluation of a genetic algorithm against a dataset.
|
/// Runs a simluation of a genetic algorithm against a dataset.
|
||||||
///
|
///
|
||||||
|
@ -42,15 +47,12 @@ fn main() -> anyhow::Result<()> {
|
||||||
smol::block_on(async {
|
smol::block_on(async {
|
||||||
drop(signal);
|
drop(signal);
|
||||||
|
|
||||||
// Command line arguments are parsed with the clap crate. And this program uses
|
// Command line arguments are parsed with the clap crate.
|
||||||
// the yaml method with clap.
|
let args = Args::parse();
|
||||||
let yaml = load_yaml!("../../cli.yml");
|
|
||||||
let matches = App::from_yaml(yaml).get_matches();
|
|
||||||
|
|
||||||
// Checking that the first argument <FILE> is a valid file
|
// Checking that the first argument <FILE> is a valid file
|
||||||
if let Some(file_path) = matches.value_of(FILE) {
|
|
||||||
let mut gemla = log_error(Gemla::<TestState>::new(
|
let mut gemla = log_error(Gemla::<TestState>::new(
|
||||||
&PathBuf::from(file_path),
|
&PathBuf::from(args.file),
|
||||||
GemlaConfig {
|
GemlaConfig {
|
||||||
generations_per_node: 3,
|
generations_per_node: 3,
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
|
@ -60,9 +62,6 @@ fn main() -> anyhow::Result<()> {
|
||||||
log_error(gemla.simulate(3).await)?;
|
log_error(gemla.simulate(3).await)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
|
||||||
Err(Error::Other(anyhow!("Invalid argument for FILE")))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
/// Corresponds to the FILE command line argument used in accordance with the clap crate.
|
|
||||||
pub const FILE: &str = "FILE";
|
|
|
@ -1 +0,0 @@
|
||||||
pub mod args;
|
|
|
@ -20,7 +20,7 @@ type SimulationTree<T> = Box<Tree<GeneticNodeWrapper<T>>>;
|
||||||
/// Provides configuration options for managing a [`Gemla`] object as it executes.
|
/// Provides configuration options for managing a [`Gemla`] object as it executes.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```
|
/// ```rust,ignore
|
||||||
/// #[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
|
/// #[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
|
||||||
/// struct TestState {
|
/// struct TestState {
|
||||||
/// pub score: f64,
|
/// pub score: f64,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod tree;
|
pub mod tree;
|
||||||
pub mod constants;
|
|
||||||
pub mod core;
|
pub mod core;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|
Loading…
Add table
Reference in a new issue