Result Storage

This notebook will show how to store pypesto result objects to be able to load them later on for visualization and further analysis. This includes sampling, profiling and optimization. Additionally, we will show how to use optimization history to look further into an optimization run and how to store the history.

After this notebook, you will…

  • know how to store and load optimization, profiling and sampling results

  • know how to store and load optimization history

  • know basic plotting functions for optimization history to inspect optimization convergence

[1]:
# install if not done yet
# %pip install pypesto --quiet

Imports

[2]:
import logging
import random
import tempfile

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Markdown, display

import pypesto.optimize as optimize
import pypesto.petab
import pypesto.profile as profile
import pypesto.sample as sample
import pypesto.visualize as visualize

mpl.rcParams['figure.dpi'] = 100
mpl.rcParams['font.size'] = 18
# set a random seed to get reproducible results
random.seed(3142)

%matplotlib inline

0. Objective function and problem definition

We will use the Boehm model from the benchmark initiative in this notebook as an example. We load the model through PEtab, a data format for specifying parameter estimation problems in systems biology.

[3]:
%%capture
# directory of the PEtab problem
petab_yaml = './boehm_JProteomeRes2014/boehm_JProteomeRes2014.yaml'

importer = pypesto.petab.PetabImporter.from_yaml(petab_yaml)
problem = importer.create_problem(verbose=False)

1. Filling in the result file

We will now run a standard parameter estimation pipeline with this model. Aside from the part on the history, we shall not go into detail here, as this is covered in other tutorials such as Getting Started and AMICI in pyPESTO.

Optimization

[4]:
%%time

# create optimizers
optimizer = optimize.FidesOptimizer(
    verbose=logging.ERROR, options={"maxiter": 200}
)

# set number of starts
n_starts = 15  # usually a larger number >=100 is used

# Optimization
result = pypesto.optimize.minimize(
    problem=problem, optimizer=optimizer, n_starts=n_starts
)
2024-03-20 19:25:44.928 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.097 and h = 3.42012e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:44.929 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.097: AMICI failed to integrate the forward problem
2024-03-20 19:25:46.712 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 87.583 and h = 2.29413e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:46.712 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 87.583: AMICI failed to integrate the forward problem
2024-03-20 19:25:49.102 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 142.019 and h = 2.9208e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:49.103 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 142.019: AMICI failed to integrate the forward problem
2024-03-20 19:25:49.261 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.8025 and h = 1.67421e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:49.262 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.8025: AMICI failed to integrate the forward problem
2024-03-20 19:25:50.126 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.0201 and h = 3.80033e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:50.127 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.0201: AMICI failed to integrate the forward problem
2024-03-20 19:25:50.243 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.0044 and h = 2.17096e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:50.244 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.0044: AMICI failed to integrate the forward problem
2024-03-20 19:25:51.090 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 168.791 and h = 1.70052e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:51.090 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 168.791: AMICI failed to integrate the forward problem
2024-03-20 19:25:52.093 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 143.026 and h = 2.33908e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:52.094 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 143.026: AMICI failed to integrate the forward problem
2024-03-20 19:25:52.968 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 93.4087 and h = 2.61765e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:52.968 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 93.4087: AMICI failed to integrate the forward problem
2024-03-20 19:25:53.015 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 107.121 and h = 1.46363e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:53.015 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 107.121: AMICI failed to integrate the forward problem
2024-03-20 19:25:53.224 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 126.89 and h = 1.28434e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:53.225 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 126.89: AMICI failed to integrate the forward problem
2024-03-20 19:25:53.282 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 125.944 and h = 1.69654e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:53.282 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 125.944: AMICI failed to integrate the forward problem
2024-03-20 19:25:53.533 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 108.177 and h = 1.31098e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:53.534 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 108.177: AMICI failed to integrate the forward problem
2024-03-20 19:25:53.588 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 127.49 and h = 1.64297e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:53.588 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 127.49: AMICI failed to integrate the forward problem
2024-03-20 19:25:53.749 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 130.46 and h = 1.63019e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:53.750 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 130.46: AMICI failed to integrate the forward problem
2024-03-20 19:25:53.959 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 153.4 and h = 1.76847e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:53.960 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 153.4: AMICI failed to integrate the forward problem
2024-03-20 19:25:54.079 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 111.359 and h = 1.44523e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:54.080 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 111.359: AMICI failed to integrate the forward problem
2024-03-20 19:25:54.198 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 110.958 and h = 1.43311e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:54.199 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 110.958: AMICI failed to integrate the forward problem
2024-03-20 19:25:54.312 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 153.502 and h = 1.80378e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:54.312 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 153.502: AMICI failed to integrate the forward problem
2024-03-20 19:25:54.454 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 128.355 and h = 1.62855e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:54.454 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 128.355: AMICI failed to integrate the forward problem
2024-03-20 19:25:54.830 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 155.09 and h = 1.72383e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:54.831 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 155.09: AMICI failed to integrate the forward problem
2024-03-20 19:25:54.877 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 109.972 and h = 1.41997e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:54.877 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 109.972: AMICI failed to integrate the forward problem
2024-03-20 19:25:54.931 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 111.332 and h = 1.42942e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:54.931 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 111.332: AMICI failed to integrate the forward problem
2024-03-20 19:25:54.993 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 110.294 and h = 1.42353e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:54.993 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 110.294: AMICI failed to integrate the forward problem
2024-03-20 19:25:55.115 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 113.086 and h = 1.46995e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:55.116 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 113.086: AMICI failed to integrate the forward problem
2024-03-20 19:25:55.289 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 114.965 and h = 1.47371e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:55.289 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 114.965: AMICI failed to integrate the forward problem
2024-03-20 19:25:55.411 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 118.601 and h = 1.5262e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:55.411 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 118.601: AMICI failed to integrate the forward problem
2024-03-20 19:25:55.555 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 110.424 and h = 1.42523e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:55.556 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 110.424: AMICI failed to integrate the forward problem
2024-03-20 19:25:55.609 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 114.243 and h = 1.5074e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:55.609 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 114.243: AMICI failed to integrate the forward problem
2024-03-20 19:25:55.840 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 113.773 and h = 1.49827e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:55.841 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 113.773: AMICI failed to integrate the forward problem
2024-03-20 19:25:55.904 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 116.897 and h = 1.4955e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:55.905 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 116.897: AMICI failed to integrate the forward problem
2024-03-20 19:25:56.472 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 114.786 and h = 2.32459e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:56.473 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 114.786: AMICI failed to integrate the forward problem
2024-03-20 19:25:56.518 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 113.085 and h = 1.49349e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:56.519 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 113.085: AMICI failed to integrate the forward problem
2024-03-20 19:25:56.574 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 140.943 and h = 1.71682e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:56.575 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 140.943: AMICI failed to integrate the forward problem
2024-03-20 19:25:56.636 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 153.622 and h = 1.81515e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:56.637 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 153.622: AMICI failed to integrate the forward problem
2024-03-20 19:25:56.873 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 140.525 and h = 1.72976e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:56.874 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 140.525: AMICI failed to integrate the forward problem
2024-03-20 19:25:57.127 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 137.97 and h = 1.71208e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:57.127 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 137.97: AMICI failed to integrate the forward problem
2024-03-20 19:25:57.195 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 125.508 and h = 1.60093e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:57.196 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 125.508: AMICI failed to integrate the forward problem
2024-03-20 19:25:57.252 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 163.739 and h = 1.80804e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:57.253 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 163.739: AMICI failed to integrate the forward problem
2024-03-20 19:25:57.354 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 137.212 and h = 1.72058e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:57.355 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 137.212: AMICI failed to integrate the forward problem
2024-03-20 19:25:57.608 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 115.779 and h = 1.49736e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:57.609 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 115.779: AMICI failed to integrate the forward problem
2024-03-20 19:25:57.642 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 14.8243 and h = 3.33169e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:57.643 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 14.8243: AMICI failed to integrate the forward problem
2024-03-20 19:25:57.689 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 34.7566 and h = 3.60482e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:57.689 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 34.7566: AMICI failed to integrate the forward problem
2024-03-20 19:25:57.752 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 124.152 and h = 1.49987e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:57.752 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 124.152: AMICI failed to integrate the forward problem
2024-03-20 19:25:59.849 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 77.5903 and h = 1.34878e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:25:59.849 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 77.5903: AMICI failed to integrate the forward problem
2024-03-20 19:26:00.298 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 146.154 and h = 4.37569e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:00.299 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 146.154: AMICI failed to integrate the forward problem
2024-03-20 19:26:02.703 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 144.615 and h = 5.07401e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:02.703 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 144.615: AMICI failed to integrate the forward problem
2024-03-20 19:26:02.721 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 86.4191 and h = 6.9592e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:02.721 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 86.4191: AMICI failed to integrate the forward problem
2024-03-20 19:26:03.310 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 186.302 and h = 3.05531e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:03.310 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 186.302: AMICI failed to integrate the forward problem
2024-03-20 19:26:05.942 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 136.423 and h = 3.06837e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:05.943 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 136.423: AMICI failed to integrate the forward problem
2024-03-20 19:26:05.961 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 74.1892 and h = 8.75255e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:05.962 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 74.1892: AMICI failed to integrate the forward problem
2024-03-20 19:26:06.611 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9506 and h = 1.3133e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:06.612 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9506: AMICI failed to integrate the forward problem
CPU times: user 22.6 s, sys: 663 ms, total: 23.2 s
Wall time: 22.3 s
[5]:
display(Markdown(result.summary()))

Optimization Result

  • number of starts: 15

  • best value: 147.5439636663234, id=13

  • worst value: 249.7459964411297, id=1

  • number of non-finite values: 0

  • execution time summary:

    • Mean execution time: 1.483s

    • Maximum execution time: 5.363s, id=9

    • Minimum execution time: 0.277s, id=1

  • summary of optimizer messages:

    Count

    Message

    13

    Converged according to fval difference

    2

    Trust Region Radius too small to proceed

  • best value found (approximately) 9 time(s)

  • number of plateaus found: 3

A summary of the best run:

Optimizer Result

  • optimizer used: <FidesOptimizer hessian_update=default verbose=40 options={‘maxiter’: 200}>

  • message: Trust Region Radius too small to proceed

  • number of evaluations: 73

  • time taken to optimize: 1.289s

  • startpoint: [ 0.67308056 -2.24646671 3.59984763 -0.44269302 3.42528599 -0.66532088 -2.34967758 -2.4519005 1.86569547]

  • endpoint: [-1.50328543 -3.35664321 4.99353675 -1.7777682 -1.75869051 3.98195797 0.63199864 0.78931234 0.73482471]

  • final objective value: 147.5439636663234

  • final gradient value: [ 1.26008783e-02 3.99880118e-05 -5.04226244e-06 3.93953534e-02 3.37773090e-03 -1.84513592e-02 9.81165917e-04 -2.72053625e-04 -4.31453389e-04]

  • final hessian value: [[ 2.42071678e+03 2.19214994e+01 -1.20405655e-04 1.80820239e+03 6.88056543e+02 -9.06312620e+02 1.80754747e+01 -9.23165429e+00 -8.87283501e+00] [ 2.19214994e+01 1.01597417e+00 -2.14053106e-06 1.36255684e+01 8.89839975e-01 -9.03583342e+00 -4.55777652e-02 -2.98884546e-01 3.44370236e-01] [-1.20405655e-04 -2.14053106e-06 1.09136856e-11 -8.40504024e-05 -2.53302690e-05 6.51041339e-05 2.81742541e-06 -5.53246929e-08 8.84813762e-06] [ 1.80820239e+03 1.36255684e+01 -8.40504024e-05 1.37831620e+03 5.21915628e+02 -6.38406844e+02 2.39206289e+01 -8.19814737e+00 -1.58131927e+01] [ 6.88056543e+02 8.89839975e-01 -2.53302690e-05 5.21915628e+02 2.98499734e+02 -2.95583014e+02 -1.05354251e+01 -4.06376376e+00 1.45914113e+01] [-9.06312620e+02 -9.03583342e+00 6.51041339e-05 -6.38406844e+02 -2.95583014e+02 8.97347257e+02 1.04818061e+01 -3.74332119e+01 2.69938917e+01] [ 1.80754747e+01 -4.55777652e-02 2.81742541e-06 2.39206289e+01 -1.05354251e+01 1.04818061e+01 8.48281105e+01 0.00000000e+00 0.00000000e+00] [-9.23165429e+00 -2.98884546e-01 -5.53246929e-08 -8.19814737e+00 -4.06376376e+00 -3.74332119e+01 0.00000000e+00 8.48309962e+01 0.00000000e+00] [-8.87283501e+00 3.44370236e-01 8.84813762e-06 -1.58131927e+01 1.45914113e+01 2.69938917e+01 0.00000000e+00 0.00000000e+00 8.48313632e+01]]

Profiling

[6]:
%%time

