Skip to content

Commit

Permalink
Slightly better error handling in L-BFGS
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-k committed Jan 25, 2024
1 parent 933508f commit e9bebb2
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions crates/argmin/src/solver/quasinewton/lbfgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,20 +434,33 @@ where

self.linesearch.search_direction(d);

// Run solver
let OptimizationResult {
problem: mut line_problem,
state: mut linesearch_state,
..
} = Executor::new(line_problem, self.linesearch.clone())
// Run line search
let linesearch_result = Executor::new(line_problem, self.linesearch.clone())
.configure(|config| {
config
.param(param.clone())
.gradient(prev_grad.clone())
.cost(cur_cost)
})
.ctrlc(false)
.run()?;
.run();

let OptimizationResult {
problem: mut line_problem,
state: mut linesearch_state,
..
} = match linesearch_result {
Ok(res) => res,
Err(e) => {
return Ok((
state.terminate_with(TerminationReason::SolverExit(format!(
"Line search terminated with: '{}'",
e,
))),
Some(kv!("gamma" => gamma;)),
))
}
};

let mut xk1 = linesearch_state.take_param().unwrap();
let next_cost = linesearch_state.get_cost();
Expand Down

0 comments on commit e9bebb2

Please sign in to comment.