use ries_rs::{
gen::GenConfig,
search::{search_streaming_with_config, SearchConfig},
OutputFormat,
};
use std::time::Instant;
fn main() {
let target = std::env::args()
.nth(1)
.unwrap_or_else(|| "3.1415926535".to_string());
let target: f64 = target.parse().expect("Please provide a valid number");
println!("Performing deep streaming search for target: {}", target);
println!("{:-<60}", "");
let gen_config = GenConfig {
max_lhs_complexity: 25,
max_rhs_complexity: 20,
..GenConfig::default()
};
let search_config = SearchConfig {
target,
max_matches: 10,
stop_at_exact: true,
..SearchConfig::default()
};
println!("Starting search...");
let start = Instant::now();
let (matches, stats) = search_streaming_with_config(&gen_config, &search_config);
let elapsed = start.elapsed();
for (i, m) in matches.iter().enumerate() {
println!(
"{:3}: {} = {} (error: {:.2e}, complexity: {})",
i + 1,
m.lhs.expr.to_infix_with_format(OutputFormat::Pretty),
m.rhs.expr.to_infix_with_format(OutputFormat::Pretty),
m.error,
m.complexity
);
}
println!("{:-<60}", "");
println!("Search Statistics:");
println!(" LHS expressions: {:>10}", stats.lhs_count);
println!(" RHS expressions: {:>10}", stats.rhs_count);
println!(" Total time: {:>10.2?}", elapsed);
println!(" Memory profile: Streaming (O(depth) rather than O(N))");
}