# 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::(read/write)SolverSettings(From/To)HDF5 in hdf5.cpp.

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

Methods Summary

 __init__(*args, **kwargs) 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 InterpolationType Accessor order returns the linear system multistep method rtype LinearSolver returns the maximum number of solver steps for the forward problem returns the maximum number of solver steps for the backward problem Returns the maximum time allowed for integration 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 Newton steps for steady state computation Returns how convergence checks for steadystate computation are performed. returns the nonlinear system solution method Accessor netf Accessor netfB Accessor nnlscf Accessor nnlscfB Accessor nrhs Accessor nrhsB Accessor ns Accessor nsB 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 Returns how convergence checks for steadystate computation are performed. Return current sensitivity method Return current sensitivity method during preequilibration Get sensitivity order returns stability limit detection mode Gets KLU / SuperLUMT state ordering mode returns the steady state sensitivity simulation tolerance factor. returns the steady state simulation tolerance factor. 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 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 LinearSolver 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 setMaxTime(maxtime) Set the maximum time allowed for integration Set a lower bound of the damping factor in the Newton solver setNewtonDampingFactorMode(dampingFactorMode) Turn on/off a damping factor in the Newton method setNewtonMaxSteps(newton_maxsteps) Set maximum number of allowed Newton steps for steady state computation Sets how convergence checks for steadystate computation are performed. sets the nonlinear system solution method 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 Sets for which variables convergence checks for steadystate computation are performed. 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 set the steady state sensitivity simulation tolerance factor. set the steady state simulation tolerance factor. Start timer for tracking integration time Disable forward sensitivity integration (used in steady state sim) Check whether maximum integration time was exceeded

Attributes

 app AMICI context

Methods

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

Clone this instance

Return type

