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
|
Convert run_simulation to fiddy functions. |
|
Convert |
|
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:
amici_model (
amici._installation.amici.Model|amici._installation.amici.ModelPtr) – The AMICI model to simulate.amici_solver (
typing.Union[amici._installation.amici.Solver,amici._installation.amici.SolverPtr]) – The AMICI solver to use. If None, a new solver will be created from the model.amici_edata (
typing.Union[amici._installation.amici.ExpData,amici._installation.amici.ExpDataPtr]) – The AMICI ExpData to use. If None, no data will be used.derivative_variables (
list[str]) – The variables that derivatives will be computed or approximated for. See the keys of all_rdata_derivatives for options.free_parameter_ids (
list[str]) – The IDs that correspond to the values in the free parameter vector that is simulated.cache (
bool) – Whether to cache the function calls.
- 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.