# Profiling
result = profile.parameter_profile(
    problem=problem,
    result=result,
    optimizer=optimizer,
    profile_index=np.array([1, 1, 1, 0, 0, 0, 0, 0, 1]),
)
2024-03-20 19:26:07.189 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 94.929 and h = 6.78998e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:07.189 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 94.929: AMICI failed to integrate the forward problem
Optimization at k_exp_hetero=-5.0 failed.
2024-03-20 19:26:09.977 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.566 and h = 2.96062e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:09.978 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.566: AMICI failed to integrate the forward problem
2024-03-20 19:26:10.565 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.548 and h = 2.09162e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:10.566 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.548: AMICI failed to integrate the forward problem
2024-03-20 19:26:10.687 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.876 and h = 5.39717e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:10.687 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.876: AMICI failed to integrate the forward problem
2024-03-20 19:26:10.734 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.58 and h = 2.30667e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:10.734 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.58: AMICI failed to integrate the forward problem
2024-03-20 19:26:11.308 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 148.049 and h = 2.39617e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:11.309 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 148.049: AMICI failed to integrate the forward problem
2024-03-20 19:26:12.383 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.569 and h = 2.16294e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:12.383 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.569: AMICI failed to integrate the forward problem
2024-03-20 19:26:13.410 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.043 and h = 2.97505e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:13.410 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.043: AMICI failed to integrate the forward problem
2024-03-20 19:26:13.806 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 83.8115 and h = 4.39714e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:13.807 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 83.8115: AMICI failed to integrate the forward problem
2024-03-20 19:26:13.825 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 144.829 and h = 3.41425e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:13.826 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 144.829: AMICI failed to integrate the forward problem
2024-03-20 19:26:14.032 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 84.2843 and h = 1.59466e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:14.032 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 84.2843: AMICI failed to integrate the forward problem
2024-03-20 19:26:14.114 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 144.547 and h = 3.84582e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:14.114 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 144.547: AMICI failed to integrate the forward problem
2024-03-20 19:26:14.255 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 144.189 and h = 4.08935e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:14.256 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 144.189: AMICI failed to integrate the forward problem
2024-03-20 19:26:14.437 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 142.36 and h = 2.2419e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:14.438 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 142.36: AMICI failed to integrate the forward problem
2024-03-20 19:26:14.930 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 144.024 and h = 2.03423e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:14.931 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 144.024: AMICI failed to integrate the forward problem
2024-03-20 19:26:16.221 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 135.955 and h = 2.51324e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:16.222 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 135.955: AMICI failed to integrate the forward problem
2024-03-20 19:26:16.395 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 136.189 and h = 1.96499e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:16.396 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 136.189: AMICI failed to integrate the forward problem
2024-03-20 19:26:16.524 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 136.876 and h = 3.39639e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:16.524 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 136.876: AMICI failed to integrate the forward problem
2024-03-20 19:26:16.730 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 136.473 and h = 2.79594e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:16.731 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 136.473: AMICI failed to integrate the forward problem
2024-03-20 19:26:16.804 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 136.275 and h = 2.31002e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:16.805 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 136.275: AMICI failed to integrate the forward problem
2024-03-20 19:26:16.917 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 136.343 and h = 2.3481e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:16.918 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 136.343: AMICI failed to integrate the forward problem
2024-03-20 19:26:17.213 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 132.125 and h = 3.72967e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:17.214 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 132.125: AMICI failed to integrate the forward problem
2024-03-20 19:26:17.234 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 132.081 and h = 3.44384e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:17.234 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 132.081: AMICI failed to integrate the forward problem
2024-03-20 19:26:17.250 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 53.7891 and h = 5.84671e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:17.251 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 53.7891: AMICI failed to integrate the forward problem
2024-03-20 19:26:17.792 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 132.634 and h = 2.88909e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:17.793 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 132.634: AMICI failed to integrate the forward problem
2024-03-20 19:26:17.981 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 132.609 and h = 1.76747e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:17.982 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 132.609: AMICI failed to integrate the forward problem
2024-03-20 19:26:18.021 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 132.516 and h = 9.94374e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:18.022 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 132.516: AMICI failed to integrate the forward problem
2024-03-20 19:26:18.313 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 54.562 and h = 9.81629e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:18.314 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 54.562: AMICI failed to integrate the forward problem
2024-03-20 19:26:18.735 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 38.1282 and h = 8.99761e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:18.736 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 38.1282: AMICI failed to integrate the forward problem
2024-03-20 19:26:19.037 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 149.906 and h = 1.98929e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:19.038 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 149.906: AMICI failed to integrate the forward problem
2024-03-20 19:26:19.671 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 155.109 and h = 3.74998e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:19.672 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 155.109: AMICI failed to integrate the forward problem
2024-03-20 19:26:19.709 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 155.312 and h = 4.867e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:19.709 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 155.312: AMICI failed to integrate the forward problem
2024-03-20 19:26:19.797 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 81.1958 and h = 2.11947e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:19.798 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 81.1958: AMICI failed to integrate the forward problem
2024-03-20 19:26:20.140 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 158.576 and h = 3.06963e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:20.140 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 158.576: AMICI failed to integrate the forward problem
2024-03-20 19:26:20.156 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 78.6187 and h = 3.35448e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:20.157 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 78.6187: AMICI failed to integrate the forward problem
2024-03-20 19:26:20.791 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 168.078 and h = 2.35881e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:20.792 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 168.078: AMICI failed to integrate the forward problem
2024-03-20 19:26:21.638 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 95.7711 and h = 1.81801e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:21.639 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 95.7711: AMICI failed to integrate the forward problem
2024-03-20 19:26:22.131 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 96.6452 and h = 2.27067e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:22.132 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 96.6452: AMICI failed to integrate the forward problem
2024-03-20 19:26:22.211 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 97.1053 and h = 5.32124e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:22.211 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 97.1053: AMICI failed to integrate the forward problem
2024-03-20 19:26:22.839 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 99.2837 and h = 5.19953e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:22.840 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 99.2837: AMICI failed to integrate the forward problem
2024-03-20 19:26:22.952 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 133.551 and h = 4.81411e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:22.952 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 133.551: AMICI failed to integrate the forward problem
2024-03-20 19:26:23.151 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 101.972 and h = 5.92597e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:23.152 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 101.972: AMICI failed to integrate the forward problem
2024-03-20 19:26:23.258 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 133.064 and h = 1.35584e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:23.258 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 133.064: AMICI failed to integrate the forward problem
2024-03-20 19:26:23.574 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 133.064 and h = 2.34855e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:23.575 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 133.064: AMICI failed to integrate the forward problem
CPU times: user 17.3 s, sys: 641 ms, total: 17.9 s
Wall time: 16.9 s