Solver

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() [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() [source]

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

Return type

float

Returns

absolute tolerances

getAbsoluteToleranceFSA() [source]

Returns the absolute tolerances for the forward sensitivity problem

Return type

float

Returns

absolute tolerances

returns the absolute tolerance for the quadrature problem

Return type

float

Returns

absolute tolerance

returns the absolute tolerance for the steady state problem

Return type

float

Returns

absolute tolerance

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

Return type

float

Returns

absolute tolerance

getCpuTime() [source]

Reads out the CPU time needed for forward solve

Return type

float

Returns

cpu_time

getCpuTimeB() [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

InternalSensitivityMethod

Returns

internal sensitivity method

getInterpolationType() [source]
Return type

InterpolationType

Returns

getLastOrder() [source]

Accessor order

Return type

IntVector

Returns

order

getLinearMultistepMethod() [source]

returns the linear system multistep method

Return type

LinearMultistepMethod

Returns

linear system multistep method

getLinearSolver() [source]
Return type

LinearSolver

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

getMaxTime() [source]

Returns the maximum time allowed for integration

Return type

float

Returns

Time in seconds

getNewtonDampingFactorLowerBound() [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

NewtonDampingFactorMode

Returns

getNewtonMaxSteps() int[source]

Get maximum number of allowed Newton steps for steady state computation

Return type

int

Returns

Returns how convergence checks for steadystate computation are performed. If activated, convergence checks are limited to every 25 steps in the simulation solver to limit performance impact.

Return type

boolean

Returns

boolean flag indicating newton step (true) or the right hand side (false)

getNonlinearSolverIteration() [source]

returns the nonlinear system solution method

Return type

NonlinearSolverIteration

Returns

getNumErrTestFails() [source]

Accessor netf

Return type

IntVector

Returns

netf

getNumErrTestFailsB() [source]

Accessor netfB

Return type

IntVector

Returns

netfB

getNumNonlinSolvConvFails() [source]

Accessor nnlscf

Return type

IntVector

Returns

nnlscf

getNumNonlinSolvConvFailsB() [source]

Accessor nnlscfB

Return type

IntVector

Returns

nnlscfB

getNumRhsEvals() [source]

Accessor nrhs

Return type

IntVector

Returns

nrhs

getNumRhsEvalsB() [source]

Accessor nrhsB

Return type

IntVector

Returns

nrhsB

getNumSteps() [source]

Accessor ns

Return type

IntVector

Returns

ns

getNumStepsB() [source]

Accessor nsB

Return type

IntVector

Returns

nsB

getRelativeTolerance() [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() [source]

Returns the relative tolerances for the adjoint sensitivity problem

Return type

float

Returns

relative tolerances

getRelativeToleranceFSA() [source]

Returns the relative tolerances for the forward sensitivity problem

Return type

float

Returns

relative tolerances

Returns the relative tolerance for the quadrature problem

Return type

float

Returns

relative tolerance

returns the relative tolerance for the steady state problem

Return type

float

Returns

relative tolerance

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

RDataReporting

Returns

ReturnData reporting mode

Returns how convergence checks for steadystate computation are performed.

Return type

boolean

Returns

boolean flag indicating state and sensitivity equations (true) or only state variables (false).

getSensitivityMethod() [source]

Return current sensitivity method

Return type

SensitivityMethod

Returns

method enum

getSensitivityMethodPreequilibration() [source]

Return current sensitivity method during preequilibration

Return type

SensitivityMethod

Returns

method enum

getSensitivityOrder() [source]

Get sensitivity order

Return type

SensitivityOrder

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).

returns the steady state sensitivity simulation tolerance factor.

Steady state sensitivity simulation tolerances are the product of the sensitivity simulation tolerances and this factor, unless manually set with set(Absolute/Relative)ToleranceSteadyStateSensi().

Return type

float

Returns

steady state simulation tolerance factor

returns the steady state simulation tolerance factor.

Steady state simulation tolerances are the product of the simulation tolerances and this factor, unless manually set with set(Absolute/Relative)ToleranceSteadyState().

Return type

float

Returns

steady state simulation tolerance factor

gett() [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()

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()

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

sets the absolute tolerance for the quadrature problem

Parameters

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

Return type

None

sets the absolute tolerance for the steady state problem

Parameters

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

Return type

None

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: amici.amici.InternalSensitivityMethod) None[source]

sets the internal sensitivity method

Parameters

ism (amici.amici.InternalSensitivityMethod) – internal sensitivity method

Return type

None

setInterpolationType(interpType: amici.amici.InterpolationType) None[source]

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

Parameters

interpType (amici.amici.InterpolationType) – interpolation type

Return type

None

setLinearMultistepMethod(lmm: amici.amici.LinearMultistepMethod) None[source]

sets the linear system multistep method

Parameters

lmm (amici.amici.LinearMultistepMethod) – linear system multistep method

Return type

None

setLinearSolver(linsol: amici.amici.LinearSolver) None[source]
Parameters

linsol (amici.amici.LinearSolver) –

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

setMaxTime(maxtime: float) None[source]

Set the maximum time allowed for integration

Parameters

maxtime (float) – Time in seconds

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: amici.amici.NewtonDampingFactorMode) None[source]

Turn on/off a damping factor in the Newton method

Parameters

dampingFactorMode (amici.amici.NewtonDampingFactorMode) –

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

Sets how convergence checks for steadystate computation are performed.

Parameters

flag (bool) – boolean flag to pick newton step (true) or the right hand side (false, default)

Return type

None

setNonlinearSolverIteration(iter: amici.amici.NonlinearSolverIteration) None[source]

sets the nonlinear system solution method

Parameters

iter (amici.amici.NonlinearSolverIteration) – nonlinear system solution method

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

sets the relative tolerance for the quadrature problem

Parameters

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

Return type

None

sets the relative tolerance for the steady state problem

Parameters

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

Return type

None

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: amici.amici.RDataReporting) None[source]

sets the ReturnData reporting mode

Parameters

rdrm (amici.amici.RDataReporting) – ReturnData reporting mode

Return type

None

Sets for which variables convergence checks for steadystate computation are performed.

Parameters

flag (bool) – boolean flag to pick state and sensitivity equations (true, default) or only state variables (false).

Return type

None

setSensitivityMethod(sensi_meth: amici.amici.SensitivityMethod) None[source]

Set sensitivity method

Parameters

sensi_meth (amici.amici.SensitivityMethod) –

Return type

None

setSensitivityMethodPreequilibration(sensi_meth_preeq: amici.amici.SensitivityMethod) None[source]

Set sensitivity method for preequilibration

Parameters

sensi_meth_preeq (amici.amici.SensitivityMethod) –

Return type

None

setSensitivityOrder(sensi: amici.amici.SensitivityOrder) None[source]

Set the sensitivity order

Parameters

sensi (amici.amici.SensitivityOrder) – 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

set the steady state sensitivity simulation tolerance factor.

Steady state sensitivity simulation tolerances are the product of the sensitivity simulation tolerances and this factor, unless manually set with set(Absolute/Relative)ToleranceSteadyStateSensi().

Parameters

factor (float) – tolerance factor (non-negative number)

Return type

None

set the steady state simulation tolerance factor.

Steady state simulation tolerances are the product of the simulation tolerances and this factor, unless manually set with set(Absolute/Relative)ToleranceSteadyState().

Parameters

factor (float) – tolerance factor (non-negative number)

Return type

None

startTimer() None[source]

Start timer for tracking integration time

Return type

None

switchForwardSensisOff() None[source]

Disable forward sensitivity integration (used in steady state sim)

Return type

None

timeExceeded() bool[source]

Check whether maximum integration time was exceeded

Return type

boolean

Returns

True if the maximum integration time was exceeded, false otherwise.