roadrunner  2.6.0
Fast simulator for SBML models
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rr::NewtonIteration Class Reference

Implementation of the newton iteration form of the kinsol steady state solver. More...

#include <NewtonIteration.h>

Inheritance diagram for rr::NewtonIteration:
rr::KinsolSteadyStateSolver rr::SteadyStateSolver rr::Solver rr::Registrable rr::BasicNewtonIteration rr::LinesearchNewtonIteration

Public Member Functions

 NewtonIteration (ExecutableModel *executableModel)
 
std::string getName () const override
 Get the name of this solver.
 
std::string getDescription () const override
 Get the description of this solver.
 
std::string getHint () const override
 Get a (user-readable) hint for this solver.
 
void resetSettings () override
 reset settings back to default.
 
void getSolverStatsFromKinsol () override
 after solve() has been called, this method collects some details such as number of function evals
 
 KinsolSteadyStateSolver (ExecutableModel *executableModel)
 constructor for creating KinsolSteadyStateSolver from an executable model only. More...
 
 KinsolSteadyStateSolver ()=default
 The default constructor for constructing without a model. More...
 
- Public Member Functions inherited from rr::KinsolSteadyStateSolver
 KinsolSteadyStateSolver (ExecutableModel *executableModel)
 constructor for creating KinsolSteadyStateSolver from an executable model only. More...
 
 KinsolSteadyStateSolver ()=default
 The default constructor for constructing without a model. More...
 
 ~KinsolSteadyStateSolver () override=default
 virtual destructor
 
void syncWithModel (ExecutableModel *m) override
 implementation of Solver::syncWithModel. More...
 
void setFScale (double value)
 set all elements of the fscale variable to More...
 
void setFScale (const std::vector< double > &value)
 set elements of the fscale variable to More...
 
void setUScale (double value)
 set all elements of the uscale variable to More...
 
void setUScale (std::vector< double > value)
 set elements of the uscale variable to value. More...
 
double solveForSteadyState (KinsolSteadyStateSolver *solverInstance, int kinsolStrategy)
 Generic solver method. More...
 
void * getKinsolMemory () const
 getter for the underlying memory block that is used by kinsol. More...
 
std::unordered_map< std::string, Setting > & getSolverStats ()
 return a mapping containing solver statistics. More...
 
void printSolverStats ()
 display solver stats to console
 
- Public Member Functions inherited from rr::SteadyStateSolver
virtual double solve ()=0
 
virtual void loadConfigSettings ()
 
std::string toString () const override
 Return a std::string representation of the solver. More...
 
std::string toRepr () const override
 Return std::string representation a la Python repr method. More...
 
void resetSettings () override
 Implements settings shared by all steady state solvers.
 
 Solver ()=default
 
 Solver (ExecutableModel *model)
 
- Public Member Functions inherited from rr::Solver
 Solver (ExecutableModel *model)
 
void updateSettings (Dictionary *inputSettings)
 Update settings values. More...
 
std::vector< std::string > getSettings () const
 Get a list of all settings for this solver. More...
 
std::unordered_map< std::string, Setting > & getSettingsMap ()
 get settings for this solver More...
 
virtual Setting getValue (const std::string &key) const
 Get the value of an integrator setting. More...
 
virtual Setting hasValue (const std::string &key) const
 Return true if this setting is supported by the integrator. More...
 
virtual size_t getNumParams () const
 Get the number of parameters. More...
 
virtual std::string getParamName (size_t n) const
 Get the name of the parameter at index n. More...
 
virtual std::string getParamDisplayName (int n) const
 Get the display name of the parameter at index n. More...
 
virtual std::string getParamHint (int n) const
 Get the hint of the parameter at index n. More...
 
virtual std::string getParamDesc (int n) const
 Get the description of the parameter at index n. More...
 