Sampling

[7]:
%%time

# Sampling
sampler = sample.AdaptiveMetropolisSampler()
result = sample.sample(
    problem=problem,
    sampler=sampler,
    n_samples=5000,  # rather low
    result=result,
    filename=None,
)
Elapsed time: 17.496361299999997
CPU times: user 15 s, sys: 2.51 s, total: 17.5 s
Wall time: 13.7 s

2. Storing the result file

We filled all our analyses into one result file. We can now store this result object into HDF5 format to reload this later on.

[8]:
# create temporary file
fn = tempfile.mktemp(".hdf5")

# write the result with the write_result function.
# Choose which parts of the result object to save with
# corresponding booleans.
pypesto.store.write_result(
    result=result,
    filename=fn,
    problem=True,
    optimize=True,
    profile=True,
    sample=True,
)

As easy as we can save the result object, we can also load it again:

[9]:
# load result with read_result function
result_loaded = pypesto.store.read_result(fn)
/home/docs/checkouts/readthedocs.org/user_builds/pypesto/envs/v0.4.2/lib/python3.11/site-packages/pypesto/store/read_from_hdf5.py:124: UserWarning: You are loading a problem. This problem is not to be used without a separately created objective.
  warnings.warn(

As you can see, when loading the result object, we get a warning regarding the problem. This is the case, as the problem is not fully saved into hdf5, as a big part of the problem is the objective function. Therefore, after loading the result object, we cannot evaluate the objective function anymore. We can, however, still use the result object for plotting and further analysis.

The best practice would be to still create the problem through petab and insert it into the result object after loading it.

[10]:
# dummy call to non-existent objective function would fail
test_parameter = result.optimize_result[0].x[problem.x_free_indices]
# result_loaded.problem.objective(test_parameter)
[11]:
result_loaded.problem = problem
print(
    f"Objective function call: {result_loaded.problem.objective(test_parameter)}"
)
print(f"Corresponding saved value: {result_loaded.optimize_result[0].fval}")
Objective function call: 147.54396905643355
Corresponding saved value: 147.5439636663234

To show that for visualizations however, the storage and loading of the result object is accurate, we will plot some result visualizations.

3. Visualization Comparison

Optimization

[12]:
# waterfall plot original
ax = visualize.waterfall(result)
ax.title.set_text("Original Result")
../_images/example_store_24_0.png
[13]:
# waterfall plot loaded
ax = visualize.waterfall(result_loaded)
ax.title.set_text("Loaded Result")
../_images/example_store_25_0.png

Profiling

[14]:
# profile plot original
ax = visualize.profiles(result)
../_images/example_store_27_0.png
[15]:
# profile plot loaded
ax = visualize.profiles(result_loaded)
../_images/example_store_28_0.png

Sampling

[16]:
# sampling plot original
ax = visualize.sampling_fval_traces(result)
/home/docs/checkouts/readthedocs.org/user_builds/pypesto/envs/v0.4.2/lib/python3.11/site-packages/pypesto/visualize/sampling.py:1383: UserWarning: Burn in index not found in the results, the full chain will be shown.
You may want to use, e.g., `pypesto.sample.geweke_test`.
  warnings.warn(
../_images/example_store_30_1.png
[17]:
# sampling plot loaded
ax = visualize.sampling_fval_traces(result_loaded)
/home/docs/checkouts/readthedocs.org/user_builds/pypesto/envs/v0.4.2/lib/python3.11/site-packages/pypesto/visualize/sampling.py:1383: UserWarning: Burn in index not found in the results, the full chain will be shown.
You may want to use, e.g., `pypesto.sample.geweke_test`.
  warnings.warn(
../_images/example_store_31_1.png

We can see that we are perfectly able to reproduce the plots from the loaded result object. With this, we can reuse the result object for further analysis and visualization again and again without spending time and resources on rerunning the analyses.

4. Optimization History

During optimization, it is possible to regularly write the objective function trace to file. This is useful, e.g., when runs fail, or for various diagnostics. Currently, pyPESTO can save histories to 3 backends: in-memory, as CSV files, or to HDF5 files.

Memory History

To record the history in-memory, just set trace_record=True in the pypesto.HistoryOptions. Then, the optimization result contains those histories:

[18]:
# record the history
history_options = pypesto.HistoryOptions(trace_record=True)

# Run optimizations
result = optimize.minimize(
    problem=problem,
    optimizer=optimizer,
    n_starts=n_starts,
    history_options=history_options,
    filename=None,
)
2024-03-20 19:26:40.390 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 73.8649 and h = 1.04813e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:40.391 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 73.8649: AMICI failed to integrate the forward problem
2024-03-20 19:26:40.566 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.339 and h = 3.06602e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:40.567 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.339: AMICI failed to integrate the forward problem
2024-03-20 19:26:40.604 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 144.771 and h = 1.68708e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:40.605 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 144.771: AMICI failed to integrate the forward problem
2024-03-20 19:26:40.943 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.5677 and h = 3.15532e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:40.944 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.5677: AMICI failed to integrate the forward problem
2024-03-20 19:26:41.756 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9402 and h = 1.52429e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:41.757 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9402: AMICI failed to integrate the forward problem
2024-03-20 19:26:42.081 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9963 and h = 1.36732e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:42.082 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9963: AMICI failed to integrate the forward problem
2024-03-20 19:26:42.466 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.053 and h = 4.42519e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:42.467 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.053: AMICI failed to integrate the forward problem
2024-03-20 19:26:43.359 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.018 and h = 1.20084e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:43.360 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.018: AMICI failed to integrate the forward problem
2024-03-20 19:26:44.913 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 64.3078 and h = 9.06641e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:44.914 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 64.3078: AMICI failed to integrate the forward problem
2024-03-20 19:26:45.037 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 137.832 and h = 2.105e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:45.038 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 137.832: AMICI failed to integrate the forward problem
2024-03-20 19:26:45.483 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 87.7627 and h = 2.73593e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:45.483 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 87.7627: AMICI failed to integrate the forward problem
2024-03-20 19:26:45.640 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.538 and h = 2.04687e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:45.640 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.538: AMICI failed to integrate the forward problem
2024-03-20 19:26:45.676 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.499 and h = 3.45626e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:45.676 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.499: AMICI failed to integrate the forward problem
2024-03-20 19:26:45.730 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9603 and h = 5.14222e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:45.731 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9603: AMICI failed to integrate the forward problem
2024-03-20 19:26:48.258 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 94.222 and h = 7.01761e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:48.259 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 94.222: AMICI failed to integrate the forward problem
2024-03-20 19:26:48.327 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 94.8527 and h = 1.67801e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:48.328 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 94.8527: AMICI failed to integrate the forward problem
2024-03-20 19:26:49.439 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 76.127 and h = 9.18259e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:49.440 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 76.127: AMICI failed to integrate the forward problem
2024-03-20 19:26:50.127 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.9287 and h = 2.85704e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:50.128 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.9287: AMICI failed to integrate the forward problem
2024-03-20 19:26:50.198 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.35 and h = 1.97181e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:50.198 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.35: AMICI failed to integrate the forward problem
2024-03-20 19:26:52.153 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 174.817 and h = 4.25904e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:52.153 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 174.817: AMICI failed to integrate the forward problem
2024-03-20 19:26:52.325 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.5478 and h = 2.25228e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:52.326 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.5478: AMICI failed to integrate the forward problem
2024-03-20 19:26:52.657 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.0871 and h = 4.69111e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:52.657 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.0871: AMICI failed to integrate the forward problem
2024-03-20 19:26:54.000 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 210.629 and h = 7.66609e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:54.000 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 210.629: AMICI failed to integrate the forward problem
2024-03-20 19:26:54.543 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.5713 and h = 1.6983e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:54.543 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.5713: AMICI failed to integrate the forward problem
2024-03-20 19:26:55.250 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.649 and h = 3.0026e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:55.250 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.649: AMICI failed to integrate the forward problem

Now, in addition to queries on the result, we can also access the history.

[19]:
print("History type: ", type(result.optimize_result.list[0].history))
# print("Function value trace of best run: ", result.optimize_result.list[0].history.get_fval_trace())

fig, ax = plt.subplots(1, 2)
visualize.waterfall(result, ax=ax[0])
visualize.optimizer_history(result, ax=ax[1])
fig.set_size_inches((15, 5))
History type:  <class 'pypesto.history.memory.MemoryHistory'>
../_images/example_store_39_1.png

CSV History

The in-memory storage is, however, not stored anywhere. To do that, it is possible to store either to CSV or HDF5. This is specified via the storage_file option. If it ends in .csv, a pypesto.objective.history.CsvHistory will be employed; if it ends in .hdf5 a pypesto.objective.history.Hdf5History. Occurrences of the substring {id} in the filename are replaced by the multistart id, allowing to maintain a separate file per run (this is necessary for CSV as otherwise runs are overwritten).

[20]:
# create temporary file
fn_csv = tempfile.mktemp("_{id}.hdf5")
# record the history and store to CSV
history_options = pypesto.HistoryOptions(
    trace_record=True, storage_file=fn_csv
)

# Run optimizations
result = optimize.minimize(
    problem=problem,
    optimizer=optimizer,
    n_starts=n_starts,
    history_options=history_options,
    filename=None,
)
2024-03-20 19:26:59.180 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 136.362 and h = 3.49853e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:59.180 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 136.362: AMICI failed to integrate the forward problem
2024-03-20 19:26:59.323 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 137.825 and h = 3.07594e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:59.323 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 137.825: AMICI failed to integrate the forward problem
2024-03-20 19:26:59.452 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 143.829 and h = 1.60903e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:59.452 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 143.829: AMICI failed to integrate the forward problem
2024-03-20 19:26:59.529 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 71.4926 and h = 1.08992e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:26:59.529 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 71.4926: AMICI failed to integrate the forward problem
2024-03-20 19:27:00.434 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.952 and h = 1.43099e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:00.435 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.952: AMICI failed to integrate the forward problem
2024-03-20 19:27:02.103 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.884 and h = 3.7621e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:02.104 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.884: AMICI failed to integrate the forward problem
2024-03-20 19:27:02.358 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 146.654 and h = 4.46772e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:02.358 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 146.654: AMICI failed to integrate the forward problem
2024-03-20 19:27:04.879 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 143.556 and h = 3.72512e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:04.880 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 143.556: AMICI failed to integrate the forward problem
2024-03-20 19:27:08.440 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.538 and h = 2.9915e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:08.441 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.538: AMICI failed to integrate the forward problem
2024-03-20 19:27:08.524 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.1326 and h = 1.28587e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:08.524 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.1326: AMICI failed to integrate the forward problem
2024-03-20 19:27:11.649 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 158.699 and h = 3.42461e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:11.650 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 158.699: AMICI failed to integrate the forward problem
2024-03-20 19:27:13.676 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 177.338 and h = 2.8661e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:13.677 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 177.338: AMICI failed to integrate the forward problem
2024-03-20 19:27:14.079 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.534 and h = 2.86e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:14.080 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.534: AMICI failed to integrate the forward problem
2024-03-20 19:27:14.227 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.838 and h = 3.2006e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:14.227 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.838: AMICI failed to integrate the forward problem

Note that for this simple cost function, saving to CSV takes a considerable amount of time. This overhead decreases for more costly simulators, e.g., using ODE simulations via AMICI.

[21]:
print("History type: ", type(result.optimize_result.list[0].history))
# print("Function value trace of best run: ", result.optimize_result.list[0].history.get_fval_trace())

fig, ax = plt.subplots(1, 2)
visualize.waterfall(result, ax=ax[0])
visualize.optimizer_history(result, ax=ax[1])
fig.set_size_inches((15, 5))
History type:  <class 'pypesto.history.amici.Hdf5AmiciHistory'>
../_images/example_store_44_1.png

HDF5 History

Just as in CSV, writing the history to HDF5 takes a considerable amount of time. If a user specifies a HDF5 output file named my_results.hdf5 and uses a parallelization engine, then: * a folder is created to contain partial results, named my_results/ (the stem of the output filename) * files are created to store the results of each start, named my_results/my_results_{START_INDEX}.hdf5 * a file is created to store the combined result from all starts, named my_results.hdf5. Note that this file depends on the files in the my_results/ directory, so cease to function if my_results/ is deleted.

[22]:
# create temporary file
fn_hdf5 = tempfile.mktemp(".hdf5")
# record the history and store to CSV
history_options = pypesto.HistoryOptions(
    trace_record=True, storage_file=fn_hdf5
)

# Run optimizations
result = optimize.minimize(
    problem=problem,
    optimizer=optimizer,
    n_starts=n_starts,
    history_options=history_options,
    filename=fn_hdf5,
)
2024-03-20 19:27:15.962 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 130.939 and h = 6.09564e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:15.963 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 130.939: AMICI failed to integrate the forward problem
2024-03-20 19:27:16.136 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 87.5675 and h = 5.77917e-06, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:16.136 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 87.5675: AMICI failed to integrate the forward problem
2024-03-20 19:27:19.594 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 88.8743 and h = 1.03313e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:19.595 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 88.8743: AMICI failed to integrate the forward problem
2024-03-20 19:27:19.656 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.604 and h = 2.61059e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:19.656 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.604: AMICI failed to integrate the forward problem
2024-03-20 19:27:22.229 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 135.755 and h = 3.42894e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:22.230 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 135.755: AMICI failed to integrate the forward problem
2024-03-20 19:27:22.644 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.618 and h = 3.14287e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:22.645 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.618: AMICI failed to integrate the forward problem
2024-03-20 19:27:27.693 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 146.099 and h = 4.20115e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:27.693 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 146.099: AMICI failed to integrate the forward problem
2024-03-20 19:27:27.737 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.201 and h = 3.30315e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:27.737 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.201: AMICI failed to integrate the forward problem
2024-03-20 19:27:30.012 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 144.883 and h = 3.21806e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:30.013 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 144.883: AMICI failed to integrate the forward problem
2024-03-20 19:27:30.097 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 87.4291 and h = 1.04476e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:30.097 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 87.4291: AMICI failed to integrate the forward problem
2024-03-20 19:27:30.415 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 89.0066 and h = 1.269e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:30.415 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 89.0066: AMICI failed to integrate the forward problem
2024-03-20 19:27:31.765 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 134.827 and h = 3.37533e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:31.766 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 134.827: AMICI failed to integrate the forward problem
2024-03-20 19:27:40.534 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.673 and h = 4.16952e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:40.535 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.673: AMICI failed to integrate the forward problem
2024-03-20 19:27:40.576 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.405 and h = 3.98719e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:40.577 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.405: AMICI failed to integrate the forward problem
2024-03-20 19:27:40.678 - amici.swig_wrappers - DEBUG - [model1_data1][CVODES:CVode:ERR_FAILURE] AMICI ERROR: in module CVODES in function CVode : At t = 145.401 and h = 4.0307e-05, the error test failed repeatedly or with |h| = hmin.
2024-03-20 19:27:40.678 - amici.swig_wrappers - ERROR - [model1_data1][FORWARD_FAILURE] AMICI forward simulation failed at t = 145.401: AMICI failed to integrate the forward problem
[23]:
print("History type: ", type(result.optimize_result.list[0].history))
# print("Function value trace of best run: ", result.optimize_result.list[0].history.get_fval_trace())

fig, ax = plt.subplots(1, 2)
visualize.waterfall(result, ax=ax[0])
visualize.optimizer_history(result, ax=ax[1])
fig.set_size_inches((15, 5))
History type:  <class 'pypesto.history.amici.Hdf5AmiciHistory'>
../_images/example_store_48_1.png

For the HDF5 history, it is possible to load the history from file, and to plot it, together with the optimization result.

[24]:
# load the history
result_loaded_w_history = pypesto.store.read_result(fn_hdf5)

fig, ax = plt.subplots(1, 2)
visualize.waterfall(result_loaded_w_history, ax=ax[0])
visualize.optimizer_history(result_loaded_w_history, ax=ax[1])
fig.set_size_inches((15, 5))
/home/docs/checkouts/readthedocs.org/user_builds/pypesto/envs/v0.4.2/lib/python3.11/site-packages/pypesto/store/read_from_hdf5.py:124: UserWarning: You are loading a problem. This problem is not to be used without a separately created objective.
  warnings.warn(
Loading the profiling result failed. It is highly likely that no profiling result exists within /tmp/tmpufunul1p.hdf5.
Loading the sampling result failed. It is highly likely that no sampling result exists within /tmp/tmpufunul1p.hdf5.
../_images/example_store_50_3.png