Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override dense hessian behavior #67

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/polysolve/nonlinear/Problem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
using typename cppoptlib::Problem<double>::Scalar;
using typename cppoptlib::Problem<double>::TVector;
typedef polysolve::StiffnessMatrix THessian;

// disable warning for dense hessian
using cppoptlib::Problem<double>::hessian;
typedef Eigen::MatrixXd TDenseHessian;

Problem() {}
~Problem() = default;
Expand All @@ -29,6 +27,12 @@
virtual double value(const TVector &x) override = 0;
virtual void gradient(const TVector &x, TVector &gradv) override = 0;
virtual void hessian(const TVector &x, THessian &hessian) = 0;
virtual void hessian(const TVector &x, TDenseHessian &hessian)

Check warning on line 30 in src/polysolve/nonlinear/Problem.hpp

View check run for this annotation

Codecov / codecov/patch

src/polysolve/nonlinear/Problem.hpp#L30

Added line #L30 was not covered by tests
{
THessian sparse_hessian;
this->hessian(x, sparse_hessian);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to throw

hessian = TDenseHessian(sparse_hessian);
}

Check warning on line 35 in src/polysolve/nonlinear/Problem.hpp

View check run for this annotation

Codecov / codecov/patch

src/polysolve/nonlinear/Problem.hpp#L32-L35

Added lines #L32 - L35 were not covered by tests

virtual bool is_step_valid(const TVector &x0, const TVector &x1) const { return true; }
virtual double max_step_size(const TVector &x0, const TVector &x1) const { return 1; }
Expand Down
Loading