-
Notifications
You must be signed in to change notification settings - Fork 31
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
Refactor NewtonSolver #2521
Refactor NewtonSolver #2521
Conversation
9a79289
to
f7bd3f8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2521 +/- ##
===========================================
+ Coverage 77.67% 77.75% +0.07%
===========================================
Files 324 323 -1
Lines 20951 20915 -36
Branches 1451 1446 -5
===========================================
- Hits 16274 16262 -12
+ Misses 4674 4650 -24
Partials 3 3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
ecc025e
to
51ff7ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat!
src/newton_solver.cpp
Outdated
void NewtonSolverDense::reinitialize() { | ||
/* dense solver does not need reinitialization */ | ||
void NewtonSolver::reinitialize() { | ||
// dense solver does not need reinitialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// dense solver does not need reinitialization | |
// direct solvers does not need reinitialization |
what about iterative solvers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are already filtered out in the constructor:
Lines 19 to 30 in 12ee3eb
switch (linsol_type) { | |
case LinearSolver::dense: | |
linsol_.reset(new SUNLinSolDense(x_)); | |
break; | |
case LinearSolver::KLU: | |
linsol_.reset(new SUNLinSolKLU(x_, model.nnz, CSC_MAT)); | |
break; | |
default: | |
throw NewtonFailure( | |
AMICI_NOT_IMPLEMENTED, "Unknown linear solver type" | |
); | |
} |
Some methods will have to be updated when more solvers are to be supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment+exception regarding the need for updating those two functions to support additional solvers.
if (auto s = dynamic_cast<SUNLinSolKLU const*>(linsol_.get())) { | ||
return s->is_singular(); | ||
} | ||
|
||
// dense solver doesn't have any implementation for rcond/condest, so use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about other direct/implicit solvers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above -- they haven't been supported before this PR, and they are still not supported yet. Although it would be pretty easy to extend that now....
cda7aac
to
00602c8
Compare
Use SUNLinSolWrapper. Get rid of subclasses. Simplify. Closes AMICI-dev#1164. We should also be able to get rid of the remaining data members, but that's for another time...
00602c8
to
39dfa38
Compare
Use SUNLinSolWrapper. Get rid of subclasses. Simplify.
Closes #1164.
We should also be able to get rid of the remaining data members,
but that's for another time...