pypesto.objective.roadrunner

RoadRunner objective

class pypesto.objective.roadrunner.ExpData[source]

Bases: object

Class for managing experimental data for a single condition.

__init__(condition_id, measurements, observable_ids, noise_distributions, noise_formulae)[source]

Initialize the ExpData object.

Parameters:
  • condition_id (str) – Identifier of the condition.

  • measurements (ndarray) – Numpy Array containing the measurement data. It is a 2D array of dimension (n_timepoints, n_observables + 1). The first column is the timepoints, the remaining columns are the observable values. Observables not measured at a given timepoint should be NaN.

  • timepoints – Timepoints of the measurement data.

  • observable_ids (Sequence[str]) – Observable ids of the measurement data. Order must match the columns of the measurements array (-time).

  • noise_distributions (ndarray) – Numpy Array describing noise distributions of the measurement data. Dimension: (n_timepoints, n_observables). Each entry is a string describing scale and type of noise distribution, the name is “scale_type”. E.g. “lin_normal”, “log_normal”, “log10_normal”.

  • noise_formulae (ndarray) – Numpy Array describing noise formulae of the measurement data. Dimension: (n_timepoints, n_observables). Each entry is a string describing the noise formula, either a parameter name or a constant.

static from_petab_problem(petab_problem)[source]

Create a list of ExpData object from a petab problem.

Parameters:

petab_problem (Problem) – PEtab problem.

Return type:

list[ExpData]

static from_petab_single_condition(condition_id, petab_problem)[source]

Create an ExpData object from a single condition of a petab problem.

Parameters:
  • condition_id (str) – Identifier of the condition.

  • petab_problem (Problem) – PEtab problem.

Return type:

ExpData

get_observable_ids()[source]

Get the observable ids of the measurement data.

Returns:

observable_ids – Observable ids of the measurement data.

sanity_check()[source]

Perform a sanity check of the data.

property timepoints

Timepoints of the measurement data.

class pypesto.objective.roadrunner.PetabImporterRR[source]

Bases: object

Importer for PEtab problems using RoadRunner.

Create a roadrunner.RoadRunner instance, a pypesto.objective.RoadRunnerObjective or a pypesto.problem.Problem from PEtab files. The actual form of the likelihood depends on the noise model specified in the provided PEtab problem. For more information, see the PEtab documentation.

__init__(petab_problem, validate_petab=True)[source]

Initialize importer.

Parameters:
  • petab_problem (Problem) – Managing access to the model and data.

  • validate_petab (bool) – Flag indicating if the PEtab problem shall be validated.

create_edatas()[source]

Create a List of ExpData objects from the PEtab problem.

Return type:

list[ExpData]

create_objective(rr=None, edatas=None)[source]

Create a pypesto.objective.RoadRunnerObjective.

Parameters:
  • rr (RoadRunner | None) – RoadRunner instance.

  • edatas (ExpData | None) – ExpData object.

Return type:

RoadRunnerObjective

create_parameter_mapping()[source]

Create a parameter mapping from the PEtab problem.

create_prior()[source]

Create a prior from the parameter table.

Returns None, if no priors are defined.

Return type:

NegLogParameterPriors | None

create_problem(objective=None, x_guesses=None, problem_kwargs=None, startpoint_kwargs=None, **kwargs)[source]

Create a pypesto.problem.Problem.

Parameters:
Return type:

Problem

Returns:

A pypesto.problem.Problem instance.

create_startpoint_method(**kwargs)[source]

Create a startpoint method.

Parameters:

**kwargs – Additional keyword arguments passed on to pypesto.startpoint.FunctionStartpoints.__init__().

Return type:

StartpointMethod

fill_model()[source]

Fill the RoadRunner model inplace from the PEtab problem.

Parameters:

return_model – Flag indicating if the model should be returned.

static from_yaml(yaml_config)[source]

Simplified constructor using a petab yaml file.

Return type:

PetabImporterRR

Parameters:

yaml_config (Path | str)

class pypesto.objective.roadrunner.RoadRunnerCalculator[source]

Bases: object

Class to handle RoadRunner simulation and obtain objective value.

__call__(x_dct, mode, roadrunner_instance, edatas, x_ids, parameter_mapping, petab_problem, solver_options=None)[source]

Perform the RoadRunner call and obtain objective function values.

Parameters:
  • x_dct (dict) – Parameter dictionary.

  • mode (Literal['mode_fun', 'mode_res']) – Mode of the call.

  • roadrunner_instance (RoadRunner) – RoadRunner instance.

  • edatas (list[ExpData]) – List of ExpData.

  • x_ids (Sequence[str]) – Sequence of parameter IDs.

  • parameter_mapping (list[tuple[dict[str, str | Number], dict[str, str | Number], dict[str, str], dict[str, str]]]) – Parameter parameter_mapping.

  • petab_problem (Problem) – PEtab problem.

  • solver_options (SolverOptions | None) – Solver options of the roadrunner instance Integrator. These will modify the roadrunner instance inplace.

Returns:

Tuple of objective function values.

fill_in_parameters(problem_parameters, roadrunner_instance=None, parameter_mapping=None, preeq=False, filling_mode=None)[source]

Fill in parameters into the roadrunner instance.

Parameters:
  • roadrunner_instance (RoadRunner | None) – RoadRunner instance to fill in parameters

  • problem_parameters (dict) – Problem parameters as parameterId=>value dict. Only parameters included here will be set. Remaining parameters will be used as already set in amici_model and edata.

  • parameter_mapping (tuple[dict[str, str | Number], dict[str, str | Number], dict[str, str], dict[str, str]] | None) – Parameter mapping for current condition. Quadruple of dicts, where the first dict contains the parameter mapping for pre- equilibration, the second dict contains the parameter mapping for the simulation, the third and fourth dict contain the scaling factors for the pre-equilibration and simulation, respectively.

  • preeq (bool) – Whether to fill in parameters for pre-equilibration.

  • filling_mode (str | None) – Which parameters to fill in. If None or “all”, all parameters are filled in. Other options are “only_parameters” and “only_species”.

Return type:

dict

Returns:

dict – Mapping of parameter IDs to values.

simulate_per_condition(x_dct, roadrunner_instance, edata, parameter_mapping_per_condition)[source]

Simulate the model for a single condition.

Parameters:
Return type:

tuple[ndarray, float]

Returns:

  • Tuple of simulation results in form of a numpy array and the

  • negative log-likelihood.

class pypesto.objective.roadrunner.SolverOptions[source]

Bases: dict

Class for managing solver options of roadrunner.

__init__(integrator=None, relative_tolerance=None, absolute_tolerance=None, maximum_num_steps=None, **kwargs)[source]

Initialize the SolverOptions object. Can be used as a dictionary.

Parameters:
  • integrator (str | None) – Integrator to use.

  • relative_tolerance (float | None) – Relative tolerance of the integrator.

  • absolute_tolerance (float | None) – Absolute tolerance of the integrator.

  • maximum_num_steps (int | None) – Maximum number of steps to take.

  • kwargs – Additional solver options.

apply_to_roadrunner(roadrunner_instance)[source]

Apply the solver options to a roadrunner object inplace.

Parameters:

roadrunner_instance (RoadRunner) – Roadrunner object to apply the solver options to.