I ain't happy
This commit is contained in:
parent
35d186cf05
commit
a2f9c95c98
2 changed files with 18 additions and 4 deletions
|
|
@ -29,7 +29,13 @@ impl Learner {
|
|||
iterations: iterations.unwrap_or(200),
|
||||
}
|
||||
}
|
||||
pub fn iterate(&self) -> Formula {
|
||||
pub fn calculate_formula(&mut self) -> Formula {
|
||||
for _ in 0..self.iterations {
|
||||
self.best_algorithm = self.iterate()
|
||||
}
|
||||
self.best_algorithm.clone()
|
||||
}
|
||||
fn iterate(&self) -> Formula {
|
||||
let mut formulas: Vec<(Formula, f64)> = vec![];
|
||||
for _ in 0..self.formulas_per_iteration {
|
||||
let mut formula = self.best_algorithm.clone();
|
||||
|
|
@ -68,7 +74,7 @@ impl Learner {
|
|||
editor.mutate_node();
|
||||
}
|
||||
}
|
||||
fn get_similarity(expected_output: &Vec<f64>, real_output: &Vec<f64>) -> Result<f64, ()> {
|
||||
pub fn get_similarity(expected_output: &Vec<f64>, real_output: &Vec<f64>) -> Result<f64, ()> {
|
||||
if expected_output.len() != real_output.len() {
|
||||
return Err(());
|
||||
}
|
||||
|
|
|
|||
12
src/main.rs
12
src/main.rs
|
|
@ -1,8 +1,16 @@
|
|||
use crate::{formula::Formula, node::Node};
|
||||
use fapprox::learner::Learner;
|
||||
|
||||
mod formula;
|
||||
mod node;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
fn main() {}
|
||||
fn main() {
|
||||
let mut learner = Learner::new(
|
||||
vec![0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.],
|
||||
vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.],
|
||||
None,
|
||||
None,
|
||||
);
|
||||
println!("{:?}", learner.calculate_formula().as_text());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue