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),
|
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![];
|
let mut formulas: Vec<(Formula, f64)> = vec![];
|
||||||
for _ in 0..self.formulas_per_iteration {
|
for _ in 0..self.formulas_per_iteration {
|
||||||
let mut formula = self.best_algorithm.clone();
|
let mut formula = self.best_algorithm.clone();
|
||||||
|
|
@ -68,7 +74,7 @@ impl Learner {
|
||||||
editor.mutate_node();
|
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() {
|
if expected_output.len() != real_output.len() {
|
||||||
return Err(());
|
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 formula;
|
||||||
mod node;
|
mod node;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
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