Skip to content

Commit

Permalink
Make the LineSearch gradient parameter in BFGS consistent with the impl
Browse files Browse the repository at this point in the history
  • Loading branch information
dspyz-matician authored and stefan-k committed Aug 31, 2024
1 parent 4718212 commit be2444e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/argmin/src/solver/quasinewton/bfgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,20 @@ impl<O, L, P, G, H, F> Solver<O, IterState<P, G, (), H, (), F>> for BFGS<L, F>
where
O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>,
P: Clone + ArgminSub<P, P> + ArgminDot<G, H> + ArgminDot<P, H>,
G: Clone + ArgminL2Norm<F> + ArgminMul<F, P> + ArgminDot<P, F> + ArgminSub<G, G>,
G: Clone
+ ArgminL2Norm<F>
+ ArgminMul<F, P>
+ ArgminMul<F, G>
+ ArgminDot<P, F>
+ ArgminSub<G, G>,
H: ArgminSub<H, H>
+ ArgminDot<G, G>
+ ArgminDot<H, H>
+ ArgminAdd<H, H>
+ ArgminMul<F, H>
+ ArgminTranspose<H>
+ ArgminEye,
L: Clone + LineSearch<P, F> + Solver<O, IterState<P, G, (), (), (), F>>,
L: Clone + LineSearch<G, F> + Solver<O, IterState<P, G, (), (), (), F>>,
F: ArgminFloat,
{
fn name(&self) -> &str {
Expand Down Expand Up @@ -214,9 +219,9 @@ where
"`BFGS`: Inverse Hessian in state not set."
))?;

let p = inv_hessian.dot(&prev_grad).mul(&float!(-1.0));
let g: G = inv_hessian.dot(&prev_grad).mul(&float!(-1.0));

self.linesearch.search_direction(p);
self.linesearch.search_direction(g);

// Run solver
let OptimizationResult {
Expand Down

0 comments on commit be2444e

Please sign in to comment.