Commit 0ab09ef7 authored by Max Lyon's avatar Max Lyon
Browse files

regularize hessian in NASOQSolver.cc

parent d754afe6
Pipeline #15453 failed with stages
in 16 seconds
......@@ -24,11 +24,22 @@ namespace COMISO {
//== IMPLEMENTATION ==========================================================
void regularize_hessian(NProblemInterface::SMatrixNP& _H)
{
NProblemInterface::SMatrixNP id;
id.resize(_H.rows(), _H.cols());
id.setIdentity();
double reg_factor = 1e-8;
auto diag = _H.diagonal();
_H = _H + reg_factor * diag.sum()/diag.rows() * id;
}
NProblemInterface::SMatrixNP get_hessian(NProblemInterface* _problem)
{
std::vector<double> zero(_problem->n_unknowns(), 0);
NProblemInterface::SMatrixNP H;
_problem->eval_hessian(zero.data(), H);
regularize_hessian(H);
return H;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment