- some clippy fixes
This commit is contained in:
+1
-1
@@ -442,7 +442,7 @@ where
|
||||
|
||||
self.metric.replace(IntMut {
|
||||
mu: mu.to_vec(),
|
||||
metric: metric,
|
||||
metric,
|
||||
derivative: dmetric.clone(),
|
||||
});
|
||||
// self.metric.replace(IntMut {
|
||||
|
||||
+14
-14
@@ -379,6 +379,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_lbfgs_quadratic_with_minimum() {
|
||||
struct QuadraticWithMinimum;
|
||||
|
||||
impl ObjectiveFunction<f64> for QuadraticWithMinimum {
|
||||
fn evaluate(&self, point: &[f64]) -> f64 {
|
||||
let x = point[0];
|
||||
(x - 2.0).powi(2)
|
||||
}
|
||||
|
||||
fn gradient(&self, point: &[f64]) -> Option<Vec<f64>> {
|
||||
let x = point[0];
|
||||
Some(vec![2.0 * (x - 2.0)])
|
||||
}
|
||||
}
|
||||
|
||||
let f = QuadraticWithMinimum;
|
||||
let initial_point = vec![0.0];
|
||||
let config = OptimizationConfig {
|
||||
@@ -412,17 +426,3 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct QuadraticWithMinimum;
|
||||
|
||||
impl ObjectiveFunction<f64> for QuadraticWithMinimum {
|
||||
fn evaluate(&self, point: &[f64]) -> f64 {
|
||||
let x = point[0];
|
||||
(x - 2.0).powi(2)
|
||||
}
|
||||
|
||||
fn gradient(&self, point: &[f64]) -> Option<Vec<f64>> {
|
||||
let x = point[0];
|
||||
Some(vec![2.0 * (x - 2.0)])
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -10,18 +10,15 @@ use std::marker::PhantomData;
|
||||
|
||||
/// Optimizer type for registration
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Default)]
|
||||
pub enum Optimizer {
|
||||
/// L-BFGS optimizer (fast, requires consistent gradients)
|
||||
#[default]
|
||||
LBFGS,
|
||||
/// Adaptive Stochastic Gradient Descent (robust, handles noisy gradients)
|
||||
ASGD,
|
||||
}
|
||||
|
||||
impl Default for Optimizer {
|
||||
fn default() -> Self {
|
||||
Self::LBFGS
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RegistrationStep {
|
||||
@@ -358,11 +355,10 @@ impl<D: Dimension> Registration<D> {
|
||||
&scales,
|
||||
);
|
||||
|
||||
if let Some(result) = optimization_result {
|
||||
if result.optimal_point.iter().all(|i| i.is_finite()) {
|
||||
if let Some(result) = optimization_result
|
||||
&& result.optimal_point.iter().all(|i| i.is_finite()) {
|
||||
p = self.fixed_mu.combine(&result.optimal_point);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Transform::<D>::new(p, fixed.shape().to_vec()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user