Skip to content

Commit f262a76

Browse files
committed
cargo fmt
1 parent eeb7d97 commit f262a76

5 files changed

Lines changed: 18 additions & 28 deletions

File tree

src/alm/alm_optimizer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use crate::{
22
alm::*,
33
constraints,
44
core::{panoc::PANOCOptimizer, ExitStatus, Problem, SolverStatus},
5-
matrix_operations, numeric::cast, FunctionCallResult, SolverError,
5+
matrix_operations,
6+
numeric::cast,
7+
FunctionCallResult, SolverError,
68
};
79
use lbfgs::LbfgsPrecision;
810
use num::Float;

src/constraints/affine_space.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,12 @@ where
8484
let aat = matrix_operations::mul_a_at(&a, n_rows, n_cols)
8585
.map_err(|_| AffineSpaceError::IncompatibleDimensions)?;
8686
let mut factorizer = CholeskyFactorizer::new(n_rows);
87-
factorizer
88-
.factorize(&aat)
89-
.map_err(|err| match err {
90-
CholeskyError::NotPositiveDefinite => AffineSpaceError::NotFullRowRank,
91-
CholeskyError::DimensionMismatch | CholeskyError::NotFactorized => {
92-
AffineSpaceError::IncompatibleDimensions
93-
}
94-
})?;
87+
factorizer.factorize(&aat).map_err(|err| match err {
88+
CholeskyError::NotPositiveDefinite => AffineSpaceError::NotFullRowRank,
89+
CholeskyError::DimensionMismatch | CholeskyError::NotFactorized => {
90+
AffineSpaceError::IncompatibleDimensions
91+
}
92+
})?;
9593
Ok(AffineSpace {
9694
a_mat: a,
9795
b_vec: b,

src/constraints/ballp.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,7 @@ impl<'a, T: Float> BallP<'a, T> {
249249
lo = u;
250250
}
251251

252-
let df = T::one()
253-
+ lambda
254-
* p
255-
* (p - T::one())
256-
* u.powf(p - cast::<T>(2.0));
252+
let df = T::one() + lambda * p * (p - T::one()) * u.powf(p - cast::<T>(2.0));
257253
let mut candidate = u - f / df;
258254

259255
if !candidate.is_finite() || candidate <= lo || candidate >= hi {

src/constraints/tests.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,7 @@ fn t_affine_space_try_new_rank_deficient() {
12951295
let a = vec![1.0, 2.0, 2.0, 4.0];
12961296
let b = vec![1.0, 2.0];
12971297
let affine_set = AffineSpace::try_new(a, b);
1298-
assert!(matches!(
1299-
affine_set,
1300-
Err(AffineSpaceError::NotFullRowRank)
1301-
));
1298+
assert!(matches!(affine_set, Err(AffineSpaceError::NotFullRowRank)));
13021299
}
13031300

13041301
#[test]
@@ -1654,9 +1651,7 @@ where
16541651
.collect();
16551652

16561653
for _ in 0..150 {
1657-
let z_feasible: Vec<f64> = (0..dim)
1658-
.map(|_| rng.random_range(-3.0..3.0))
1659-
.collect();
1654+
let z_feasible: Vec<f64> = (0..dim).map(|_| rng.random_range(-3.0..3.0)).collect();
16601655
let norm_z_sq_feasible = z_feasible.iter().map(|zi| zi * zi).sum::<f64>();
16611656
let t_feasible = norm_z_sq_feasible + rng.random_range(0.0..3.0);
16621657
let mut y = z_feasible;

src/core/panoc/panoc_engine.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use crate::{
22
constraints,
33
core::{panoc::PANOCCache, AlgorithmEngine, Problem},
4-
matrix_operations, numeric::cast, FunctionCallResult, SolverError,
4+
matrix_operations,
5+
numeric::cast,
6+
FunctionCallResult, SolverError,
57
};
68
use lbfgs::LbfgsPrecision;
79
use num::Float;
@@ -210,8 +212,7 @@ where
210212
self.cache.lbfgs.reset(); // invalidate the L-BFGS buffer
211213

212214
// update L, sigma and gamma...
213-
self.cache.lipschitz_constant =
214-
self.cache.lipschitz_constant * cast::<T>(2.0);
215+
self.cache.lipschitz_constant = self.cache.lipschitz_constant * cast::<T>(2.0);
215216
self.cache.gamma = self.cache.gamma / cast::<T>(2.0);
216217

217218
// recompute the half step...
@@ -226,8 +227,7 @@ where
226227
self.compute_fpr(u_current);
227228
it_lipschitz_search += 1;
228229
}
229-
self.cache.sigma = (T::one() - gamma_l_coeff::<T>())
230-
/ (cast::<T>(4.0) * self.cache.gamma);
230+
self.cache.sigma = (T::one() - gamma_l_coeff::<T>()) / (cast::<T>(4.0) * self.cache.gamma);
231231

232232
Ok(())
233233
}
@@ -390,8 +390,7 @@ where
390390
self.cache_gradient_norm();
391391
self.cache.gamma =
392392
gamma_l_coeff::<T>() / self.cache.lipschitz_constant.max(min_l_estimate());
393-
self.cache.sigma = (T::one() - gamma_l_coeff::<T>())
394-
/ (cast::<T>(4.0) * self.cache.gamma);
393+
self.cache.sigma = (T::one() - gamma_l_coeff::<T>()) / (cast::<T>(4.0) * self.cache.gamma);
395394
self.gradient_step(u_current); // updated self.cache.gradient_step
396395
self.half_step(); // updates self.cache.u_half_step
397396

0 commit comments

Comments
 (0)