virtual std::string getValueAsString (const std::string &key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual void setValue (const std::string &key, Setting value)
 
virtual std::string getSettingsRepr () const
 Get the solver settings as a std::string. More...
 
virtual std::string settingsPyDictRepr () const
 Python dictionary-style std::string representation of settings. More...
 
const std::string & getDisplayName (const std::string &key) const
 Gets the hint associated with a given key. More...
 
const std::string & getHint (const std::string &key) const
 Gets the hint associated with a given key. More...
 
const std::string & getDescription (const std::string &key) const
 Gets the description associated with a given key. More...
 
Setting::TypeId getType (const std::string &key) const
 Gets the type associated with a given key. More...
 
virtual ExecutableModelgetModel () const
 returns the pointer to the ExecutableModel
 
virtual std::string getName () const=0
 Gets the name associated with this Solver type. More...
 
virtual std::string getHint () const=0
 Gets the hint associated with this Solver type. More...
 
virtual std::string getDescription () const=0
 Gets the description associated with this Solver type. More...
 
- Public Member Functions inherited from rr::Registrable
virtual Solverconstruct (ExecutableModel *model) const =0
 Constructs a new Solver of a given type. More...
 

Protected Member Functions

double solveNewtonIteration (const std::string &strategy)
 solve the currently defined problem
 
void createKinsol () override
 Initialize kinsol objects. More...
 
void freeKinsol () override
 Destory kinsol objects. More...
 
void updateKinsol () override
 Calls methods for updating options in kinsol. More...
 
- Protected Member Functions inherited from rr::Solver
void addSetting (const std::string &name, const Setting &val, const std::string &display_name, const std::string &hint, const std::string &description)
 

Protected Attributes

SUNMatrix jac = nullptr
 matrix for jacobian
 
SUNLinearSolver linearSolver = nullptr
 linear solver for newton methods
 
- Protected Attributes inherited from rr::KinsolSteadyStateSolver
void * mKinsol_Memory = nullptr
 Pointer to the kinsol memory block.
 
N_Vector mStateVector = nullptr
 a sundials N_Vector for storing system state variables
 
N_Vector fscale = nullptr
 std::vector containing diagonal elements of scaling matrix DF for F(u) chosen so that the components of D_F*F(u) (as a matrix multiplication) all have roughly the same magnitude when u is not too near a root of F(u). More...
 
N_Vector uscale = nullptr
 std::vector containing diagonal elements of scaling matrix Du for std::vector u chosen so that the components of D_u*u (as a matrix multiplication) all have roughly the same magnitude when u is close to a root of F(u). More...
 
N_Vector constraints = nullptr
 vector of constraints used to ensure positive solution. More...
 
long int numFuncEvals
 kinsol output variables. More...
 
long int numNolinSolvIters
 
long int numBetaCondFails
 
long int numBacktrackOps
 
double funcNorm
 
double stepLength
 
long int numJacEvals
 
long int numJtimesEvals
 
long int numLinConvFails
 
long int numLinFuncEvals
 
long int numLinIters
 
long int numNonlinSolvIters
 
long int numPrecEvals
 
long int numPrecSolves
 
long int nSolverIterations = 0
 stores the number of iterations required by the solver to converge. More...
 
std::unordered_map< std::string, SettingsolverStats
 
- Protected Attributes inherited from rr::Solver
ExecutableModelmModel = nullptr
 non-owning pointer to model
 

Additional Inherited Members

- Public Types inherited from rr::Solver
using SettingsList = std::vector< std::string >
 
using SettingsMap = std::unordered_map< std::string, Setting >
 
using DisplayNameMap = std::unordered_map< std::string, std::string >
 
using HintMap = std::unordered_map< std::string, std::string >
 
using DescriptionMap = std::unordered_map< std::string, std::string >
 
- Static Public Member Functions inherited from rr::KinsolSteadyStateSolver
template<class KinsolSteadyStateSolverType >
static int kinsolDyDtFcn (N_Vector stateVecIn, N_Vector stateVecOut, void *userData)
 kinsol callback function that implements system equations More...
 
- Public Attributes inherited from rr::Solver
SettingsList sorted_settings
 
SettingsMap settings
 
DisplayNameMap display_names_
 
HintMap hints
 
DescriptionMap descriptions
 

Detailed Description

Implementation of the newton iteration form of the kinsol steady state solver.

Member Function Documentation

◆ createKinsol()

void rr::NewtonIteration::createKinsol ( )
overrideprotectedvirtual

Initialize kinsol objects.

All subclasses require some of the same initial calls (such as N_VNew_Serial and KINCreate).

Reimplemented from rr::KinsolSteadyStateSolver.

◆ freeKinsol()

void rr::NewtonIteration::freeKinsol ( )
overrideprotectedvirtual

Destory kinsol objects.

Destroys the kinsol objects that are shared among KinsolSteadyStateSolvers

Reimplemented from rr::KinsolSteadyStateSolver.

◆ KinsolSteadyStateSolver() [1/2]

rr::KinsolSteadyStateSolver::KinsolSteadyStateSolver
default

The default constructor for constructing without a model.

useful only for testing.

◆ KinsolSteadyStateSolver() [2/2]

rr::KinsolSteadyStateSolver::KinsolSteadyStateSolver
explicit

constructor for creating KinsolSteadyStateSolver from an executable model only.

This constructor should be inherited by subclasses

◆ updateKinsol()

void rr::NewtonIteration::updateKinsol ( )
overrideprotectedvirtual

Calls methods for updating options in kinsol.

The settings configuration system in roadrunner make this particular aspect of interacting with sundials libraries a little akward.

User passes in arguments like uScale and they are stored at the class level. This method passed them on to kinsol.

When a user updates a setting with setValue, they are only updating the value in roadrunner. The change doesn't occur in sundials until we call the corresponding sundials function with the new value. We cannot use regular "setters" because they won't get called when a user changes a value. Instead, here we update all kinsol options at once, and this method is called before we call KIN_Solve.

Reimplemented from rr::KinsolSteadyStateSolver.


The documentation for this class was generated from the following files: