Skip to content

Commit

Permalink
feat: register magic search in main()
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentElement committed Jan 9, 2025
1 parent 092be05 commit b44f1ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub fn one_sample_with_dist() {

pub async fn simulate_sample() {
let mut futures = FuturesUnordered::new();
let run_length = 10000000;
let run_length = 1000000;
let polling_interval = 1000;
let polls = run_length / polling_interval;
let sample = read_inputs().collect::<Vec<Term>>();
Expand Down
19 changes: 13 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ mod config;
mod generators;

/// Main AlChemy simulation module
mod soup;
mod supercollider;

/// Experimental stuff
mod experiments;

/// Utilities
mod utils;

/// Lambda-calculus stuff
mod lambda;

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)]
pub enum Experiment {
XorsetStability,
Expand All @@ -33,6 +36,7 @@ pub enum Experiment {
EntropySeries,
SampleSimulate,
SampleScan,
MagicTestFunction,
}

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -126,7 +130,7 @@ pub fn read_inputs() -> impl Iterator<Item = Term> {
expressions.into_iter()
}

pub fn generate_expressions_and_seed_soup(cfg: &config::Config) -> soup::Soup {
pub fn generate_expressions_and_seed_soup(cfg: &config::Config) -> lambda::LambdaSoup {
let expressions = match &cfg.generator_config {
config::Generator::BTree(gen_cfg) => {
let mut gen = generators::BTreeGen::from_config(gen_cfg);
Expand All @@ -139,8 +143,8 @@ pub fn generate_expressions_and_seed_soup(cfg: &config::Config) -> soup::Soup {
.collect::<Vec<Term>>()
}
};
let mut soup = soup::Soup::from_config(&cfg.reactor_config);
soup.perturb(expressions);
let mut soup = lambda::LambdaSoup::from_config(&cfg.reactor_config);
soup.add_lambda_expressions(expressions);
soup
}

Expand Down Expand Up @@ -175,6 +179,9 @@ fn main() -> std::io::Result<()> {
Experiment::AdditionSearch => {
block_on(experiments::look_for_add());
}
Experiment::MagicTestFunction => {
block_on(experiments::look_for_magic());
}
Experiment::SyncEntropyTest => experiments::sync_entropy_test(),
Experiment::SampleScan => experiments::one_sample_with_dist(),
Experiment::XorsetSearch => {
Expand All @@ -194,9 +201,9 @@ fn main() -> std::io::Result<()> {
}

let mut soup = if cli.read_stdin {
let mut soup = soup::Soup::from_config(&config.reactor_config);
let mut soup = lambda::LambdaSoup::from_config(&config.reactor_config);
let expressions = read_inputs();
soup.perturb(expressions);
soup.add_lambda_expressions(expressions);
soup
} else {
generate_expressions_and_seed_soup(&config)
Expand Down
1 change: 0 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn encode_hex(bytes: &[u8]) -> String {
.collect()
}


#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DecodeHexError {
OddLength,
Expand Down

0 comments on commit b44f1ad

Please sign in to comment.