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