Skip to main content

pounce_algorithm/hess/
exact.rs

1//! Exact Hessian — port of `IpExactHessianUpdater.{hpp,cpp}`.
2//! Pulls `eval_h` from the NLP at every iterate via
3//! `IpoptCalculatedQuantities::curr_exact_hessian` and stashes the
4//! result into `IpoptData::w`.
5
6use crate::hess::r#trait::HessianUpdater;
7use crate::ipopt_cq::IpoptCqHandle;
8use crate::ipopt_data::IpoptDataHandle;
9
10pub struct ExactHessianUpdater;
11
12impl ExactHessianUpdater {
13    pub fn new() -> Self {
14        Self
15    }
16}
17
18impl Default for ExactHessianUpdater {
19    fn default() -> Self {
20        Self::new()
21    }
22}
23
24impl HessianUpdater for ExactHessianUpdater {
25    fn update_hessian(&mut self, data: &IpoptDataHandle, cq: &IpoptCqHandle) -> bool {
26        let w = cq.borrow().curr_exact_hessian();
27        data.borrow_mut().w = Some(w);
28        true
29    }
30}