Skip to content

Commit bfa6624

Browse files
committed
cargo fmt
1 parent f6b80de commit bfa6624

3 files changed

Lines changed: 29 additions & 30 deletions

File tree

src/alm/alm_optimizer.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -764,13 +764,14 @@ where
764764
// This function will panic is there is no akkt_tolerance
765765
// This should never happen because we set the AKKT tolerance
766766
// in the constructor and can never become `None` again
767-
let criterion_3 = cache
768-
.panoc_cache
769-
.akkt_tolerance
770-
.ok_or(SolverError::InvalidProblemState(
771-
"missing inner AKKT tolerance while checking the exit criterion",
772-
))?
773-
<= self.epsilon_tolerance + SMALL_EPSILON;
767+
let criterion_3 =
768+
cache
769+
.panoc_cache
770+
.akkt_tolerance
771+
.ok_or(SolverError::InvalidProblemState(
772+
"missing inner AKKT tolerance while checking the exit criterion",
773+
))?
774+
<= self.epsilon_tolerance + SMALL_EPSILON;
774775
Ok(criterion_1 && criterion_2 && criterion_3)
775776
}
776777

@@ -811,12 +812,13 @@ where
811812
fn update_inner_akkt_tolerance(&mut self) -> FunctionCallResult {
812813
let cache = &mut self.alm_cache;
813814
// epsilon_{nu+1} := max(epsilon, beta*epsilon_nu)
814-
let akkt_tolerance = cache
815-
.panoc_cache
816-
.akkt_tolerance
817-
.ok_or(SolverError::InvalidProblemState(
818-
"missing inner AKKT tolerance while updating it",
819-
))?;
815+
let akkt_tolerance =
816+
cache
817+
.panoc_cache
818+
.akkt_tolerance
819+
.ok_or(SolverError::InvalidProblemState(
820+
"missing inner AKKT tolerance while updating it",
821+
))?;
820822
cache.panoc_cache.set_akkt_tolerance(f64::max(
821823
akkt_tolerance * self.epsilon_update_factor,
822824
self.epsilon_tolerance,
@@ -992,14 +994,11 @@ where
992994
.with_penalty(c)
993995
.with_cost(cost);
994996
if self.alm_problem.n1 > 0 {
995-
let status = status.with_lagrange_multipliers(
996-
self.alm_cache
997-
.y_plus
998-
.as_ref()
999-
.ok_or(SolverError::InvalidProblemState(
1000-
"missing Lagrange multipliers at the ALM solution",
1001-
))?,
1002-
);
997+
let status = status.with_lagrange_multipliers(self.alm_cache.y_plus.as_ref().ok_or(
998+
SolverError::InvalidProblemState(
999+
"missing Lagrange multipliers at the ALM solution",
1000+
),
1001+
)?);
10031002
Ok(status)
10041003
} else {
10051004
Ok(status)

src/constraints/affine_space.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,9 @@ impl Constraint for AffineSpace {
8686
assert!(x.len() == n, "x has wrong dimension");
8787

8888
// Step 1: Compute e = Ax - b
89-
let a = ArrayView2::from_shape((self.n_rows, self.n_cols), &self.a_mat)
90-
.map_err(|_| {
91-
SolverError::InvalidProblemState(
92-
"failed to construct the affine-space matrix view",
93-
)
94-
})?;
89+
let a = ArrayView2::from_shape((self.n_rows, self.n_cols), &self.a_mat).map_err(|_| {
90+
SolverError::InvalidProblemState("failed to construct the affine-space matrix view")
91+
})?;
9592
let x_view = ArrayView1::from(&x[..]);
9693
let b = ArrayView1::from(&self.b_vec[..]);
9794
let e = a.dot(&x_view) - b;

src/core/panoc/panoc_engine.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ where
264264
// point `u_plus`
265265
(self.problem.cost)(&self.cache.u_plus, &mut self.cache.cost_value)?;
266266
(self.problem.gradf)(&self.cache.u_plus, &mut self.cache.gradient_u)?;
267-
if !self.cache.cost_value.is_finite() || !matrix_operations::is_finite(&self.cache.gradient_u)
267+
if !self.cache.cost_value.is_finite()
268+
|| !matrix_operations::is_finite(&self.cache.gradient_u)
268269
{
269270
return Err(SolverError::NotFiniteComputation(
270271
"line-search candidate produced a non-finite cost or gradient",
@@ -287,7 +288,8 @@ where
287288
u_current.copy_from_slice(&self.cache.u_half_step); // set u_current ← u_half_step
288289
(self.problem.cost)(u_current, &mut self.cache.cost_value)?; // cost value
289290
(self.problem.gradf)(u_current, &mut self.cache.gradient_u)?; // compute gradient
290-
if !self.cache.cost_value.is_finite() || !matrix_operations::is_finite(&self.cache.gradient_u)
291+
if !self.cache.cost_value.is_finite()
292+
|| !matrix_operations::is_finite(&self.cache.gradient_u)
291293
{
292294
return Err(SolverError::NotFiniteComputation(
293295
"first PANOC iterate produced a non-finite cost or gradient",
@@ -389,7 +391,8 @@ where
389391
self.cache.reset();
390392
(self.problem.cost)(u_current, &mut self.cache.cost_value)?; // cost value
391393
self.estimate_loc_lip(u_current)?; // computes the gradient as well! (self.cache.gradient_u)
392-
if !self.cache.cost_value.is_finite() || !matrix_operations::is_finite(&self.cache.gradient_u)
394+
if !self.cache.cost_value.is_finite()
395+
|| !matrix_operations::is_finite(&self.cache.gradient_u)
393396
{
394397
return Err(SolverError::NotFiniteComputation(
395398
"initial PANOC cost or gradient is non-finite",

0 commit comments

Comments
 (0)