Nothing could stop us
This commit is contained in:
parent
6655499305
commit
2ebfe38bac
1 changed files with 28 additions and 1 deletions
|
|
@ -23,7 +23,34 @@ impl Learner {
|
|||
iterations: iterations.unwrap_or(200),
|
||||
}
|
||||
}
|
||||
fn get_similarity(expected_output: Vec<f64>, real_output: Vec<f64>) -> Result<f64, ()> {
|
||||
pub 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();
|
||||
Learner::mutate_formula_randomly(&mut formula);
|
||||
let outputs = formula.run(self.inputs.clone());
|
||||
formulas.push((
|
||||
formula,
|
||||
Learner::get_similarity(&self.expected_outputs, &outputs).unwrap(),
|
||||
));
|
||||
}
|
||||
formulas
|
||||
.iter()
|
||||
.max_by(|x, y| {
|
||||
if x.1 > y.1 {
|
||||
std::cmp::Ordering::Greater
|
||||
} else if x.1 < y.1 {
|
||||
std::cmp::Ordering::Less
|
||||
} else {
|
||||
std::cmp::Ordering::Equal
|
||||
}
|
||||
})
|
||||
.unwrap()
|
||||
.0
|
||||
.clone()
|
||||
}
|
||||
fn mutate_formula_randomly(formula: &mut Formula) {}
|
||||
fn get_similarity(expected_output: &Vec<f64>, real_output: &Vec<f64>) -> Result<f64, ()> {
|
||||
if expected_output.len() != real_output.len() {
|
||||
return Err(());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue