From aff25dc1207793c6797f68deeeee1f86891ab9af Mon Sep 17 00:00:00 2001 From: Kevin Lewis Date: Mon, 1 Jul 2024 12:58:44 -0400 Subject: [PATCH] don't return infinite error results --- src/correctness.rs | 2 ++ src/inverse_kinematics/auxiliary.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/correctness.rs b/src/correctness.rs index 4db9925..9f46831 100644 --- a/src/correctness.rs +++ b/src/correctness.rs @@ -20,6 +20,8 @@ const TEST_ITERATIONS: usize = 1000; #[test] fn run_tests() { + // Seed fastrand + fastrand::seed(0); let setups: Vec> = vec![ Box::new(Subproblem6Setup::new()), Box::new(Subproblem5Setup::new()), diff --git a/src/inverse_kinematics/auxiliary.rs b/src/inverse_kinematics/auxiliary.rs index 5382a40..ad4a86b 100644 --- a/src/inverse_kinematics/auxiliary.rs +++ b/src/inverse_kinematics/auxiliary.rs @@ -152,7 +152,9 @@ pub fn search_1d Vector > ( if j == max_evals.len() - 1 { let best_result = last_results.iter() .min_by(|x, y| x.2.partial_cmp(&y.2).unwrap()).unwrap(); - results.push((best_result.0, best_result.1)) + if best_result.2.is_finite() { + results.push((best_result.0, best_result.1)); + } } } results @@ -235,7 +237,9 @@ pub fn search_2d Vector>( if j == max_evals.len() - 1 { let best_result = last_results.iter() .min_by(|x, y| x.3.partial_cmp(&y.3).unwrap()).unwrap(); - results.push((best_result.0, best_result.1, best_result.2)) + if (best_result.3.is_finite()) { + results.push((best_result.0, best_result.1, best_result.2)); + } } }