Commit e811b6b1 authored by David Bommes's avatar David Bommes
Browse files

remove regularization in OSQP solver but make sure that diagonal entries are always created

parent 00f899f7
Pipeline #20227 failed with stages
in 12 minutes and 26 seconds
......@@ -34,14 +34,13 @@ namespace
using ContraintVector = OSQPSolver::ContraintVector;
void regularize_hessian(NProblemInterface::SMatrixNP& _H)
void regularize_hessian(NProblemInterface::SMatrixNP& _H, const double _reg_factor = 1e-8)
{
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; // perturbation?!
_H = _H + _reg_factor * diag.sum() / diag.rows() * id; // perturbation?!
}
NProblemInterface::SMatrixNP get_hessian(NProblemInterface* _problem)
......@@ -49,7 +48,7 @@ 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); // TODO: some docs why this is needed?
regularize_hessian(H, 0.0); // make sure that diagonal entries are created!
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