-
Notifications
You must be signed in to change notification settings - Fork 2
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
Parameter management utilities #163
base: develop
Are you sure you want to change the base?
Conversation
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.
I don't really have substantial feedback...
@@ -129,17 +129,23 @@ int test(int argc, char *argv[]) | |||
real_type norm_b = 0.0; | |||
|
|||
// Set solver options | |||
real_type tol = 1e-12; | |||
//real_type tol = 1e-12; |
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.
//real_type tol = 1e-12; |
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.
Good catch!
solver.getIterativeSolver().setMaxit(2500); | ||
solver.getIterativeSolver().setTol(tol); | ||
// solver.getIterativeSolver().setTol(tol); |
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.
// solver.getIterativeSolver().setTol(tol); |
|
||
matrix_handler.setValuesChanged(true, memspace); | ||
|
||
// Set system matrix and initialize iterative solver | ||
status = solver.setMatrix(A); | ||
error_sum += status; | ||
|
||
solver.getIterativeSolver().setRestart(200); | ||
// solver.getIterativeSolver().setRestart(200); |
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.
// solver.getIterativeSolver().setRestart(200); |
int LinSolverIterativeRandFGMRES::getCliParam(const std::string id, std::string& /* value */) | ||
{ | ||
switch (params_list_[id]) | ||
{ | ||
default: | ||
out::error() << "Unknown string parameter " << id << "\n"; | ||
return 1; | ||
} | ||
return 0; | ||
} |
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.
I am a little confused about the purpose of this function. Is that to say no parameters have a string as their value?
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.
You are right. Randomized FGMRES solver does not have configuration parameters that are of string type. This method is just a placeholder. Need to document this better.
|
https://en.cppreference.com/w/cpp/language/raii is an idea that applies to configuration - ideally, an object is completely configured and ready to use as soon as it is constructed. Are these configurable solver objects configured with the parsed configuration options in their constructors? Or is the functionality here used to set that up after the fact? |
Since Re::Solve is used for solving series of similar linear systems it is conceivable that one might want to change its parameters at runtime. In that case, Re::Solve would need to ensure that the choice of solver configuration parameters is self-consistent and that correct workspace is allocated. |
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.
These changes are a big step in the right direction. According to https://en.wikipedia.org/wiki/Single-responsibility_principle, it is usually best to map each separate definable functionality to a separately testable object. The LinSolver base class appears to handle 3 things: parameter management, norm/residual calculation, and matrix equation solution. Is it possible for LinSolver to offload the first two into other classes to a greater degree? Would that increase the composability of the design in a desirable way?
return 1; | ||
} | ||
|
||
virtual int getCliParam(const std::string /* id */, index_type& /* value */) |
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.
Could these functions be pure virtual? This is possible if and only if they are always overridden in derived classes; otherwise a default implementation like this is required.
I suggest we keep this as draft for now. We need to merge #198 and probably do some other fixes as we discover them through this preview PR. Thanks all for useful feedback so far. |
Managing different solver parameters in Re::Solve becomes a nontrivial task and there is a need for consistent parameter management across all Re::Solve modules. In addition to setting up file I/O for initializing solver parameters, the scope here includes creating a common interface for setting and retrieving parameters for all solver classes and ability to change solver configuration parameters at runtime. The requirements are:
This draft PR is a proposal how to handle this. Parameter management is implemented only for classes
LinSolverIterativeFGMRES
andLinSolverIterativeRandGMRES
for now.Closes #96