# amici.amici.Solver¶

class amici.amici.Solver(*args, **kwargs)[source]

The Solver class provides a generic interface to CVODES and IDAS solvers, individual realizations are realized in the CVodeSolver and the IDASolver class. All transient private/protected members (CVODES/IDAS memory, interface variables and status flags) are specified as mutable and not included in serialization or equality checks. No solver setting parameter should be marked mutable.

NOTE: Any changes in data members here must be propagated to copy ctor, equality operator, serialization functions in serialization.h, and amici::hdf5::readSolverSettingsFromHDF5 in hdf5.cpp.

__init__(*args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods Summary

 __init__(*args, **kwargs) Initialize self. calcIC(tout1) Calculates consistent initial conditions, assumes initial states to be correct (DAE only) calcICB(which, tout1) Calculates consistent initial conditions for the backwards problem, assumes initial states to be correct (DAE only) Clone this instance check if ASA is being computed check if FSA is being computed Get the absolute tolerances for the forward problem Returns the absolute tolerances for the backward problem for adjoint sensitivity analysis Returns the absolute tolerances for the forward sensitivity problem returns the absolute tolerance for the quadrature problem returns the absolute tolerance for the steady state problem returns the absolute tolerance for the sensitivities of the steady state problem Reads out the CPU time needed for forward solve Reads out the CPU time needed for backward solve returns the internal sensitivity method rtype int Accessor order returns the linear system multistep method rtype int returns the maximum number of solver steps for the forward problem returns the maximum number of solver steps for the backward problem Get a lower bound of the damping factor used in the Newton solver Get a state of the damping factor used in the Newton solver Get maximum number of allowed linear steps per Newton step for steady state computation Get maximum number of allowed Newton steps for steady state computation returns the nonlinear system solution method Accessor netf Accessor netfB Accessor nnlscf Accessor nnlscfB Accessor nrhs Accessor nrhsB Accessor ns Accessor nsB Get if model preequilibration is enabled Get the relative tolerances for the forward problem Returns the relative tolerances for the adjoint sensitivity problem Returns the relative tolerances for the forward sensitivity problem Returns the relative tolerance for the quadrature problem returns the relative tolerance for the steady state problem returns the relative tolerance for the sensitivities of the steady state problem returns the ReturnData reporting mode getRootInfo(rootsfound) getRootInfo extracts information which event occurred Return current sensitivity method Return current sensitivity method during preequilibration Get sensitivity order returns stability limit detection mode Gets KLU / SuperLUMT state ordering mode current solver timepoint number of parameters with which the solver was initialized number of quadratures with which the solver was initialized number of states with which the solver was initialized Resets vectors containing diagnosis information run(tout) runs a forward simulation until the specified timepoint runB(tout) runs a backward simulation until the specified timepoint Switches off computation of state sensitivities without deallocating the memory for sensitivities Sets the absolute tolerances for the forward problem Sets the absolute tolerances for the backward problem for adjoint sensitivity analysis Sets the absolute tolerances for the forward sensitivity problem sets the absolute tolerance for the quadrature problem sets the absolute tolerance for the steady state problem sets the absolute tolerance for the sensitivities of the steady state problem sets the internal sensitivity method setInterpolationType(interpType) sets the interpolation of the forward solution that is used for the backwards problem sets the linear system multistep method setLinearSolver(linsol) type linsol int setMaxSteps(maxsteps) sets the maximum number of solver steps for the forward problem setMaxStepsBackwardProblem(maxsteps) sets the maximum number of solver steps for the backward problem Set a lower bound of the damping factor in the Newton solver setNewtonDampingFactorMode(dampingFactorMode) Turn on/off a damping factor in the Newton method setNewtonMaxLinearSteps(newton_maxlinsteps) Set maximum number of allowed linear steps per Newton step for steady state computation setNewtonMaxSteps(newton_maxsteps) Set maximum number of allowed Newton steps for steady state computation sets the nonlinear system solution method setPreequilibration(require_preequilibration) Enable/disable model preequilibration Sets the relative tolerances for the forward problem Sets the relative tolerances for the adjoint sensitivity problem Sets the relative tolerances for the forward sensitivity problem sets the relative tolerance for the quadrature problem sets the relative tolerance for the steady state problem sets the relative tolerance for the sensitivities of the steady state problem sets the ReturnData reporting mode setSensitivityMethod(sensi_meth) Set sensitivity method Set sensitivity method for preequilibration Set the sensitivity order setStabilityLimitFlag(stldet) set stability limit detection mode setStateOrdering(ordering) Sets KLU / SuperLUMT state ordering mode solveB(tBout, itaskB) Solves the backward problem until a predefined timepoint (adjoint only) step(tout) makes a single step in the simulation Stores diagnosis information from solver memory block for forward problem storeDiagnosisB(which) Stores diagnosis information from solver memory block for backward problem Disable forward sensitivity integration (used in steady state sim) Disable rootfinding Reinitializes state and respective sensitivities (if necessary) according to changes in fixedParameters

Attributes

 app AMICI context

Methods

__init__(*args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

calcIC(tout1: float)None[source]

Calculates consistent initial conditions, assumes initial states to be correct (DAE only)

Parameters

tout1 (float) – next timepoint to be computed (sets timescale)

Return type

None

calcICB(which: int, tout1: float)None[source]

Calculates consistent initial conditions for the backwards problem, assumes initial states to be correct (DAE only)

Parameters
Return type

None

clone() → Iterable[][source]

Clone this instance

Return type

Returns

The clone

computingASA()bool[source]

check if ASA is being computed

Return type

boolean

Returns

flag

computingFSA()bool[source]

check if FSA is being computed

Return type

boolean

Returns

flag

getAbsoluteTolerance()float[source]

Get the absolute tolerances for the forward problem

Same tolerance is used for the backward problem if not specified differently via setAbsoluteToleranceASA.

Return type

float

Returns

absolute tolerances

getAbsoluteToleranceB()float[source]

Returns the absolute tolerances for the backward problem for adjoint sensitivity analysis

Return type

float

Returns

absolute tolerances

getAbsoluteToleranceFSA()float[source]

Returns the absolute tolerances for the forward sensitivity problem

Return type

float

Returns

absolute tolerances

getAbsoluteToleranceQuadratures()float[source]

returns the absolute tolerance for the quadrature problem

Return type

float

Returns

absolute tolerance

getAbsoluteToleranceSteadyState()float[source]

returns the absolute tolerance for the steady state problem

Return type

float

Returns

absolute tolerance

getAbsoluteToleranceSteadyStateSensi()float[source]

returns the absolute tolerance for the sensitivities of the steady state problem

Return type

float

Returns

absolute tolerance

getCpuTime()float[source]

Reads out the CPU time needed for forward solve

Return type

float

Returns

cpu_time

getCpuTimeB()float[source]

Reads out the CPU time needed for backward solve

Return type

float

Returns

cpu_timeB

getInternalSensitivityMethod()[source]

returns the internal sensitivity method

Return type

int

Returns

internal sensitivity method

getInterpolationType()[source]
Return type

int

Returns

getLastOrder()[source]

Accessor order

Return type

Returns

order

getLinearMultistepMethod()[source]

returns the linear system multistep method

Return type

int

Returns

linear system multistep method

getLinearSolver()[source]
Return type

int

Returns

getMaxSteps()int[source]

returns the maximum number of solver steps for the forward problem

Return type

int

Returns

maximum number of solver steps

getMaxStepsBackwardProblem()int[source]

returns the maximum number of solver steps for the backward problem

Return type

int

Returns

maximum number of solver steps

getNewtonDampingFactorLowerBound()float[source]

Get a lower bound of the damping factor used in the Newton solver

Return type

float

Returns

getNewtonDampingFactorMode()[source]

Get a state of the damping factor used in the Newton solver

Return type

int

Returns

getNewtonMaxLinearSteps()int[source]

Get maximum number of allowed linear steps per Newton step for steady state computation

Return type

int

Returns

getNewtonMaxSteps()int[source]

Get maximum number of allowed Newton steps for steady state computation

Return type

int

Returns

getNonlinearSolverIteration()[source]

returns the nonlinear system solution method

Return type

int

Returns

getNumErrTestFails()[source]

Accessor netf

Return type

Returns

netf

getNumErrTestFailsB()[source]

Accessor netfB

Return type

Returns

netfB

getNumNonlinSolvConvFails()[source]

Accessor nnlscf

Return type

Returns

nnlscf

getNumNonlinSolvConvFailsB()[source]

Accessor nnlscfB

Return type

Returns

nnlscfB

getNumRhsEvals()[source]

Accessor nrhs

Return type

Returns

nrhs

getNumRhsEvalsB()[source]

Accessor nrhsB

Return type

Returns

nrhsB

getNumSteps()[source]

Accessor ns

Return type

Returns

ns

getNumStepsB()[source]

Accessor nsB

Return type

Returns

nsB

getPreequilibration()bool[source]

Get if model preequilibration is enabled

Return type

boolean

Returns

getRelativeTolerance()float[source]

Get the relative tolerances for the forward problem

Same tolerance is used for the backward problem if not specified differently via setRelativeToleranceASA.

Return type

float

Returns

relative tolerances

getRelativeToleranceB()float[source]

Returns the relative tolerances for the adjoint sensitivity problem

Return type

float

Returns

relative tolerances

getRelativeToleranceFSA()float[source]

Returns the relative tolerances for the forward sensitivity problem

Return type

float

Returns

relative tolerances

getRelativeToleranceQuadratures()float[source]

Returns the relative tolerance for the quadrature problem

Return type

float

Returns

relative tolerance

getRelativeToleranceSteadyState()float[source]

returns the relative tolerance for the steady state problem

Return type

float

Returns

relative tolerance

getRelativeToleranceSteadyStateSensi()float[source]

returns the relative tolerance for the sensitivities of the steady state problem

Return type

float

Returns

relative tolerance

getReturnDataReportingMode()[source]

returns the ReturnData reporting mode

Return type

int

Returns

ReturnData reporting mode

getRootInfo(rootsfound: Iterable[int])None[source]

getRootInfo extracts information which event occurred

Parameters

rootsfound (typing.Iterable[int]) – array with flags indicating whether the respective event occurred

Return type

None

getSensitivityMethod()[source]

Return current sensitivity method

Return type

int

Returns

method enum

getSensitivityMethodPreequilibration()[source]

Return current sensitivity method during preequilibration

Return type

int

Returns

method enum

getSensitivityOrder()[source]

Get sensitivity order

Return type

int

Returns

sensitivity order

getStabilityLimitFlag()bool[source]

returns stability limit detection mode

Return type

boolean

Returns

stldet can be false (deactivated) or true (activated)

getStateOrdering()int[source]

Gets KLU / SuperLUMT state ordering mode

Return type

int

Returns

State-ordering as integer according to SUNLinSolKLU::StateOrdering or SUNLinSolSuperLUMT::StateOrdering (which differ).

gett()float[source]

current solver timepoint

Return type

float

Returns

t

nplist()int[source]

number of parameters with which the solver was initialized

Return type

int

Returns

sx.getLength()

nquad()int[source]

number of quadratures with which the solver was initialized

Return type

int

Returns

xQB.getLength()

nx()int[source]

number of states with which the solver was initialized

Return type

int

Returns

x.getLength()

resetDiagnosis()None[source]

Resets vectors containing diagnosis information

Return type

None

run(tout: float)int[source]

runs a forward simulation until the specified timepoint

Parameters

tout (float) – next timepoint

Return type

int

Returns

status flag

runB(tout: float)None[source]

runs a backward simulation until the specified timepoint

Parameters

tout (float) – next timepoint

Return type

None

sensToggleOff()None[source]

Switches off computation of state sensitivities without deallocating the memory for sensitivities

Return type

None

setAbsoluteTolerance(atol: float)None[source]

Sets the absolute tolerances for the forward problem

Same tolerance is used for the backward problem if not specified differently via setAbsoluteToleranceASA.

Parameters

atol (float) – absolute tolerance (non-negative number)

Return type

None

setAbsoluteToleranceB(atol: float)None[source]

Sets the absolute tolerances for the backward problem for adjoint sensitivity analysis

Parameters

atol (float) – absolute tolerance (non-negative number)

Return type

None

setAbsoluteToleranceFSA(atol: float)None[source]

Sets the absolute tolerances for the forward sensitivity problem

Parameters

atol (float) – absolute tolerance (non-negative number)

Return type

None

setAbsoluteToleranceQuadratures(atol: float)None[source]

sets the absolute tolerance for the quadrature problem

Parameters

atol (float) – absolute tolerance (non-negative number)

Return type

None

setAbsoluteToleranceSteadyState(atol: float)None[source]

sets the absolute tolerance for the steady state problem

Parameters

atol (float) – absolute tolerance (non-negative number)

Return type

None

setAbsoluteToleranceSteadyStateSensi(atol: float)None[source]

sets the absolute tolerance for the sensitivities of the steady state problem

Parameters

atol (float) – absolute tolerance (non-negative number)

Return type

None

setInternalSensitivityMethod(ism: )None[source]

sets the internal sensitivity method

Parameters

ism () – internal sensitivity method

Return type

None

setInterpolationType(interpType: )None[source]

sets the interpolation of the forward solution that is used for the backwards problem

Parameters

interpType () – interpolation type

Return type

None

setLinearMultistepMethod(lmm: )None[source]

sets the linear system multistep method

Parameters

lmm () – linear system multistep method

Return type

None

setLinearSolver(linsol: )None[source]
Parameters

linsol () –

Return type

None

setMaxSteps(maxsteps: int)None[source]

sets the maximum number of solver steps for the forward problem

Parameters

maxsteps (int) – maximum number of solver steps (positive number)

Return type

None

setMaxStepsBackwardProblem(maxsteps: int)None[source]

sets the maximum number of solver steps for the backward problem

Parameters

maxsteps (int) – maximum number of solver steps (non-negative number)

Notes: default behaviour (100 times the value for the forward problem) can be restored by passing maxsteps=0

Return type

None

setNewtonDampingFactorLowerBound(dampingFactorLowerBound: float)None[source]

Set a lower bound of the damping factor in the Newton solver

Parameters

dampingFactorLowerBound (float) –

Return type

None

setNewtonDampingFactorMode(dampingFactorMode: )None[source]

Turn on/off a damping factor in the Newton method

Parameters

dampingFactorMode () –

Return type

None

setNewtonMaxLinearSteps(newton_maxlinsteps: int)None[source]

Set maximum number of allowed linear steps per Newton step for steady state computation

Parameters

newton_maxlinsteps (int) –

Return type

None

setNewtonMaxSteps(newton_maxsteps: int)None[source]

Set maximum number of allowed Newton steps for steady state computation

Parameters

newton_maxsteps (int) –

Return type

None

setNonlinearSolverIteration(iter: )None[source]

sets the nonlinear system solution method

Parameters

iter () – nonlinear system solution method

Return type

None

setPreequilibration(require_preequilibration: bool)None[source]

Enable/disable model preequilibration

Parameters

require_preequilibration (bool) –

Return type

None

setRelativeTolerance(rtol: float)None[source]

Sets the relative tolerances for the forward problem

Same tolerance is used for the backward problem if not specified differently via setRelativeToleranceASA.

Parameters

rtol (float) – relative tolerance (non-negative number)

Return type

None

setRelativeToleranceB(rtol: float)None[source]

Sets the relative tolerances for the adjoint sensitivity problem

Parameters

rtol (float) – relative tolerance (non-negative number)

Return type

None

setRelativeToleranceFSA(rtol: float)None[source]

Sets the relative tolerances for the forward sensitivity problem

Parameters

rtol (float) – relative tolerance (non-negative number)

Return type

None

setRelativeToleranceQuadratures(rtol: float)None[source]

sets the relative tolerance for the quadrature problem

Parameters

rtol (float) – relative tolerance (non-negative number)

Return type

None

setRelativeToleranceSteadyState(rtol: float)None[source]

sets the relative tolerance for the steady state problem

Parameters

rtol (float) – relative tolerance (non-negative number)

Return type

None

setRelativeToleranceSteadyStateSensi(rtol: float)None[source]

sets the relative tolerance for the sensitivities of the steady state problem

Parameters

rtol (float) – relative tolerance (non-negative number)

Return type

None

setReturnDataReportingMode(rdrm: )None[source]

sets the ReturnData reporting mode

Parameters

rdrm () – ReturnData reporting mode

Return type

None

setSensitivityMethod(sensi_meth: )None[source]

Set sensitivity method

Parameters

sensi_meth () –

Return type

None

setSensitivityMethodPreequilibration(sensi_meth_preeq: )None[source]

Set sensitivity method for preequilibration

Parameters

sensi_meth_preeq () –

Return type

None

setSensitivityOrder(sensi: )None[source]

Set the sensitivity order

Parameters

sensi () – sensitivity order

Return type

None

setStabilityLimitFlag(stldet: bool)None[source]

set stability limit detection mode

Parameters

stldet (bool) – can be false (deactivated) or true (activated)

Return type

None

setStateOrdering(ordering: int)None[source]

Sets KLU / SuperLUMT state ordering mode

This only applies when linsol is set to LinearSolver::KLU or LinearSolver::SuperLUMT. Mind the difference between SUNLinSolKLU::StateOrdering and SUNLinSolSuperLUMT::StateOrdering.

Parameters

ordering (int) – state ordering

Return type

None

solveB(tBout: float, itaskB: int)None[source]

Solves the backward problem until a predefined timepoint (adjoint only)

Parameters
Return type

None

step(tout: float)int[source]

makes a single step in the simulation

Parameters

tout (float) – next timepoint

Return type

int

Returns

status flag

storeDiagnosis()None[source]

Stores diagnosis information from solver memory block for forward problem

Return type

None

storeDiagnosisB(which: int)None[source]

Stores diagnosis information from solver memory block for backward problem

Parameters

which (int) – identifier of the backwards problem

Return type

None

switchForwardSensisOff()None[source]

Disable forward sensitivity integration (used in steady state sim)

Return type

None

turnOffRootFinding()None[source]

Disable rootfinding

Return type

None

updateAndReinitStatesAndSensitivities(model: )None[source]

Reinitializes state and respective sensitivities (if necessary) according to changes in fixedParameters

Parameters

model () – pointer to the model instance

Return type

None