Class SteadystateProblem¶
Defined in File steadystateproblem.h
Class Documentation¶
-
class
amici
::
SteadystateProblem
¶ The SteadystateProblem class solves a steady-state problem using Newton’s method and falls back to integration on failure.
Public Functions
-
void
workSteadyStateProblem
(Solver *solver, Model *model, int it)¶ Handles steady state computation in the forward case: tries to determine the steady state of the ODE system and computes steady state sensitivities if requested.
- Parameters
solver
: pointer to the solver objectmodel
: pointer to the model objectit
: integer with the index of the current time step
-
void
workSteadyStateBackwardProblem
(Solver *solver, Model *model, const BackwardProblem *bwd)¶ Integrates over the adjoint state backward in time by solving a linear system of equations, which gives the analytical solution. Computes the gradient via adjoint steady state sensitivities
- Parameters
solver
: pointer to the solver objectmodel
: pointer to the model objectbwd
: backward problem
-
void
findSteadyState
(Solver *solver, NewtonSolver *newtonSolver, Model *model, int it)¶ Handles the computation of the steady state, throws an AmiException, if no steady state was found.
- Parameters
solver
: pointer to the solver objectnewtonSolver
: pointer to the newtonSolver solver objectmodel
: pointer to the model objectit
: integer with the index of the current time step
-
void
findSteadyStateByNewtonsMethod
(NewtonSolver *newtonSolver, Model *model, bool newton_retry)¶ Tries to determine the steady state by using Newton’s method.
- Parameters
newtonSolver
: pointer to the newtonSolver solver objectmodel
: pointer to the model objectnewton_retry
: bool flag indicating whether being relaunched
-
void
findSteadyStateBySimulation
(const Solver *solver, Model *model, int it)¶ Tries to determine the steady state by using forward simulation.
- Parameters
solver
: pointer to the solver objectmodel
: pointer to the model objectit
: integer with the index of the current time step
-
void
computeSteadyStateQuadrature
(NewtonSolver *newtonSolver, const Solver *solver, Model *model)¶ Handles the computation of quadratures in adjoint mode.
- Parameters
newtonSolver
: pointer to the newtonSolver solver objectsolver
: pointer to the solver objectmodel
: pointer to the model object
-
void
getQuadratureByLinSolve
(NewtonSolver *newtonSolver, Model *model)¶ Computes the quadrature in steady state backward mode by solving the linear system defined by the backward Jacobian.
- Parameters
newtonSolver
: pointer to the newtonSolver solver objectmodel
: pointer to the model object
-
void
getQuadratureBySimulation
(const Solver *solver, Model *model)¶ Computes the quadrature in steady state backward mode by numerical integration of xB forward in time.
- Parameters
solver
: pointer to the solver objectmodel
: pointer to the model object
-
void
handleSteadyStateFailure
(const Solver *solver, Model *model)¶ Stores state and throws an exception if equilibration failed.
- Parameters
solver
: pointer to the solver objectmodel
: pointer to the model object
-
void
writeErrorString
(std::string *errorString, SteadyStateStatus status) const¶ Assembles the error message to be thrown.
- Parameters
errorString
: const pointer to string with error messagestatus
: Entry of steady_state_status to be processed
-
bool
getSensitivityFlag
(const Model *model, const Solver *solver, int it, SteadyStateContext context)¶ Checks depending on the status of the Newton solver, solver settings, and the model, whether state sensitivities still need to be computed via a linear system solve or stored.
- Return
flag telling how to process state sensitivities
- Parameters
model
: pointer to the model objectsolver
: pointer to the solver objectit
: integer with the index of the current time stepcontext
: SteadyStateContext giving the situation for the flag
-
realtype
getWrmsNorm
(AmiVector const &x, AmiVector const &xdot, realtype atol, realtype rtol, AmiVector &ewt) const¶ Computes the weighted root mean square of xdot the weights are computed according to x: w_i = 1 / ( rtol * x_i + atol )
- Return
root-mean-square norm
- Parameters
x
: current statexdot
: current rhsatol
: absolute tolerancertol
: relative toleranceewt
: error weight vector
-
bool
checkConvergence
(const Solver *solver, Model *model, SensitivityMethod checkSensitivities)¶ Checks convergence for state and respective sensitivities.
- Return
boolean indicating convergence
- Parameters
solver
: Solver instancemodel
: instancecheckSensitivities
: flag whether sensitivities should be checked
-
void
applyNewtonsMethod
(Model *model, NewtonSolver *newtonSolver, bool newton_retry)¶ Runs the Newton solver iterations and checks for convergence to steady state.
- Parameters
model
: pointer to the model objectnewtonSolver
: pointer to the NewtonSolver objectnewton_retry
: flag indicating if Newton solver is rerun
-
void
runSteadystateSimulation
(const Solver *solver, Model *model, bool backward)¶ Simulation is launched, if Newton solver or linear system solve fails.
- Parameters
solver
: pointer to the solver objectmodel
: pointer to the model objectbackward
: flag indicating adjoint mode (including quadrature)
-
std::unique_ptr<Solver>
createSteadystateSimSolver
(const Solver *solver, Model *model, bool forwardSensis, bool backward) const¶ Initialize CVodeSolver instance for preequilibration simulation.
- Return
solver instance
- Parameters
solver
: pointer to the solver objectmodel
: pointer to the model objectforwardSensis
: flag switching on integration with FSAbackward
: flag switching on quadratures computation
-
bool
initializeBackwardProblem
(Solver *solver, Model *model, const BackwardProblem *bwd)¶ Initialize backward computation by setting state, time, adjoint state and checking for preequilibration mode.
- Return
flag indicating whether backward computation to be carried out
- Parameters
solver
: pointer to the solver objectmodel
: pointer to the model objectbwd
: pointer to backward problem
-
void
computeQBfromQ
(Model *model, const AmiVector &yQ, AmiVector &yQB) const¶ Compute the backward quadratures, which contribute to the gradient (xQB) from the quadrature over the backward state itself (xQ)
- Parameters
model
: pointer to the model objectyQ
: vector to be multiplied with dxdotdpyQB
: resulting vector after multiplication
-
void
storeSimulationState
(Model *model, bool storesensi)¶ Store carbon copy of current simulation state variables as SimulationState.
- Parameters
model
: model carrying the ModelState to be usedstoresensi
: flag to enable storage of sensitivities
-
const SimulationState &
getFinalSimulationState
() const¶ Returns the stored SimulationState.
- Return
stored SimulationState
-
const AmiVector &
getEquilibrationQuadratures
() const¶ Returns the quadratures from pre- or postequilibration.
- Return
xQB Vector with quadratures
-
const AmiVectorArray &
getStateSensitivity
() const¶ Returns state sensitivity at steadystate.
- Return
sx
-
double
getCPUTime
() const¶ Accessor for run_time of the forward problem.
- Return
run_time
-
double
getCPUTimeB
() const¶ Accessor for run_time of the backward problem.
- Return
run_time
-
std::vector<SteadyStateStatus> const &
getSteadyStateStatus
() const¶ Accessor for steady_state_status.
- Return
steady_state_status
-
const std::vector<int> &
getNumSteps
() const¶ Accessor for numsteps.
- Return
numsteps
-
int
getNumStepsB
() const¶ Accessor for numstepsB.
- Return
numstepsB
-
const std::vector<int> &
getNumLinSteps
() const¶ Accessor for numlinsteps.
- Return
numlinsteps
-
void
getAdjointUpdates
(Model &model, const ExpData &edata)¶ computes adjoint updates dJydx according to provided model and expdata
- Parameters
model
: Model instanceedata
: experimental data
-
bool
hasQuadrature
() const¶ Accessor for hasQuadrature_.
- Return
hasQuadrature_
-
bool
checkSteadyStateSuccess
() const¶ computes adjoint updates dJydx according to provided model and expdata
- Return
convergence of steady state solver
-
void