Class SteadystateProblem

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

SteadystateProblem(const Solver &solver, const Model &model)

constructor

Parameters

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 object

  • model: pointer to the model object

  • it: 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 object

  • model: pointer to the model object

  • bwd: 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 object

  • newtonSolver: pointer to the newtonSolver solver object

  • model: pointer to the model object

  • it: 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 object

  • model: pointer to the model object

  • newton_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 object

  • model: pointer to the model object

  • it: 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 object

  • solver: pointer to the solver object

  • model: 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 object

  • model: 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 object

  • model: 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 object

  • model: 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 message

  • status: 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 object

  • solver: pointer to the solver object

  • it: integer with the index of the current time step

  • context: 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 state

  • xdot: current rhs

  • atol: absolute tolerance

  • rtol: relative tolerance

  • ewt: 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 instance

  • model: instance

  • checkSensitivities: 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 object

  • newtonSolver: pointer to the NewtonSolver object

  • newton_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 object

  • model: pointer to the model object

  • backward: 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 object

  • model: pointer to the model object

  • forwardSensis: flag switching on integration with FSA

  • backward: 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 object

  • model: pointer to the model object

  • bwd: 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 object

  • yQ: vector to be multiplied with dxdotdp

  • yQB: 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 used

  • storesensi: 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 AmiVector &getState() const

Returns state at steadystate.

Return

x

const AmiVectorArray &getStateSensitivity() const

Returns state sensitivity at steadystate.

Return

sx

std::vector<realtype> const &getDJydx() const

Accessor for dJydx.

Return

dJydx

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

realtype getSteadyStateTime() const

Accessor for t.

Return

t

realtype getResidualNorm() const

Accessor for wrms.

Return

wrms

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 instance

  • edata: experimental data

AmiVector const &getAdjointState() const

Return the adjoint state.

Return

xB adjoint state

AmiVector const &getAdjointQuadrature() const

Accessor for xQB.

Return

xQB

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