amici.adapters.fiddy

Adapters for using AMICI with the fiddy package for finite difference checks.

Note

Like fiddy, this module is experimental and subject to change.

Functions

run_simulation_to_cached_functions(...[, ...])

Convert run_simulation to fiddy functions.

simulate_petab_to_cached_functions(...[, ...])

Convert amici.sim.sundials.petab.v1.simulate_petab() (PEtab v1 simulations) to fiddy functions.

simulate_petab_v2_to_cached_functions(...[, ...])

Create fiddy functions for PetabSimulator.

amici.adapters.fiddy.run_simulation_to_cached_functions(amici_model, *, cache=True, free_parameter_ids=None, amici_solver=None, amici_edata=None, derivative_variables=None)[source]

Convert run_simulation to fiddy functions.

Parameters:
Returns:

function, derivatives and structure

amici.adapters.fiddy.simulate_petab_to_cached_functions(petab_problem, *, amici_model, free_parameter_ids=None, cache=True, precreate_edatas=True, precreate_parameter_mapping=True, simulate_petab=None, **kwargs)[source]

Convert amici.sim.sundials.petab.v1.simulate_petab() (PEtab v1 simulations) to fiddy functions.

Note that all gradients are provided on linear scale. The correction from ‘log10’ scale is automatically done.

Parameters:
  • amici_model (amici._installation.amici.Model) – The AMICI model to simulate.

  • simulate_petab (collections.abc.Callable[[typing.Any], str]) – A method to simulate PEtab problems with AMICI, e.g. amici.petab_objective.simulate_petab.

  • free_parameter_ids (list[str]) – The IDs of the parameters, in the order that parameter values will be supplied. Defaults to petab_problem.parameter_df.index.

  • petab_problem (petab.v1.problem.Problem) – The PEtab problem.

  • cache (bool) – Whether to cache the function call.

  • precreate_edatas (bool) – Whether to create the AMICI measurements object in advance, to save time.

  • precreate_parameter_mapping (bool) – Whether to create the AMICI parameter mapping object in advance, to save time.

  • kwargs – Passed to simulate_petab.

Return type:

tuple[collections.abc.Callable[[numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.double]]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.double]]], collections.abc.Callable[[numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.double]]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.double]]]]

Returns:

A tuple of:

  • 1: A method to compute the function at a point.

  • 2: A method to compute the gradient at a point.

amici.adapters.fiddy.simulate_petab_v2_to_cached_functions(petab_simulator, *, free_parameter_ids=None, cache=True)[source]

Create fiddy functions for PetabSimulator.

Parameters:
  • petab_simulator (amici.sim.sundials.petab._v2.PetabSimulator) – The PEtab simulator to use.

  • free_parameter_ids (list[str]) – The IDs of the parameters, in the order that parameter values will be supplied. Defaults to the estimated parameters of the PEtab problem.

  • cache (bool) – Whether to cache the function call.

Return type:

tuple[collections.abc.Callable[[numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.double]]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.double]]], collections.abc.Callable[[numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.double]]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.double]]]]

Returns:

tuple of:

  • 1: A method to compute the function at a point.

  • 2: A method to compute the gradient at a point.