pub mod engine;
pub mod evolution;
pub mod graph;
pub mod spec;
pub mod state;
pub mod trainer;
pub mod utils;
pub use evolution::{crossover, mutation, pools, selection};
pub use graph::{network, node, topology};
pub use utils::fitness;
pub use utils::markdown;
pub use utils::tabular_data;
pub use engine::{
RLSpec, RaceConfig, RaceSnapshot, RlEngine, RlRaceConfig, RunMode, RunSpec, StopReason,
TabularEngine, TabularRaceConfig, TabularSpec, rl_race_config_builder,
tabular_race_config_builder,
};
pub use utils::fitness::{Direction, Fitness, FitnessLabel};
pub use graph::network::{Network, NetworkOptions};
pub use graph::node::{Activation, CombineOp, Node, NodeKind, StandardizeOp};
pub use graph::topology::{FeatureSplitPolicy, Topology, TopologyOptions};
pub use evolution::crossover::CrossoverMethod;
pub use evolution::mutation::MutationMethod;
pub use evolution::selection::SelectionMethod;
pub use trainer::stream::{BatchStream, PoolSplit};
pub use trainer::{
AnyTrainer, Env, LossFn, RlContext, RlStep, RlStepMeta, RunData, StepEnv, StepReport,
StreamShape, TabularContext, TabularStep, TabularTrainer,
};
pub use trainer::menu::{
FITNESS_NAMES, Loss, METRIC_NAMES, TargetKind, fitness_for, metric_for, metrics_for,
};
pub use utils::tabular_data::{
DataFormat, Dataset, PoolLayout, detect_pool_layout, exam_dir, load_csv_dataset, load_dataset,
load_dataset_auto, load_tensor, one_hot, resolve_dataset, resolve_inputs_targets_datasets,
resolve_train_test_datasets, resolve_train_val_datasets, save_csv_dataset, save_dataset,
save_dataset_as, save_tensor,
};
pub use utils::score::{
accuracy_score, argmax_classes, cross_entropy_onehot, cross_entropy_onehot_loss, f1_from_vecs,
f1_score, l1_loss_score, label_smoothing_cross_entropy_loss, mse_loss_score,
precision_from_vecs, precision_score, r2_score, rmse_score,
};
pub use utils::race_steps::{
deterministic_train_step, deterministic_train_step_fn, eval_one_step, eval_one_step_fn,
seed_step_randomness, train_one_step, train_one_step_fn, train_one_step_pred_only,
};
pub use flodl::{DType, Device, Variable};
pub use flodl;
pub mod prelude {
pub use crate::engine::config::{
CrossCullPolicy, LogLevel, MutationCullPolicy, RaceConfig, RaceConfigBuilder, RaceSnapshot,
RlRaceConfig, RunMode, StopReason, TabularRaceConfig, rl_race_config_builder,
tabular_race_config_builder,
};
pub use crate::engine::{RLSpec, RlEngine, RunSpec, TabularEngine, TabularSpec};
pub use crate::utils::fitness::{Direction, Fitness, FitnessLabel, Metric};
pub use crate::trainer::{
AnyTrainer, BoxedLossFn, ChallengeDecay, ChallengePolicy, Env, ForcedAction, Loss, LossFn,
ObsMemory, Reinforce, RlContext, RlStep, RlStepMeta, RlStepReport, RunData, Signal,
StepEnv, StepReport, StreamShape, TabularContext, TabularStep, TabularStepReport,
TabularTrainer, TargetKind, challenge_fires, effective_challenge_prob, episode_start_seed,
fitness_for, forced_action, least_action, metric_for, metrics_for,
};
pub use crate::trainer::stream::{BatchStream, PoolSplit};
pub use crate::evolution::selection::SelectionMethod;
pub use crate::graph::network::{Network, NetworkOptions};
pub use crate::graph::node::{Activation, CombineOp, Node, NodeKind, StandardizeOp};
pub use crate::graph::topology::{FeatureSplitPolicy, Topology, TopologyOptions};
pub use crate::flodl::nn::Module;
pub use crate::flodl::nn::optim::Optimizer;
pub use crate::flodl::{DType, Device, Tensor, Variable};
}
pub fn auto_device() -> flodl::Device {
#[cfg(feature = "cuda")]
{
flodl::Device::CUDA(0)
}
#[cfg(not(feature = "cuda"))]
{
flodl::Device::CPU
}
}
#[cfg(test)]
mod example_dependency_pin {
const MANIFEST: &str = include_str!("../Cargo.toml");
fn table(name: &str) -> Vec<String> {
let header = format!("[{name}]");
let mut out = Vec::new();
let mut inside = false;
for line in MANIFEST.lines() {
let trimmed = line.trim();
if trimmed.starts_with('[') {
inside = trimmed == header;
continue;
}
if !inside || trimmed.is_empty() || trimmed.starts_with('#') {
continue;
}
if let Some((key, _)) = trimmed.split_once('=') {
out.push(key.trim().to_string());
}
}
out.sort();
out
}
const DEPS: &[&str] = &[
"comfy-table",
"ctrlc",
"fastrand",
"flodl",
"serde",
"serde_json",
"strum",
"tracing",
"tracing-subscriber",
"xxhash-rust",
];
const DEV_DEPS: &[&str] = &["clap", "dhat", "proptest"];
fn expected(names: &[&str]) -> Vec<String> {
names.iter().map(|s| (*s).to_string()).collect()
}
#[test]
fn examples_add_no_dependencies() {
assert_eq!(
table("dependencies"),
expected(DEPS),
"[dependencies] changed: an example must not need a new crate (CONVENTIONS.md)"
);
assert_eq!(
table("dev-dependencies"),
expected(DEV_DEPS),
"[dev-dependencies] changed: an example must not need a new crate (CONVENTIONS.md)"
);
}
}